docs/.vitepress/theme/components/settings/ScreenAppearance.vue

78ea9fc554970c86ce26acb3978ead8147153dad
wotaku/docs/.vitepress/theme/components/settings/ScreenAppearance.vue
Duck phone layout menud9bd3e965b 5 months ago

54 lines · 1231 bytes

 1<script setup lang="ts">
 2import { NuInputHorizontalRadioGroup } from '@nolebase/ui'
 3import { useData } from 'vitepress'
 4import { computed, inject } from 'vue'
 5
 6import MenuTitle from './MenuTitle.vue'
 7
 8const { isDark } = useData()
 9const toggleAppearance = inject<() => void>('toggle-appearance', () => {
10  isDark.value = !isDark.value
11})
12
13const fieldOptions = [
14  {
15    value: 'on',
16    title: 'On',
17    ariaLabel: 'On',
18    text: 'ON',
19    name: 'Dark Mode'
20  },
21  {
22    value: 'off',
23    title: 'Off',
24    ariaLabel: 'Off',
25    text: 'OFF',
26    name: 'Dark Mode'
27  }
28]
29
30const currentMode = computed({
31  get: () => (isDark.value ? 'on' : 'off'),
32  set: (value) => {
33    if ((value === 'on') !== isDark.value) {
34      toggleAppearance()
35    }
36  }
37})
38</script>
39
40<template>
41  <div space-y-2>
42    <MenuTitle title="Dark mode" aria-label="Dark mode">
43      <template #icon>
44        <span i-icon-park-outline:dark-mode mr-1 aria-hidden="true" />
45      </template>
46    </MenuTitle>
47    <NuInputHorizontalRadioGroup
48      v-model="currentMode"
49      bg="$vp-nolebase-enhanced-readabilities-menu-background-color"
50      text="sm $vp-nolebase-enhanced-readabilities-menu-text-color"
51      :options="fieldOptions"
52    />
53  </div>
54</template>
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form