Commit d822be9529
Unsigned
Layout: unified · split
docs/.vitepress/configs/constants.ts +7
| @@ -572,6 +572,13 @@ export const siteConfig = { | |||
| 572 | appearance: true, | 572 | appearance: true, |
| 573 | titleTemplate: ':title • Wotaku.wiki by Duck', | 573 | titleTemplate: ':title • Wotaku.wiki by Duck', |
| 574 | head: [ | 574 | head: [ |
| 575 | // Apply the "Effects" preference before first paint to avoid a flash of | ||
| 576 | // effects. Effects are off by default; the class strips blur/transitions. | ||
| 577 | [ | ||
| 578 | 'script', | ||
| 579 | {}, | ||
| 580 | `(function(){try{if(localStorage.getItem('preference-effects')!=='on')document.documentElement.classList.add('effects-disabled')}catch(e){document.documentElement.classList.add('effects-disabled')}})()` | ||
| 581 | ], | ||
| 575 | ['meta', { name: 'theme-color', content: '#56b4fc' }], | 582 | ['meta', { name: 'theme-color', content: '#56b4fc' }], |
| 576 | ['meta', { name: 'og:type', content: 'website' }], | 583 | ['meta', { name: 'og:type', content: 'website' }], |
| 577 | ['meta', { name: 'og:locale', content: 'en' }], | 584 | ['meta', { name: 'og:locale', content: 'en' }], |
docs/.vitepress/theme/Layout.vue +6 −5
| @@ -34,7 +34,8 @@ import NotFoundComponent from './components/NotFound.vue' | |||
| 34 | import { NolebaseEnhancedReadabilitiesScreenMenu } from './components/settings' | 34 | import { NolebaseEnhancedReadabilitiesScreenMenu } from './components/settings' |
| 35 | import NavActions from './components/NavActions.vue' | 35 | import NavActions from './components/NavActions.vue' |
| 36 | import SidebarCard from './components/SidebarCard.vue' | 36 | import SidebarCard from './components/SidebarCard.vue' |
| 37 | import { AccentColorStorageKey, LowEndDeviceModeStorageKey, TakodachiStorageKey } from './constants' | 37 | import { AccentColorStorageKey, TakodachiStorageKey } from './constants' |
| 38 | import { useEffects } from './composables/useEffects' | ||
| 38 | import { v2add, v2mag, v2norm, v2smul, v2sub, type Vec2D } from './math' | 39 | import { v2add, v2mag, v2norm, v2smul, v2sub, type Vec2D } from './math' |
| 39 | 40 | ||
| 40 | const route = useRoute() | 41 | const route = useRoute() |
| @@ -744,15 +745,15 @@ const breadcrumbs = computed(() => { | |||
| 744 | 745 | ||
| 745 | // Respect user's reduced motion preferences | 746 | // Respect user's reduced motion preferences |
| 746 | const prefs = usePreferredReducedMotion() | 747 | const prefs = usePreferredReducedMotion() |
| 747 | const lowEndDeviceMode = useStorage(LowEndDeviceModeStorageKey, 'off') | 748 | const { effectsEnabled } = useEffects() |
| 748 | const reduceBlurEffects = computed(() => lowEndDeviceMode.value === 'on') | ||
| 749 | 749 | ||
| 750 | watchEffect(() => { | 750 | watchEffect(() => { |
| 751 | if (import.meta.env.SSR) return | 751 | if (import.meta.env.SSR) return |
| 752 | 752 | ||
| 753 | // Effects are off by default; the class strips blur/transitions/scaling. | ||
| 753 | document.documentElement.classList.toggle( | 754 | document.documentElement.classList.toggle( |
| 754 | 'reduce-blur-effects', | 755 | 'effects-disabled', |
| 755 | reduceBlurEffects.value | 756 | !effectsEnabled.value |
| 756 | ) | 757 | ) |
| 757 | }) | 758 | }) |
| 758 | 759 | ||
docs/.vitepress/theme/components/Search.vue +2 −4
| @@ -28,7 +28,6 @@ import { | |||
| 28 | useLocalStorage, | 28 | useLocalStorage, |
| 29 | useScrollLock, | 29 | useScrollLock, |
| 30 | useSessionStorage, | 30 | useSessionStorage, |
| 31 | useStorage, | ||
| 32 | watchDebounced | 31 | watchDebounced |
| 33 | } from '@vueuse/core' | 32 | } from '@vueuse/core' |
| 34 | import { useFocusTrap } from '@vueuse/integrations/useFocusTrap' | 33 | import { useFocusTrap } from '@vueuse/integrations/useFocusTrap' |
| @@ -62,7 +61,7 @@ import type { PageLink } from '../../plugins/urlSearchPlugin' | |||
| 62 | import { LRUCache } from '../composables/search/lru-cache' | 61 | import { LRUCache } from '../composables/search/lru-cache' |
| 63 | import { createSearchTranslate } from '../composables/search/translation' | 62 | import { createSearchTranslate } from '../composables/search/translation' |
| 64 | import { useData } from '../composables/search/use-data' | 63 | import { useData } from '../composables/search/use-data' |
| 65 | import { LowEndDeviceModeStorageKey } from '../constants' | 64 | import { useEffects } from '../composables/useEffects' |
| 66 | import { enhanceAppWithTabs } from './tabs' | 65 | import { enhanceAppWithTabs } from './tabs' |
| 67 | 66 | ||
| 68 | export interface FooterTranslations { | 67 | export interface FooterTranslations { |
| @@ -138,8 +137,7 @@ const filterText = disableQueryPersistence.value | |||
| 138 | ? ref('') | 137 | ? ref('') |
| 139 | : useSessionStorage('vitepress:local-search-filter', '') | 138 | : useSessionStorage('vitepress:local-search-filter', '') |
| 140 | 139 | ||
| 141 | const lowEndDeviceMode = useStorage(LowEndDeviceModeStorageKey, 'off') | 140 | const { effectsEnabled: searchAnimationsEnabled } = useEffects() |
| 142 | const searchAnimationsEnabled = computed(() => lowEndDeviceMode.value !== 'on') | ||
| 143 | const showKeyboardShortcuts = computed(() => !filterText.value) | 141 | const showKeyboardShortcuts = computed(() => !filterText.value) |
| 144 | 142 | ||
| 145 | const SearchMotionDiv = motion.div | 143 | const SearchMotionDiv = motion.div |
docs/.vitepress/theme/components/settings/BlurEffects.vue → docs/.vitepress/theme/components/settings/Effects.vue renamed +8 −15
| @@ -1,17 +1,16 @@ | |||
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { NuInputHighlight, NuInputHorizontalRadioGroup } from '@nolebase/ui' | 2 | import { NuInputHighlight, NuInputHorizontalRadioGroup } from '@nolebase/ui' |
| 3 | import { useStorage } from '@vueuse/core' | ||
| 4 | import { computed, ref } from 'vue' | 3 | import { computed, ref } from 'vue' |
| 5 | 4 | ||
| 6 | import MenuHelp from './MenuHelp.vue' | 5 | import MenuHelp from './MenuHelp.vue' |
| 7 | import MenuTitle from './MenuTitle.vue' | 6 | import MenuTitle from './MenuTitle.vue' |
| 8 | 7 | ||
| 9 | import { LowEndDeviceModeStorageKey } from '../../constants' | 8 | import { useEffects } from '../../composables/useEffects' |
| 10 | 9 | ||
| 11 | const menuTitleElementRef = ref<HTMLDivElement>() | 10 | const menuTitleElementRef = ref<HTMLDivElement>() |
| 12 | const isMenuHelpPoppedUp = ref(false) | 11 | const isMenuHelpPoppedUp = ref(false) |
| 13 | 12 | ||
| 14 | const lowEndDeviceMode = useStorage(LowEndDeviceModeStorageKey, 'off') | 13 | const { effects } = useEffects() |
| 15 | 14 | ||
| 16 | const fieldOptions = computed(() => [ | 15 | const fieldOptions = computed(() => [ |
| 17 | { | 16 | { |
| @@ -19,14 +18,14 @@ const fieldOptions = computed(() => [ | |||
| 19 | title: 'On', | 18 | title: 'On', |
| 20 | ariaLabel: 'On', | 19 | ariaLabel: 'On', |
| 21 | text: 'ON', | 20 | text: 'ON', |
| 22 | name: 'Low-End Device Mode' | 21 | name: 'Effects' |
| 23 | }, | 22 | }, |
| 24 | { | 23 | { |
| 25 | value: 'off', | 24 | value: 'off', |
| 26 | title: 'Off', | 25 | title: 'Off', |
| 27 | ariaLabel: 'Off', | 26 | ariaLabel: 'Off', |
| 28 | text: 'OFF', | 27 | text: 'OFF', |
| 29 | name: 'Low-End Device Mode' | 28 | name: 'Effects' |
| 30 | } | 29 | } |
| 31 | ]) | 30 | ]) |
| 32 | </script> | 31 | </script> |
| @@ -34,12 +33,7 @@ const fieldOptions = computed(() => [ | |||
| 34 | <template> | 33 | <template> |
| 35 | <div space-y-2 role="radiogroup"> | 34 | <div space-y-2 role="radiogroup"> |
| 36 | <div ref="menuTitleElementRef" relative flex items-center> | 35 | <div ref="menuTitleElementRef" relative flex items-center> |
| 37 | <MenuTitle | 36 | <MenuTitle title="Effects" aria-label="Effects" flex="1" pr-4> |
| 38 | title="Low-end device mode" | ||
| 39 | aria-label="Low-end device mode" | ||
| 40 | flex="1" | ||
| 41 | pr-4 | ||
| 42 | > | ||
| 43 | <template #icon> | 37 | <template #icon> |
| 44 | <span i-icon-park-outline:effects mr-1 aria-hidden="true" /> | 38 | <span i-icon-park-outline:effects mr-1 aria-hidden="true" /> |
| 45 | </template> | 39 | </template> |
| @@ -48,16 +42,15 @@ const fieldOptions = computed(() => [ | |||
| 48 | v-model:is-popped-up="isMenuHelpPoppedUp" | 42 | v-model:is-popped-up="isMenuHelpPoppedUp" |
| 49 | :menu-title-element-ref="menuTitleElementRef" | 43 | :menu-title-element-ref="menuTitleElementRef" |
| 50 | > | 44 | > |
| 51 | <h4 text-md mb-1 font-semibold>Low-end device mode</h4> | 45 | <h4 text-md mb-1 font-semibold>Effects</h4> |
| 52 | <p text="sm" mb-2 max-w-100> | 46 | <p text="sm" mb-2 max-w-100> |
| 53 | Turn on to disable expensive backdrop blur and view transitions if the | 47 | Adds backdrop blur, smooth page transitions, and scaling animations. Keep off for the best performance on slower devices. |
| 54 | site feels laggy on slower devices. | ||
| 55 | </p> | 48 | </p> |
| 56 | </MenuHelp> | 49 | </MenuHelp> |
| 57 | </div> | 50 | </div> |
| 58 | <NuInputHighlight :active="isMenuHelpPoppedUp" class="rounded-md"> | 51 | <NuInputHighlight :active="isMenuHelpPoppedUp" class="rounded-md"> |
| 59 | <NuInputHorizontalRadioGroup | 52 | <NuInputHorizontalRadioGroup |
| 60 | v-model="lowEndDeviceMode" | 53 | v-model="effects" |
| 61 | bg="$vp-nolebase-enhanced-readabilities-menu-background-color" | 54 | bg="$vp-nolebase-enhanced-readabilities-menu-background-color" |
| 62 | text="sm $vp-nolebase-enhanced-readabilities-menu-text-color" | 55 | text="sm $vp-nolebase-enhanced-readabilities-menu-text-color" |
| 63 | :options="fieldOptions" | 56 | :options="fieldOptions" |
docs/.vitepress/theme/components/settings/Menu.vue +2 −2
| @@ -4,7 +4,7 @@ import { inject } from 'vue' | |||
| 4 | 4 | ||
| 5 | import { InjectionKey } from '../../constants' | 5 | import { InjectionKey } from '../../constants' |
| 6 | import AccentColor from './AccentColor.vue' | 6 | import AccentColor from './AccentColor.vue' |
| 7 | import BlurEffects from './BlurEffects.vue' | 7 | import Effects from './Effects.vue' |
| 8 | import LayoutSwitch from './LayoutSwitch.vue' | 8 | import LayoutSwitch from './LayoutSwitch.vue' |
| 9 | import LayoutSwitchContentLayoutWidthInput from './LayoutSwitchContentLayoutMaxWidthSlider.vue' | 9 | import LayoutSwitchContentLayoutWidthInput from './LayoutSwitchContentLayoutMaxWidthSlider.vue' |
| 10 | import LayoutSwitchPageLayoutWidthInput from './LayoutSwitchPageLayoutMaxWidthSlider.vue' | 10 | import LayoutSwitchPageLayoutWidthInput from './LayoutSwitchPageLayoutMaxWidthSlider.vue' |
| @@ -31,7 +31,7 @@ const mounted = useMounted() | |||
| 31 | <LayoutSwitchContentLayoutWidthInput /> | 31 | <LayoutSwitchContentLayoutWidthInput /> |
| 32 | <Spotlight v-if="!options.spotlight?.disabled" /> | 32 | <Spotlight v-if="!options.spotlight?.disabled" /> |
| 33 | <SpotlightStyles v-if="!options.spotlight?.disabled" /> | 33 | <SpotlightStyles v-if="!options.spotlight?.disabled" /> |
| 34 | <BlurEffects /> | 34 | <Effects /> |
| 35 | <Takodachi /> | 35 | <Takodachi /> |
| 36 | <AccentColor /> | 36 | <AccentColor /> |
| 37 | </div> | 37 | </div> |
docs/.vitepress/theme/components/settings/ScreenMenu.vue +2 −2
| @@ -4,7 +4,7 @@ import { useData } from 'vitepress' | |||
| 4 | import VPSocialLinks from 'vitepress/dist/client/theme-default/components/VPSocialLinks.vue' | 4 | import VPSocialLinks from 'vitepress/dist/client/theme-default/components/VPSocialLinks.vue' |
| 5 | 5 | ||
| 6 | import AccentColor from './AccentColor.vue' | 6 | import AccentColor from './AccentColor.vue' |
| 7 | import BlurEffects from './BlurEffects.vue' | 7 | import Effects from './Effects.vue' |
| 8 | import ScreenAppearance from './ScreenAppearance.vue' | 8 | import ScreenAppearance from './ScreenAppearance.vue' |
| 9 | 9 | ||
| 10 | const mounted = useMounted() | 10 | const mounted = useMounted() |
| @@ -13,7 +13,7 @@ const { theme } = useData() | |||
| 13 | 13 | ||
| 14 | <template> | 14 | <template> |
| 15 | <div v-if="mounted" space-y-2 class="VPNolebaseEnhancedReadabilitiesMenu"> | 15 | <div v-if="mounted" space-y-2 class="VPNolebaseEnhancedReadabilitiesMenu"> |
| 16 | <BlurEffects /> | 16 | <Effects /> |
| 17 | <ScreenAppearance /> | 17 | <ScreenAppearance /> |
| 18 | <AccentColor /> | 18 | <AccentColor /> |
| 19 | <VPSocialLinks | 19 | <VPSocialLinks |
docs/.vitepress/theme/components/settings/index.ts +5 −5
| @@ -2,7 +2,7 @@ import type { Plugin } from 'vue' | |||
| 2 | 2 | ||
| 3 | import type { Options } from '../../types' | 3 | import type { Options } from '../../types' |
| 4 | 4 | ||
| 5 | import BlurEffects from './BlurEffects.vue' | 5 | import Effects from './Effects.vue' |
| 6 | import LayoutSwitch from './LayoutSwitch.vue' | 6 | import LayoutSwitch from './LayoutSwitch.vue' |
| 7 | import LayoutSwitchContentLayoutMaxWidthSlider from './LayoutSwitchContentLayoutMaxWidthSlider.vue' | 7 | import LayoutSwitchContentLayoutMaxWidthSlider from './LayoutSwitchContentLayoutMaxWidthSlider.vue' |
| 8 | import LayoutSwitchPageLayoutMaxWidthSlider from './LayoutSwitchPageLayoutMaxWidthSlider.vue' | 8 | import LayoutSwitchPageLayoutMaxWidthSlider from './LayoutSwitchPageLayoutMaxWidthSlider.vue' |
| @@ -16,8 +16,8 @@ import SpotlightStyles from './SpotlightStyles.vue' | |||
| 16 | import { | 16 | import { |
| 17 | InjectionKey, | 17 | InjectionKey, |
| 18 | LayoutMode, | 18 | LayoutMode, |
| 19 | EffectsStorageKey, | ||
| 19 | LayoutSwitchModeStorageKey, | 20 | LayoutSwitchModeStorageKey, |
| 20 | LowEndDeviceModeStorageKey, | ||
| 21 | SpotlightStyle, | 21 | SpotlightStyle, |
| 22 | SpotlightToggledStorageKey | 22 | SpotlightToggledStorageKey |
| 23 | } from '../../constants' | 23 | } from '../../constants' |
| @@ -25,14 +25,14 @@ import { | |||
| 25 | export type { Options } | 25 | export type { Options } |
| 26 | 26 | ||
| 27 | export { | 27 | export { |
| 28 | BlurEffects, | 28 | Effects, |
| 29 | EffectsStorageKey, | ||
| 29 | InjectionKey, | 30 | InjectionKey, |
| 30 | LayoutMode, | 31 | LayoutMode, |
| 31 | LayoutSwitch, | 32 | LayoutSwitch, |
| 32 | LayoutSwitchContentLayoutMaxWidthSlider, | 33 | LayoutSwitchContentLayoutMaxWidthSlider, |
| 33 | LayoutSwitchModeStorageKey, | 34 | LayoutSwitchModeStorageKey, |
| 34 | LayoutSwitchPageLayoutMaxWidthSlider, | 35 | LayoutSwitchPageLayoutMaxWidthSlider, |
| 35 | LowEndDeviceModeStorageKey, | ||
| 36 | NolebaseEnhancedReadabilitiesMenu, | 36 | NolebaseEnhancedReadabilitiesMenu, |
| 37 | NolebaseEnhancedReadabilitiesScreenMenu, | 37 | NolebaseEnhancedReadabilitiesScreenMenu, |
| 38 | ScreenLayoutSwitch, | 38 | ScreenLayoutSwitch, |
| @@ -44,7 +44,7 @@ export { | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | const components = { | 46 | const components = { |
| 47 | NolebaseEnhancedReadabilitiesBlurEffects: BlurEffects, | 47 | NolebaseEnhancedReadabilitiesEffects: Effects, |
| 48 | NolebaseEnhancedReadabilitiesMenu, | 48 | NolebaseEnhancedReadabilitiesMenu, |
| 49 | NolebaseEnhancedReadabilitiesScreenMenu, | 49 | NolebaseEnhancedReadabilitiesScreenMenu, |
| 50 | NolebaseEnhancedReadabilitiesLayoutSwitch: LayoutSwitch, | 50 | NolebaseEnhancedReadabilitiesLayoutSwitch: LayoutSwitch, |
docs/.vitepress/theme/composables/useEffects.ts added +11
| @@ -0,0 +1,11 @@ | |||
| 1 | import { useStorage } from '@vueuse/core' | ||
| 2 | import { computed } from 'vue' | ||
| 3 | |||
| 4 | import { EffectsStorageKey } from '../constants' | ||
| 5 | |||
| 6 | export function useEffects() { | ||
| 7 | const effects = useStorage(EffectsStorageKey, 'off') | ||
| 8 | const effectsEnabled = computed(() => effects.value === 'on') | ||
| 9 | |||
| 10 | return { effects, effectsEnabled } | ||
| 11 | } | ||
docs/.vitepress/theme/constants.ts +1 −1
| @@ -26,7 +26,7 @@ export const SpotlightToggledStorageKey = | |||
| 26 | export const SpotlightStylesStorageKey = | 26 | export const SpotlightStylesStorageKey = |
| 27 | 'vitepress-nolebase-enhanced-readabilities-spotlight-styles' | 27 | 'vitepress-nolebase-enhanced-readabilities-spotlight-styles' |
| 28 | 28 | ||
| 29 | export const LowEndDeviceModeStorageKey = 'preference-low-end-device-mode' | 29 | export const EffectsStorageKey = 'preference-effects' |
| 30 | export const TakodachiStorageKey = 'preference-takodachi' | 30 | export const TakodachiStorageKey = 'preference-takodachi' |
| 31 | export const AccentColorStorageKey = 'preference-accent-color' | 31 | export const AccentColorStorageKey = 'preference-accent-color' |
| 32 | 32 | ||
docs/.vitepress/theme/styles/style.scss +18 −2
| @@ -1553,7 +1553,9 @@ table tr:nth-child(odd) { | |||
| 1553 | } | 1553 | } |
| 1554 | } | 1554 | } |
| 1555 | 1555 | ||
| 1556 | html.reduce-blur-effects { | 1556 | // Applied to <html> when the "Effects" preference is off (the default). |
| 1557 | // Strips backdrop blur, view/page transitions and scaling bounces. | ||
| 1558 | html.effects-disabled { | ||
| 1557 | &::view-transition-group(root), | 1559 | &::view-transition-group(root), |
| 1558 | &::view-transition-new(root), | 1560 | &::view-transition-new(root), |
| 1559 | &::view-transition-old(root) { | 1561 | &::view-transition-old(root) { |
| @@ -1626,10 +1628,24 @@ html.reduce-blur-effects { | |||
| 1626 | .VPSidebarItem.is-link:not(.collapsible), | 1628 | .VPSidebarItem.is-link:not(.collapsible), |
| 1627 | .VPSidebarItem.is-link.collapsible > .item, | 1629 | .VPSidebarItem.is-link.collapsible > .item, |
| 1628 | // Search button hover/active scale bounce | 1630 | // Search button hover/active scale bounce |
| 1629 | #local-search > .DocSearch-Button { | 1631 | #local-search > .DocSearch-Button, |
| 1632 | // Appearance (dark/light) toggle hover/active scale bounce | ||
| 1633 | .VPSwitchAppearance { | ||
| 1630 | scale: none !important; | 1634 | scale: none !important; |
| 1631 | transition: none !important; | 1635 | transition: none !important; |
| 1632 | } | 1636 | } |
| 1637 | |||
| 1638 | // Nav-pill button + dropdown panel active/open scale bounces | ||
| 1639 | .nav-action-btn:active, | ||
| 1640 | .nav-actions .VPSocialLink:active, | ||
| 1641 | .VPNolebaseEnhancedReadabilitiesMenuFlyout .button:active, | ||
| 1642 | .bookmarks-btn:active, | ||
| 1643 | .bookmarks-panel-enter-from, | ||
| 1644 | .bookmarks-panel-leave-to, | ||
| 1645 | .settings-popup-enter-from, | ||
| 1646 | .settings-popup-leave-to { | ||
| 1647 | transform: none !important; | ||
| 1648 | } | ||
| 1633 | } | 1649 | } |
| 1634 | 1650 | ||
| 1635 | /* Icon tooltips (hover on desktop, tap on mobile) */ | 1651 | /* Icon tooltips (hover on desktop, tap on mobile) */ |