feat(docs): align documentation shell with HeroUI baseline
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
import { useColorMode } from "@vueuse/core";
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
ToggleButtonGroup,
|
||||
ToggleButton,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconSun, IconMoon, IconDeviceDesktop } from "@tabler/icons-vue";
|
||||
const mode = useColorMode({
|
||||
storageKey: "vitepress-theme-appearance",
|
||||
emitAuto: true,
|
||||
});
|
||||
const choices = [
|
||||
{ id: "light", label: "浅色主题", icon: IconSun },
|
||||
{ id: "dark", label: "深色主题", icon: IconMoon },
|
||||
{ id: "auto", label: "跟随系统", icon: IconDeviceDesktop },
|
||||
] as const;
|
||||
function setTheme(value: unknown) {
|
||||
if (value === "light" || value === "dark" || value === "auto")
|
||||
mode.value = value;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<ToggleButtonGroup
|
||||
class="docs-theme-wide"
|
||||
:model-value="mode"
|
||||
selection-mode="single"
|
||||
disallow-empty-selection
|
||||
aria-label="外观"
|
||||
size="sm"
|
||||
@update:model-value="setTheme"
|
||||
>
|
||||
<ToggleButton
|
||||
v-for="choice in choices"
|
||||
:id="choice.id"
|
||||
:key="choice.id"
|
||||
is-icon-only
|
||||
:aria-label="choice.label"
|
||||
>
|
||||
<component :is="choice.icon" aria-hidden="true" :size="15" />
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
class="docs-theme-compact"
|
||||
variant="ghost"
|
||||
is-icon-only
|
||||
size="sm"
|
||||
aria-label="选择外观"
|
||||
>
|
||||
<IconSun v-if="mode === 'light'" :size="18" />
|
||||
<IconMoon v-else-if="mode === 'dark'" :size="18" />
|
||||
<IconDeviceDesktop v-else :size="18" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent placement="bottom end">
|
||||
<PopoverDialog>
|
||||
<PopoverHeading class="sr-only">外观</PopoverHeading>
|
||||
<ToggleButtonGroup
|
||||
:model-value="mode"
|
||||
selection-mode="single"
|
||||
disallow-empty-selection
|
||||
aria-label="外观"
|
||||
size="sm"
|
||||
@update:model-value="setTheme"
|
||||
>
|
||||
<ToggleButton
|
||||
v-for="choice in choices"
|
||||
:id="choice.id"
|
||||
:key="choice.id"
|
||||
is-icon-only
|
||||
:aria-label="choice.label"
|
||||
>
|
||||
<component :is="choice.icon" aria-hidden="true" :size="16" />
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
Reference in New Issue
Block a user