-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: load space's custom colors (#1090)
* feat: apply custom colors from space * feat: load dark/light theme for skin * feat: disable dark/light theme toggler on custom skin * refactor: use a dedicated function to set skin * refactor: fix types --------- Co-authored-by: Chaitanya <[email protected]>
- Loading branch information
Showing
9 changed files
with
84 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
type Skin = 'dark' | 'light' | 'none'; | ||
export type Skin = 'dark' | 'light' | 'none'; | ||
|
||
const DEFAULT_SKIN = 'light'; | ||
|
||
export function useUserSkin() { | ||
const store = useStorage<Skin>('skin', 'none'); | ||
const currentMode = computed(() => | ||
['light', 'none'].includes(store.value) ? 'light' : 'dark' | ||
[DEFAULT_SKIN, 'none'].includes(store.value) ? DEFAULT_SKIN : 'dark' | ||
); | ||
|
||
function toggleSkin() { | ||
store.value = ['light', 'none'].includes(store.value) ? 'dark' : 'light'; | ||
} | ||
|
||
function setSkin(skin: Skin) { | ||
store.value = skin; | ||
} | ||
|
||
watchEffect(() => { | ||
if (currentMode.value === 'light') { | ||
if (currentMode.value === DEFAULT_SKIN) { | ||
document.documentElement.classList.remove('dark'); | ||
} else { | ||
document.documentElement.classList.add('dark'); | ||
} | ||
}); | ||
|
||
return { | ||
DEFAULT_SKIN, | ||
currentMode, | ||
toggleSkin | ||
toggleSkin, | ||
setSkin | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters