-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: moved theme related code to theme.js
- Loading branch information
1 parent
36e8ae1
commit 211107f
Showing
4 changed files
with
24 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useStorage } from '@vueuse/core' | ||
|
||
export const theme = useStorage('theme', 'light') | ||
|
||
export function toggleTheme() { | ||
const currentTheme = document.documentElement.getAttribute('data-theme') | ||
theme.value = currentTheme === 'dark' ? 'light' : 'dark' | ||
document.documentElement.setAttribute('data-theme', theme.value) | ||
} | ||
|
||
export function setTheme(value) { | ||
theme.value = value || theme.value | ||
if (['light', 'dark'].includes(theme.value)) { | ||
document.documentElement.setAttribute('data-theme', theme.value) | ||
} | ||
} |