Commit d412924605
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/settings/AccentColor.vue +32 −9
| @@ -1,10 +1,11 @@ | ||
| 1 | 1 | <script setup lang="ts"> |
| 2 | 2 | import { useData } from 'vitepress' |
| 3 | import { NuVerticalTransition } from '@nolebase/ui' | |
| 3 | import { NuInputHighlight, NuVerticalTransition } from '@nolebase/ui' | |
| 4 | 4 | import { useStorage } from '@vueuse/core' |
| 5 | 5 | import { computed, onMounted, onUnmounted, ref } from 'vue' |
| 6 | 6 | |
| 7 | 7 | import { AccentColorStorageKey } from '../../constants' |
| 8 | import MenuHelp from './MenuHelp.vue' | |
| 8 | 9 | import MenuTitle from './MenuTitle.vue' |
| 9 | 10 | |
| 10 | 11 | const { isDark } = useData() |
| @@ -62,6 +63,8 @@ const accentColor = useStorage(AccentColorStorageKey, 'ayanami') | ||
| 62 | 63 | |
| 63 | 64 | const open = ref(false) |
| 64 | 65 | const rootRef = ref<HTMLDivElement>() |
| 66 | const menuTitleElementRef = ref<HTMLDivElement>() | |
| 67 | const isMenuHelpPoppedUp = ref(false) | |
| 65 | 68 | |
| 66 | 69 | const selectedOption = computed( |
| 67 | 70 | () => accentOptions.find((o) => o.key === accentColor.value) ?? accentOptions[0] |
| @@ -88,13 +91,26 @@ onUnmounted(() => document.removeEventListener('click', onDocClick, true)) | ||
| 88 | 91 | |
| 89 | 92 | <template> |
| 90 | 93 | <div ref="rootRef" class="accent-color"> |
| 91 | <MenuTitle title="Accent Color" aria-label="Accent Color" mb-2> | |
| 92 | <template #icon> | |
| 93 | <span i-lucide:swatch-book mr-1 aria-hidden="true" /> | |
| 94 | </template> | |
| 95 | </MenuTitle> | |
| 94 | <div ref="menuTitleElementRef" relative flex items-center mb-2> | |
| 95 | <MenuTitle title="Accent Color" aria-label="Accent Color" flex="1" pr-4> | |
| 96 | <template #icon> | |
| 97 | <span i-lucide:swatch-book mr-1 aria-hidden="true" /> | |
| 98 | </template> | |
| 99 | </MenuTitle> | |
| 100 | <MenuHelp | |
| 101 | v-model:is-popped-up="isMenuHelpPoppedUp" | |
| 102 | :menu-title-element-ref="menuTitleElementRef" | |
| 103 | > | |
| 104 | <h4 text-md mb-1 font-semibold>Accent Color</h4> | |
| 105 | <p text="sm" mb-2 max-w-100> | |
| 106 | Sets the accent color used for links, buttons, and highlights across | |
| 107 | the site. | |
| 108 | </p> | |
| 109 | </MenuHelp> | |
| 110 | </div> | |
| 96 | 111 | |
| 97 | <div class="accent-select" :class="{ 'accent-select--open': open }"> | |
| 112 | <NuInputHighlight :active="isMenuHelpPoppedUp" class="rounded-md"> | |
| 113 | <div class="accent-select" :class="{ 'accent-select--open': open }"> | |
| 98 | 114 | <button |
| 99 | 115 | type="button" |
| 100 | 116 | class="accent-trigger" |
| @@ -144,7 +160,8 @@ onUnmounted(() => document.removeEventListener('click', onDocClick, true)) | ||
| 144 | 160 | </button> |
| 145 | 161 | </div> |
| 146 | 162 | </NuVerticalTransition> |
| 147 | </div> | |
| 163 | </div> | |
| 164 | </NuInputHighlight> | |
| 148 | 165 | </div> |
| 149 | 166 | </template> |
| 150 | 167 | |
| @@ -158,9 +175,10 @@ onUnmounted(() => document.removeEventListener('click', onDocClick, true)) | ||
| 158 | 175 | align-items: center; |
| 159 | 176 | gap: 8px; |
| 160 | 177 | width: 100%; |
| 178 | min-height: 44px; | |
| 161 | 179 | padding: 7px 10px; |
| 162 | 180 | border-radius: 8px; |
| 163 | border: 1px solid var(--vp-c-divider); | |
| 181 | border: 2px solid var(--vp-c-divider); | |
| 164 | 182 | background: var(--wk-c-menu-bg); |
| 165 | 183 | color: var(--vp-c-text-1); |
| 166 | 184 | font-size: 13px; |
| @@ -192,6 +210,7 @@ onUnmounted(() => document.removeEventListener('click', onDocClick, true)) | ||
| 192 | 210 | margin-top: 6px; |
| 193 | 211 | max-height: 240px; |
| 194 | 212 | overflow-y: auto; |
| 213 | overscroll-behavior: contain; | |
| 195 | 214 | display: flex; |
| 196 | 215 | flex-direction: column; |
| 197 | 216 | gap: 2px; |
| @@ -225,6 +244,10 @@ onUnmounted(() => document.removeEventListener('click', onDocClick, true)) | ||
| 225 | 244 | background-color: var(--vp-c-brand-soft); |
| 226 | 245 | } |
| 227 | 246 | |
| 247 | .accent-btn--selected .accent-label { | |
| 248 | font-weight: 600; | |
| 249 | } | |
| 250 | ||
| 228 | 251 | .accent-btn--selected:hover { |
| 229 | 252 | background-color: var(--vp-c-brand-soft); |
| 230 | 253 | } |