Commit 9dcbd7c5a9

9dcbd7c5a9b0e6dd329de0f12fa06a6a9593879b

parent: 4b5845f6a4

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-07 16:27 UTC

init

Layout: unified · split

docs/.vitepress/theme/Layout.vue +79 −4
@@ -9,7 +9,8 @@
99import {
1010 customStorageEventName,
1111 useEventListener,
12 useStorage
12 useStorage,
13 useThrottleFn
1314} from '@vueuse/core'
1415import { usePreferredReducedMotion } from '@vueuse/core'
1516import { useData, useRoute } from 'vitepress'
@@ -34,7 +35,7 @@ import NotFoundComponent from './components/NotFound.vue'
3435import { NolebaseEnhancedReadabilitiesScreenMenu } from './components/settings'
3536import NavActions from './components/NavActions.vue'
3637import SidebarCard from './components/SidebarCard.vue'
37import { AccentColorStorageKey, TakodachiStorageKey } from './constants'
38import { AccentBgStorageKey, AccentBgStrengthStorageKey, AccentColorStorageKey, TakodachiStorageKey } from './constants'
3839import { useEffects } from './composables/useEffects'
3940import { v2add, v2mag, v2norm, v2smul, v2sub, type Vec2D } from './math'
4041
@@ -836,8 +837,52 @@ const accentPalettes: Record<string, PaletteEntry> = {
836837}
837838
838839const accentColor = useStorage(AccentColorStorageKey, 'ayanami')
840const accentBg = useStorage(AccentBgStorageKey, false)
841const accentBgStrength = useStorage(AccentBgStrengthStorageKey, 60)
842
843// Accent-tinted replacements for the neutral tokens in style.scss.
844// Lightness matches the original hex values, so contrast is unchanged.
845// Entries are [lightness, chroma] or [lightness, chroma, alpha].
846type TintEntry = [number, number] | [number, number, number]
847const accentBgTokens: Record<'dark' | 'light', Record<string, TintEntry>> = {
848 dark: {
849 '--vp-c-bg': [0.187, 0.024],
850 '--vp-c-bg-alt': [0.164, 0.022],
851 '--vp-c-bg-elv': [0.224, 0.028],
852 '--vp-c-bg-soft': [0.224, 0.028],
853 '--vp-c-divider': [0.26, 0.032],
854 '--vp-c-border': [0.57, 0.02],
855 '--vp-c-text-1': [0.915, 0.012],
856 '--vp-c-text-2': [0.742, 0.012],
857 '--vp-c-text-3': [0.655, 0.012],
858 '--wk-c-menu-bg': [0.295, 0.032],
859 '--wk-c-nav-solid-bg': [0.2, 0.024],
860 '--nav-pill-bg': [0.205, 0.024, 0.7],
861 '--wk-fs-header-divider': [0.44, 0.02, 0.65],
862 },
863 light: {
864 '--vp-c-bg': [0.986, 0.012],
865 '--vp-c-bg-alt': [0.958, 0.024],
866 '--vp-c-bg-elv': [0.958, 0.024],
867 '--vp-c-bg-soft': [0.958, 0.024],
868 '--vp-c-divider': [0.828, 0.036],
869 '--vp-c-border': [0.815, 0.024],
870 '--vp-c-gutter': [0.913, 0.02],
871 '--vp-c-text-1': [0.224, 0.016],
872 '--vp-c-text-2': [0.309, 0.014],
873 '--vp-c-text-3': [0.396, 0.014],
874 '--wk-c-menu-bg': [0.928, 0.026],
875 '--wk-c-nav-solid-bg': [0.986, 0.012],
876 '--nav-pill-bg': [0.99, 0.01, 0.8],
877 '--wk-fs-header-divider': [0.715, 0.02, 0.25],
878 },
879}
880const accentBgTokenKeys = [...new Set([
881 ...Object.keys(accentBgTokens.dark),
882 ...Object.keys(accentBgTokens.light),
883])]
839884
840watchEffect(() => {
885const applyAccentTheme = () => {
841886 if (import.meta.env.SSR) return
842887 const palette = accentPalettes[accentColor.value] ?? accentPalettes.ayanami
843888 const shades = 'dark' in palette
@@ -857,7 +902,37 @@ watchEffect(() => {
857902 el.style.setProperty('--vp-c-brand-soft', `color-mix(in srgb, ${shades['400']} 40%, transparent)`)
858903 el.style.setProperty('--vp-c-sidebar-active', `color-mix(in srgb, ${shades['800']} 15%, transparent)`)
859904 }
860})
905
906 for (const key of accentBgTokenKeys) el.style.removeProperty(key)
907 const userStrength = accentBg.value
908 ? Math.min(100, Math.max(0, Number(accentBgStrength.value) || 0)) / 100
909 : 0
910 if (userStrength > 0) {
911 const parsed = shades['500'].match(/oklch\(\s*[\d.]+\s+([\d.]+)\s+([\d.]+)/)
912 if (parsed) {
913 // Tint scales with the accent's own chroma (full tint at C >= 0.10,
914 // grayscale accents stay gray), then with the intensity preset.
915 const strength = Math.min(1, Number(parsed[1]) / 0.10) * userStrength * 1.5
916 const hue = parsed[2]
917 const tokens = accentBgTokens[isDark.value ? 'dark' : 'light']
918 for (const [key, [l, c, alpha]] of Object.entries(tokens)) {
919 const chroma = (c * strength).toFixed(4)
920 const suffix = alpha === undefined ? '' : ` / ${alpha}`
921 el.style.setProperty(key, `oklch(${l} ${chroma} ${hue}${suffix})`)
922 }
923 }
924 }
925}
926
927// Applying the tint restyles the whole page, so throttle rapid changes
928// (leading + trailing: single clicks apply instantly, the last value sticks).
929const applyAccentThemeThrottled = useThrottleFn(applyAccentTheme, 100, true)
930
931watch(
932 [accentColor, isDark, accentBg, accentBgStrength],
933 () => applyAccentThemeThrottled(),
934 { immediate: true }
935)
861936
862937const speed = 2
863938const snapThreshold = 5 // px
docs/.vitepress/theme/components/HomeFeatures.vue +4 −4
@@ -1242,13 +1242,13 @@ html.effects-disabled .row-toggle:active {
12421242 display: flex;
12431243 flex-direction: column;
12441244 gap: 4px;
1245 background: #e8e6ec;
1245 background: var(--wk-c-menu-bg);
12461246 border-radius: 12px;
12471247 padding: 10px 12px;
12481248}
12491249
12501250.dark .sh-option {
1251 background: #2c2c31;
1251 background: var(--wk-c-menu-bg);
12521252}
12531253
12541254.sh-option strong {
@@ -1284,7 +1284,7 @@ html.effects-disabled .row-toggle:active {
12841284}
12851285
12861286.settings-dropdown {
1287 --seg-track: #e8e6ec;
1287 --seg-track: var(--wk-c-menu-bg);
12881288 --seg-pill-bg: var(--vp-c-bg);
12891289 --seg-pill-text: var(--vp-c-text-1);
12901290 --seg-pill-shadow: 0 2px 4px 0 #bababa8c;
@@ -1301,7 +1301,7 @@ html.effects-disabled .row-toggle:active {
13011301}
13021302
13031303.dark .settings-dropdown {
1304 --seg-track: #2c2c31;
1304 --seg-track: var(--wk-c-menu-bg);
13051305 --seg-pill-bg: var(--vp-c-text-1);
13061306 --seg-pill-text: var(--vp-c-bg-elv);
13071307 --seg-pill-shadow: 0 2px 4px 0 #535353db;
docs/.vitepress/theme/components/Search.vue +4 −4
@@ -3614,7 +3614,7 @@ html.effects-disabled .clear-button:active {
36143614
36153615/* Settings popup card */
36163616.search-settings-popup {
3617 --seg-track: #e8e6ec;
3617 --seg-track: var(--wk-c-menu-bg);
36183618 --seg-pill-bg: var(--vp-c-bg);
36193619 --seg-pill-text: var(--vp-c-text-1);
36203620 --seg-pill-shadow: 0 2px 4px 0 #bababa8c;
@@ -3631,7 +3631,7 @@ html.effects-disabled .clear-button:active {
36313631}
36323632
36333633.dark .search-settings-popup {
3634 --seg-track: #2c2c31;
3634 --seg-track: var(--wk-c-menu-bg);
36353635 --seg-pill-bg: var(--vp-c-text-1);
36363636 --seg-pill-text: var(--vp-c-bg-elv);
36373637 --seg-pill-shadow: 0 2px 4px 0 #535353db;
@@ -3749,13 +3749,13 @@ html.effects-disabled .clear-button:active {
37493749 display: flex;
37503750 flex-direction: column;
37513751 gap: 4px;
3752 background: #e8e6ec;
3752 background: var(--wk-c-menu-bg);
37533753 border-radius: 12px;
37543754 padding: 10px 12px;
37553755}
37563756
37573757.dark .sh-option {
3758 background: #2c2c31;
3758 background: var(--wk-c-menu-bg);
37593759}
37603760
37613761.sh-option strong {
docs/.vitepress/theme/components/settings/AccentBackground.vue added +127
@@ -0,0 +1,127 @@
1<script setup lang="ts">
2import {
3 NuInputHighlight,
4 NuInputHorizontalRadioGroup,
5 NuVerticalTransition
6} from '@nolebase/ui'
7import { useStorage } from '@vueuse/core'
8import { computed, ref } from 'vue'
9
10import MenuHelp from './MenuHelp.vue'
11import MenuTitle from './MenuTitle.vue'
12
13import { AccentBgStorageKey, AccentBgStrengthStorageKey } from '../../constants'
14
15const menuTitleElementRef = ref<HTMLDivElement>()
16const isMenuHelpPoppedUp = ref(false)
17const intensityTitleElementRef = ref<HTMLDivElement>()
18const isIntensityHelpPoppedUp = ref(false)
19
20const accentBg = useStorage(AccentBgStorageKey, false)
21const strengthStorageValue = useStorage(AccentBgStrengthStorageKey, 60)
22
23const strengthValue = computed({
24 get: () => {
25 const parsed = Number.parseInt(String(strengthStorageValue.value))
26 if (Number.isNaN(parsed)) return 60
27 // Snap stored values to the nearest preset.
28 return Math.round(Math.min(100, Math.max(20, parsed)) / 20) * 20
29 },
30 set: (val) => {
31 strengthStorageValue.value = val
32 }
33})
34
35const fieldOptions = computed(() => [
36 {
37 value: true,
38 title: 'On',
39 ariaLabel: 'On',
40 text: 'ON',
41 name: 'Accent Background Toggle Switch'
42 },
43 {
44 value: false,
45 title: 'Off',
46 ariaLabel: 'Off',
47 text: 'OFF',
48 name: 'Accent Background Toggle Switch'
49 }
50])
51
52const strengthOptions = computed(() =>
53 [20, 40, 60, 80, 100].map((v) => ({
54 value: v,
55 title: `${v}%`,
56 ariaLabel: `${v}%`,
57 text: `${v}`,
58 name: 'Accent Background Strength'
59 }))
60)
61</script>
62
63<template>
64 <div space-y-2 select-none role="radiogroup">
65 <div ref="menuTitleElementRef" relative flex items-center>
66 <MenuTitle
67 title="Accent Background"
68 aria-label="Accent Background"
69 flex="1"
70 pr-4
71 >
72 <template #icon>
73 <span i-lucide:paint-roller mr-1 aria-hidden="true" />
74 </template>
75 </MenuTitle>
76 <MenuHelp
77 v-model:is-popped-up="isMenuHelpPoppedUp"
78 :menu-title-element-ref="menuTitleElementRef"
79 >
80 <h4 text-md mb-1 font-semibold>Accent Background</h4>
81 <p text="sm" mb-2 max-w-100>
82 Tints backgrounds, surfaces, and text with your accent color.
83 </p>
84 </MenuHelp>
85 </div>
86 <NuInputHighlight :active="isMenuHelpPoppedUp" class="rounded-md">
87 <NuInputHorizontalRadioGroup
88 v-model="accentBg"
89 bg="$vp-nolebase-enhanced-readabilities-menu-background-color"
90 text="sm $vp-nolebase-enhanced-readabilities-menu-text-color"
91 :options="fieldOptions"
92 />
93 </NuInputHighlight>
94 <NuVerticalTransition :duration="200">
95 <div v-show="accentBg" space-y-2 role="radiogroup">
96 <div ref="intensityTitleElementRef" relative flex items-center>
97 <MenuTitle title="Intensity" aria-label="Intensity" flex="1" pr-4>
98 <template #icon>
99 <span
100 i-lucide:chart-no-axes-column-increasing
101 mr-1
102 aria-hidden="true"
103 />
104 </template>
105 </MenuTitle>
106 <MenuHelp
107 v-model:is-popped-up="isIntensityHelpPoppedUp"
108 :menu-title-element-ref="intensityTitleElementRef"
109 >
110 <h4 text-md mb-1 font-semibold>Intensity</h4>
111 <p text="sm" mb-2 max-w-100>
112 How strongly the accent color tints the background.
113 </p>
114 </MenuHelp>
115 </div>
116 <NuInputHighlight :active="isIntensityHelpPoppedUp" class="rounded-md">
117 <NuInputHorizontalRadioGroup
118 v-model="strengthValue"
119 bg="$vp-nolebase-enhanced-readabilities-menu-background-color"
120 text="sm $vp-nolebase-enhanced-readabilities-menu-text-color"
121 :options="strengthOptions"
122 />
123 </NuInputHighlight>
124 </div>
125 </NuVerticalTransition>
126 </div>
127</template>
docs/.vitepress/theme/components/settings/Menu.vue +4 −2
@@ -3,6 +3,7 @@ import { useMounted } from '@vueuse/core'
33import { inject } from 'vue'
44
55import { InjectionKey } from '../../constants'
6import AccentBackground from './AccentBackground.vue'
67import AccentColor from './AccentColor.vue'
78import Effects from './Effects.vue'
89import LayoutSwitch from './LayoutSwitch.vue'
@@ -33,6 +34,7 @@ const mounted = useMounted()
3334 <SpotlightStyles v-if="!options.spotlight?.disabled" />
3435 <Effects />
3536 <Takodachi />
37 <AccentBackground />
3638 <AccentColor />
3739 </div>
3840 </SettingsFlyout>
@@ -40,12 +42,12 @@ const mounted = useMounted()
4042
4143<style>
4244.VPNolebaseEnhancedReadabilitiesMenu {
43 --vp-nolebase-enhanced-readabilities-menu-background-color: #e8e6ec;
45 --vp-nolebase-enhanced-readabilities-menu-background-color: var(--wk-c-menu-bg);
4446 --vp-nolebase-enhanced-readabilities-menu-text-color: var(--vp-c-text-1);
4547}
4648
4749.dark .VPNolebaseEnhancedReadabilitiesMenu {
48 --vp-nolebase-enhanced-readabilities-menu-background-color: #2c2c31;
50 --vp-nolebase-enhanced-readabilities-menu-background-color: var(--wk-c-menu-bg);
4951 --vp-nolebase-enhanced-readabilities-menu-text-color: var(--vp-c-text-1);
5052}
5153
docs/.vitepress/theme/components/settings/ScreenMenu.vue +4 −2
@@ -3,6 +3,7 @@ import { useMounted } from '@vueuse/core'
33import { useData } from 'vitepress'
44import VPSocialLinks from 'vitepress/dist/client/theme-default/components/VPSocialLinks.vue'
55
6import AccentBackground from './AccentBackground.vue'
67import AccentColor from './AccentColor.vue'
78import Effects from './Effects.vue'
89
@@ -13,6 +14,7 @@ const { theme } = useData()
1314<template>
1415 <div v-if="mounted" space-y-2 class="VPNolebaseEnhancedReadabilitiesMenu">
1516 <Effects />
17 <AccentBackground />
1618 <AccentColor />
1719 <VPSocialLinks
1820 v-if="theme.socialLinks"
@@ -24,12 +26,12 @@ const { theme } = useData()
2426
2527<style>
2628.VPNolebaseEnhancedReadabilitiesMenu {
27 --vp-nolebase-enhanced-readabilities-menu-background-color: #e8e6ec;
29 --vp-nolebase-enhanced-readabilities-menu-background-color: var(--wk-c-menu-bg);
2830 --vp-nolebase-enhanced-readabilities-menu-text-color: var(--vp-c-text-1);
2931}
3032
3133.dark .VPNolebaseEnhancedReadabilitiesMenu {
32 --vp-nolebase-enhanced-readabilities-menu-background-color: #2c2c31;
34 --vp-nolebase-enhanced-readabilities-menu-background-color: var(--wk-c-menu-bg);
3335 --vp-nolebase-enhanced-readabilities-menu-text-color: var(--vp-c-text-1);
3436}
3537</style>
docs/.vitepress/theme/constants.ts +3
@@ -29,6 +29,9 @@ export const SpotlightStylesStorageKey =
2929export const EffectsStorageKey = 'preference-effects'
3030export const TakodachiStorageKey = 'preference-takodachi'
3131export const AccentColorStorageKey = 'preference-accent-color'
32export const AccentBgStorageKey = 'preference-accent-bg'
33/** Accent background tint strength, 0–100. */
34export const AccentBgStrengthStorageKey = 'preference-accent-bg-strength'
3235
3336export enum LayoutMode {
3437 FullWidth = 1,
docs/.vitepress/theme/styles/style.scss +21 −1
@@ -22,6 +22,10 @@ $ease-in-expo: cubic-bezier(0.7, 0, 0.84, 0);
2222 --vp-c-text-3: #46464a;
2323 /* Divider under the mobile full-screen header bars. */
2424 --wk-fs-header-divider: rgba(163, 163, 163, 0.25);
25 /* Flat menu/option surfaces (settings menu, search help cards). */
26 --wk-c-menu-bg: #e8e6ec;
27 /* Solid nav-pill segment background when effects (blur) are off. */
28 --wk-c-nav-solid-bg: var(--vp-c-bg);
2529}
2630
2731.dark {
@@ -36,6 +40,8 @@ $ease-in-expo: cubic-bezier(0.7, 0, 0.84, 0);
3640 --vp-c-text-2: #ababaf;
3741 --vp-c-text-3: #919094;
3842 --wk-fs-header-divider: rgba(82, 82, 82, 0.65);
43 --wk-c-menu-bg: #2c2c31;
44 --wk-c-nav-solid-bg: #151617;
3945}
4046
4147:root {
@@ -125,6 +131,20 @@ $ease-in-expo: cubic-bezier(0.7, 0, 0.84, 0);
125131 --nav-pill-border: rgb(212 212 212 / 0.1);
126132}
127133
134/* Nolebase sliders hardcode #fff / #e1e2da for the thumb and progress fill;
135 use theme tokens (like the radio pills) so they follow the theme. */
136.nolebase-ui-slider {
137 --nolebase-ui-slider-thumb-color: var(--vp-c-bg);
138 --nolebase-ui-slider-track-color: var(--vp-c-bg);
139 --nolebase-ui-slider-track-progress-color: var(--vp-c-bg);
140}
141
142.dark .nolebase-ui-slider {
143 --nolebase-ui-slider-thumb-color: var(--vp-c-text-1);
144 --nolebase-ui-slider-track-color: var(--vp-c-text-1);
145 --nolebase-ui-slider-track-progress-color: var(--vp-c-text-1);
146}
147
128148.dark {
129149 /* Colors: Brand */
130150 --vp-c-brand-1: theme("colors.brand.400");
@@ -1626,7 +1646,7 @@ html.effects-disabled {
16261646 .VPSocialLinks.VPNavBarSocialLinks.social-links,
16271647 .nav-actions,
16281648 .VPNolebaseEnhancedReadabilitiesMenuFlyout {
1629 background-color: #151617 !important;
1649 background-color: var(--wk-c-nav-solid-bg) !important;
16301650 }
16311651 }
16321652