|
| 1 | +const lightTheme: { [k: string]: string } = { |
| 2 | + '--color-background': 'var(--vt-c-white)', |
| 3 | + '--color-background-soft': 'var(--vt-c-white-soft)', |
| 4 | + '--color-background-mute': 'var(--vt-c-white-mute)', |
| 5 | + '--color-border': 'var(--vt-c-divider-light-2)', |
| 6 | + '--color-border-hover': 'var(--vt-c-divider-light-1)', |
| 7 | + '--color-heading': 'var(--vt-c-text-light-1)', |
| 8 | + '--color-text': 'var(--vt-c-text-light-1)' |
| 9 | +} |
| 10 | + |
| 11 | +const darkTheme: { [k: string]: string } = { |
| 12 | + '--color-background': 'var(--vt-c-black)', |
| 13 | + '--color-background-soft': 'var(--vt-c-black-soft)', |
| 14 | + '--color-background-mute': 'var(--vt-c-black-mute)', |
| 15 | + '--color-border': 'var(--vt-c-divider-dark-2)', |
| 16 | + '--color-border-hover': 'var(--vt-c-divider-dark-1)', |
| 17 | + '--color-heading': 'var(--vt-c-text-dark-1)', |
| 18 | + '--color-text': 'var(--vt-c-text-dark-2)' |
| 19 | +} |
| 20 | + |
| 21 | + |
| 22 | +export default function setTheme(darkMode: boolean) { |
| 23 | + const theme = darkMode ? darkTheme : lightTheme |
| 24 | + Object.keys(theme).forEach((key) => { |
| 25 | + document.documentElement.style.setProperty(key, theme[key]) |
| 26 | + }) |
| 27 | +} |
0 commit comments