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