Commit 1ab03abafe
Unsigned
Layout: unified · split
docs/.vitepress/theme/Layout.vue +22 −7
| @@ -572,7 +572,10 @@ watchEffect(() => { | |||
| 572 | ) | 572 | ) |
| 573 | }) | 573 | }) |
| 574 | 574 | ||
| 575 | const accentPalettes: Record<string, Record<string, string>> = { | 575 | type ShadeMap = Record<string, string> |
| 576 | type PaletteEntry = ShadeMap | { dark: ShadeMap; light: ShadeMap } | ||
| 577 | |||
| 578 | const accentPalettes: Record<string, PaletteEntry> = { | ||
| 576 | ayanami: { | 579 | ayanami: { |
| 577 | 400: 'oklch(0.722 0.105 247.48)', | 580 | 400: 'oklch(0.722 0.105 247.48)', |
| 578 | 500: 'oklch(0.626 0.098 247.46)', | 581 | 500: 'oklch(0.626 0.098 247.46)', |
| @@ -616,11 +619,20 @@ const accentPalettes: Record<string, Record<string, string>> = { | |||
| 616 | 800: 'oklch(0.461 0.176 28.95)', | 619 | 800: 'oklch(0.461 0.176 28.95)', |
| 617 | }, | 620 | }, |
| 618 | fubuki: { | 621 | fubuki: { |
| 619 | 400: 'oklch(0.82 0 0)', | 622 | dark: { |
| 620 | 500: 'oklch(0.72 0 0)', | 623 | 400: 'oklch(0.82 0 0)', |
| 621 | 600: 'oklch(0.62 0 0)', | 624 | 500: 'oklch(0.72 0 0)', |
| 622 | 700: 'oklch(0.52 0 0)', | 625 | 600: 'oklch(0.62 0 0)', |
| 623 | 800: 'oklch(0.42 0 0)', | 626 | 700: 'oklch(0.52 0 0)', |
| 627 | 800: 'oklch(0.42 0 0)', | ||
| 628 | }, | ||
| 629 | light: { | ||
| 630 | 400: 'oklch(0.58 0 0)', | ||
| 631 | 500: 'oklch(0.48 0 0)', | ||
| 632 | 600: 'oklch(0.38 0 0)', | ||
| 633 | 700: 'oklch(0.28 0 0)', | ||
| 634 | 800: 'oklch(0.18 0 0)', | ||
| 635 | }, | ||
| 624 | }, | 636 | }, |
| 625 | } | 637 | } |
| 626 | 638 | ||
| @@ -628,7 +640,10 @@ const accentColor = useStorage(AccentColorStorageKey, 'ayanami') | |||
| 628 | 640 | ||
| 629 | watchEffect(() => { | 641 | watchEffect(() => { |
| 630 | if (import.meta.env.SSR) return | 642 | if (import.meta.env.SSR) return |
| 631 | const shades = accentPalettes[accentColor.value] ?? accentPalettes.ayanami | 643 | const palette = accentPalettes[accentColor.value] ?? accentPalettes.ayanami |
| 644 | const shades = 'dark' in palette | ||
| 645 | ? (isDark.value ? palette.dark : palette.light) | ||
| 646 | : palette | ||
| 632 | const el = document.documentElement | 647 | const el = document.documentElement |
| 633 | if (isDark.value) { | 648 | if (isDark.value) { |
| 634 | el.style.setProperty('--vp-c-brand-1', shades['400']) | 649 | el.style.setProperty('--vp-c-brand-1', shades['400']) |
docs/.vitepress/theme/components/settings/AccentColor.vue +6 −2
| @@ -1,9 +1,12 @@ | |||
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { useData } from 'vitepress' | ||
| 2 | import { useStorage } from '@vueuse/core' | 3 | import { useStorage } from '@vueuse/core' |
| 3 | 4 | ||
| 4 | import { AccentColorStorageKey } from '../../constants' | 5 | import { AccentColorStorageKey } from '../../constants' |
| 5 | import MenuTitle from './MenuTitle.vue' | 6 | import MenuTitle from './MenuTitle.vue' |
| 6 | 7 | ||
| 8 | const { isDark } = useData() | ||
| 9 | |||
| 7 | const accentOptions = [ | 10 | const accentOptions = [ |
| 8 | { | 11 | { |
| 9 | key: 'ayanami', | 12 | key: 'ayanami', |
| @@ -39,8 +42,9 @@ const accentOptions = [ | |||
| 39 | key: 'fubuki', | 42 | key: 'fubuki', |
| 40 | label: 'Fubuki', | 43 | label: 'Fubuki', |
| 41 | shades: ['oklch(0.82 0 0)', 'oklch(0.72 0 0)', 'oklch(0.62 0 0)', 'oklch(0.52 0 0)', 'oklch(0.42 0 0)'], | 44 | shades: ['oklch(0.82 0 0)', 'oklch(0.72 0 0)', 'oklch(0.62 0 0)', 'oklch(0.52 0 0)', 'oklch(0.42 0 0)'], |
| 45 | lightShades: ['oklch(0.58 0 0)', 'oklch(0.48 0 0)', 'oklch(0.38 0 0)', 'oklch(0.28 0 0)', 'oklch(0.18 0 0)'], | ||
| 42 | }, | 46 | }, |
| 43 | ] as const | 47 | ] |
| 44 | 48 | ||
| 45 | const accentColor = useStorage(AccentColorStorageKey, 'ayanami') | 49 | const accentColor = useStorage(AccentColorStorageKey, 'ayanami') |
| 46 | </script> | 50 | </script> |
| @@ -65,7 +69,7 @@ const accentColor = useStorage(AccentColorStorageKey, 'ayanami') | |||
| 65 | <span class="accent-label">{{ option.label }}</span> | 69 | <span class="accent-label">{{ option.label }}</span> |
| 66 | <span class="accent-shades"> | 70 | <span class="accent-shades"> |
| 67 | <span | 71 | <span |
| 68 | v-for="(shade, i) in option.shades" | 72 | v-for="(shade, i) in ('lightShades' in option && !isDark ? option.lightShades : option.shades)" |
| 69 | :key="i" | 73 | :key="i" |
| 70 | class="accent-shade" | 74 | class="accent-shade" |
| 71 | :style="{ backgroundColor: shade }" | 75 | :style="{ backgroundColor: shade }" |