Commit 3fc55f5043

3fc55f5043a50f77edcccc35ebd50807309fd616

parent: d40536b48d

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-09 03:02 UTC

Sorting

Layout: unified · split

docs/.vitepress/theme/components/settings/AccentColor.vue +117 −13
@@ -1,6 +1,8 @@
11<script setup lang="ts">
22import { useData } from 'vitepress'
3import { NuVerticalTransition } from '@nolebase/ui'
34import { useStorage } from '@vueuse/core'
5import { computed, onMounted, onUnmounted, ref } from 'vue'
46
57import { AccentColorStorageKey } from '../../constants'
68import MenuTitle from './MenuTitle.vue'
@@ -57,44 +59,147 @@ const accentOptions = [
5759]
5860
5961const accentColor = useStorage(AccentColorStorageKey, 'ayanami')
62
63const open = ref(false)
64const rootRef = ref<HTMLDivElement>()
65
66const selectedOption = computed(
67 () => accentOptions.find((o) => o.key === accentColor.value) ?? accentOptions[0]
68)
69
70function shadesFor(option: typeof accentOptions[number]) {
71 return 'lightShades' in option && !isDark.value ? option.lightShades! : option.shades
72}
73
74function select(key: string) {
75 accentColor.value = key
76 open.value = false
77}
78
79function onDocClick(e: MouseEvent) {
80 if (rootRef.value && !rootRef.value.contains(e.target as Node)) {
81 open.value = false
82 }
83}
84
85onMounted(() => document.addEventListener('click', onDocClick, true))
86onUnmounted(() => document.removeEventListener('click', onDocClick, true))
6087</script>
6188
6289<template>
63 <div>
90 <div ref="rootRef" class="accent-color">
6491 <MenuTitle title="Accent Color" aria-label="Accent Color" mb-2>
6592 <template #icon>
6693 <span i-lucide:swatch-book mr-1 aria-hidden="true" />
6794 </template>
6895 </MenuTitle>
69 <div class="accent-list">
96
97 <div class="accent-select" :class="{ 'accent-select--open': open }">
7098 <button
71 v-for="option in accentOptions"
72 :key="option.key"
73 class="accent-btn"
74 :class="{ 'accent-btn--selected': accentColor === option.key }"
75 :aria-pressed="accentColor === option.key"
76 :aria-label="option.label"
77 @click="accentColor = option.key"
99 type="button"
100 class="accent-trigger"
101 aria-haspopup="listbox"
102 :aria-expanded="open"
103 :aria-label="`Accent Color: ${selectedOption.label}`"
104 @click="open = !open"
78105 >
79 <span class="accent-label">{{ option.label }}</span>
106 <span class="accent-label">{{ selectedOption.label }}</span>
80107 <span class="accent-shades">
81108 <span
82 v-for="(shade, i) in ('lightShades' in option && !isDark ? option.lightShades : option.shades)"
109 v-for="(shade, i) in shadesFor(selectedOption)"
83110 :key="i"
84111 class="accent-shade"
85112 :style="{ backgroundColor: shade }"
86113 />
87114 </span>
115 <span
116 class="accent-chevron i-lucide:chevron-down"
117 :class="{ 'accent-chevron--open': open }"
118 aria-hidden="true"
119 />
88120 </button>
121
122 <NuVerticalTransition :duration="200">
123 <div v-show="open" class="accent-options" role="listbox">
124 <button
125 v-for="option in accentOptions"
126 :key="option.key"
127 type="button"
128 role="option"
129 class="accent-btn"
130 :class="{ 'accent-btn--selected': accentColor === option.key }"
131 :aria-selected="accentColor === option.key"
132 :aria-label="option.label"
133 @click="select(option.key)"
134 >
135 <span class="accent-label">{{ option.label }}</span>
136 <span class="accent-shades">
137 <span
138 v-for="(shade, i) in shadesFor(option)"
139 :key="i"
140 class="accent-shade"
141 :style="{ backgroundColor: shade }"
142 />
143 </span>
144 </button>
145 </div>
146 </NuVerticalTransition>
89147 </div>
90148 </div>
91149</template>
92150
93151<style scoped>
94.accent-list {
152.accent-select {
153 position: relative;
154}
155
156.accent-trigger {
157 display: flex;
158 align-items: center;
159 gap: 8px;
160 width: 100%;
161 padding: 7px 10px;
162 border-radius: 8px;
163 border: 1px solid var(--vp-c-divider);
164 background: var(--wk-c-menu-bg);
165 color: var(--vp-c-text-1);
166 font-size: 13px;
167 cursor: pointer;
168 transition: border-color 0.15s, background-color 0.15s;
169}
170
171.accent-trigger:hover {
172 border-color: var(--vp-c-brand-1);
173}
174
175.accent-select--open .accent-trigger {
176 border-color: var(--vp-c-brand-1);
177}
178
179.accent-chevron {
180 flex-shrink: 0;
181 width: 16px;
182 height: 16px;
183 color: var(--vp-c-text-2);
184 transition: transform 0.2s ease;
185}
186
187.accent-chevron--open {
188 transform: rotate(180deg);
189}
190
191.accent-options {
192 margin-top: 6px;
193 max-height: 240px;
194 overflow-y: auto;
95195 display: flex;
96196 flex-direction: column;
97197 gap: 2px;
198 padding: 4px;
199 border-radius: 8px;
200 border: 1px solid var(--vp-c-divider);
201 background: var(--vp-c-bg-elv);
202 box-shadow: var(--vp-shadow-2);
98203}
99204
100205.accent-btn {
@@ -141,5 +246,4 @@ const accentColor = useStorage(AccentColorStorageKey, 'ayanami')
141246 width: 18px;
142247 height: 100%;
143248}
144
145249</style>
docs/.vitepress/theme/components/settings/Menu.vue +2 −2
@@ -33,9 +33,9 @@ const mounted = useMounted()
3333 <Spotlight v-if="!options.spotlight?.disabled" />
3434 <SpotlightStyles v-if="!options.spotlight?.disabled" />
3535 <Effects />
36 <Takodachi />
37 <AccentBackground />
3836 <AccentColor />
37 <AccentBackground />
38 <Takodachi />
3939 </div>
4040 </SettingsFlyout>
4141</template>
docs/.vitepress/theme/components/settings/ScreenMenu.vue +1 −1
@@ -14,8 +14,8 @@ const { theme } = useData()
1414<template>
1515 <div v-if="mounted" space-y-2 class="VPNolebaseEnhancedReadabilitiesMenu">
1616 <Effects />
17 <AccentBackground />
1817 <AccentColor />
18 <AccentBackground />
1919 <VPSocialLinks
2020 v-if="theme.socialLinks"
2121 :links="theme.socialLinks"