feat(docs): align documentation shell with HeroUI baseline
This commit is contained in:
@@ -1,16 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { IconCode, IconCopy } from "@tabler/icons-vue";
|
||||
import { computed, ref, watch, onBeforeUnmount, useId } from "vue";
|
||||
import { IconCode, IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
useId,
|
||||
defineAsyncComponent,
|
||||
} from "vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import { highlights } from "virtual:docs-data";
|
||||
const props = defineProps<{
|
||||
name: string;
|
||||
align?: "center" | "start" | "end";
|
||||
isBgSolid?: boolean;
|
||||
hideCode?: boolean;
|
||||
minHeight?: string;
|
||||
description?: string;
|
||||
}>();
|
||||
const demos = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
});
|
||||
const loaders = import.meta.glob("../../demos/*.vue", { import: "default" });
|
||||
const demos = Object.fromEntries(
|
||||
Object.entries(loaders).map(([name, loader]) => [
|
||||
name,
|
||||
defineAsyncComponent(loader as () => Promise<import("vue").Component>),
|
||||
]),
|
||||
);
|
||||
const sources = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
query: "?raw",
|
||||
@@ -24,20 +39,44 @@ const expanded = ref(false),
|
||||
copyStatus = ref("复制代码");
|
||||
const id = useId();
|
||||
const highlightedCode = ref("");
|
||||
watch([expanded, () => props.name], async ([open, name], _, onCleanup) => {
|
||||
let current = true;
|
||||
onCleanup(() => {
|
||||
current = false;
|
||||
});
|
||||
highlightedCode.value = "";
|
||||
if (open) {
|
||||
try {
|
||||
const result = await highlights[name]?.();
|
||||
if (current) highlightedCode.value = result?.default ?? "";
|
||||
} catch {
|
||||
// The plain source remains available if a highlight chunk cannot load.
|
||||
}
|
||||
const preview = ref<HTMLElement>();
|
||||
let generation = 0;
|
||||
let observer: IntersectionObserver | undefined;
|
||||
async function highlight() {
|
||||
const current = ++generation;
|
||||
try {
|
||||
const result = await highlights[props.name]?.();
|
||||
if (current === generation) highlightedCode.value = result?.default ?? "";
|
||||
} catch {
|
||||
/* Plain same-SFC source remains available. */
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => props.name,
|
||||
() => {
|
||||
highlightedCode.value = "";
|
||||
void highlight();
|
||||
},
|
||||
);
|
||||
watch(expanded, (value) => {
|
||||
if (value && !highlightedCode.value) void highlight();
|
||||
});
|
||||
onMounted(() => {
|
||||
if (!preview.value || props.hideCode) return;
|
||||
if (typeof IntersectionObserver === "undefined") {
|
||||
void highlight();
|
||||
return;
|
||||
}
|
||||
observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries.some((entry) => entry.isIntersecting)) {
|
||||
void highlight();
|
||||
observer?.disconnect();
|
||||
}
|
||||
},
|
||||
{ rootMargin: "200px" },
|
||||
);
|
||||
observer.observe(preview.value);
|
||||
});
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
async function copy() {
|
||||
@@ -53,12 +92,18 @@ async function copy() {
|
||||
copyStatus.value = "复制失败,请手动选择代码";
|
||||
}
|
||||
}
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
onBeforeUnmount(() => {
|
||||
clearTimeout(timer);
|
||||
generation++;
|
||||
observer?.disconnect();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="component-preview-container" :data-name="name">
|
||||
<p v-if="description" class="preview-description">{{ description }}</p>
|
||||
<div
|
||||
class="preview not-prose"
|
||||
:class="{ 'preview-only': hideCode }"
|
||||
:style="{
|
||||
alignItems:
|
||||
align === 'start'
|
||||
@@ -69,50 +114,59 @@ onBeforeUnmount(() => clearTimeout(timer));
|
||||
background: isBgSolid ? 'var(--background)' : undefined,
|
||||
}"
|
||||
>
|
||||
<div class="demo-row">
|
||||
<div class="demo-row" :style="{ minHeight }">
|
||||
<component :is="component" v-if="component" />
|
||||
<p v-else role="alert">示例不存在:{{ name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="code-section">
|
||||
<div class="code-toolbar">
|
||||
<span class="code-language">
|
||||
<span class="code-dot" aria-hidden="true" />
|
||||
Vue
|
||||
</span>
|
||||
<div>
|
||||
<button
|
||||
:aria-label="(expanded ? '收起' : '展开') + name + ' 示例代码'"
|
||||
:aria-controls="id"
|
||||
:aria-expanded="expanded"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
<IconCode aria-hidden="true" :size="14" />
|
||||
{{ expanded ? "收起代码" : "展开代码" }}
|
||||
</button>
|
||||
<button :aria-label="'复制' + name + ' 示例代码'" @click="copy">
|
||||
<IconCopy aria-hidden="true" :size="14" />
|
||||
复制代码
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="copy-feedback"
|
||||
:class="{ 'sr-only': copyStatus === '复制代码' }"
|
||||
role="status"
|
||||
<div
|
||||
v-if="!hideCode"
|
||||
ref="preview"
|
||||
class="code-section not-prose"
|
||||
:data-expanded="expanded"
|
||||
>
|
||||
<Button
|
||||
class="preview-copy"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
is-icon-only
|
||||
:aria-label="'复制' + name + ' 示例代码'"
|
||||
@click="copy"
|
||||
>
|
||||
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
||||
</p>
|
||||
<IconCheck
|
||||
v-if="copyStatus === '已复制'"
|
||||
aria-hidden="true"
|
||||
:size="16"
|
||||
/>
|
||||
<IconCopy v-else aria-hidden="true" :size="16" />
|
||||
</Button>
|
||||
<div
|
||||
v-if="expanded"
|
||||
:id="id"
|
||||
class="highlighted-source"
|
||||
tabindex="0"
|
||||
:aria-hidden="!expanded || undefined"
|
||||
:tabindex="expanded ? 0 : undefined"
|
||||
:aria-label="name + ' 示例源码'"
|
||||
>
|
||||
<div v-if="highlightedCode" v-html="highlightedCode" />
|
||||
<pre v-else><code>{{ code }}</code></pre>
|
||||
<pre
|
||||
v-else
|
||||
><code>{{expanded ? code : code.split('\n').slice(0,5).join('\n')}}</code></pre>
|
||||
</div>
|
||||
<Button
|
||||
class="preview-expand"
|
||||
size="sm"
|
||||
variant="tertiary"
|
||||
:aria-label="(expanded ? '收起' : '展开') + name + ' 示例代码'"
|
||||
:aria-controls="id"
|
||||
:aria-expanded="expanded"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
<IconCode :size="14" aria-hidden="true" />
|
||||
{{ expanded ? "收起代码" : "展开代码" }}
|
||||
</Button>
|
||||
<p class="sr-only" role="status">
|
||||
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -10,15 +10,21 @@ import {
|
||||
} from "vue";
|
||||
import { withBase, useRouter } from "vitepress";
|
||||
import {
|
||||
DialogRoot,
|
||||
DialogTrigger,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
DialogClose,
|
||||
} from "reka-ui";
|
||||
Button,
|
||||
Link,
|
||||
Kbd,
|
||||
Modal,
|
||||
ModalTrigger,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
SearchField,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
EmptyState,
|
||||
} from "@heroui-vue/components";
|
||||
import { searchIndex } from "virtual:docs-data";
|
||||
import { searchDocs, searchExcerpt } from "./search";
|
||||
const router = useRouter();
|
||||
@@ -26,7 +32,7 @@ const navigating = ref(false);
|
||||
const open = ref(false),
|
||||
query = ref(""),
|
||||
active = ref(0),
|
||||
field = ref<HTMLInputElement>();
|
||||
field = ref<{ focus: () => void }>();
|
||||
const results = computed(() => searchDocs(searchIndex, query.value));
|
||||
watch(query, () => {
|
||||
active.value = 0;
|
||||
@@ -36,11 +42,31 @@ watch(open, (value) => {
|
||||
else navigating.value = false;
|
||||
});
|
||||
function shortcut(event: KeyboardEvent) {
|
||||
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
||||
if (
|
||||
!event.defaultPrevented &&
|
||||
!event.isComposing &&
|
||||
!event.repeat &&
|
||||
(event.metaKey || event.ctrlKey) &&
|
||||
event.key.toLowerCase() === "k"
|
||||
) {
|
||||
event.preventDefault();
|
||||
open.value = !open.value;
|
||||
}
|
||||
}
|
||||
function keydown(event: KeyboardEvent) {
|
||||
if (event.defaultPrevented || event.isComposing || event.keyCode === 229)
|
||||
return;
|
||||
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
move(event.key === "ArrowDown" ? 1 : -1);
|
||||
} else if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
navigate();
|
||||
} else if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
open.value = false;
|
||||
}
|
||||
}
|
||||
function move(delta: number) {
|
||||
if (!results.value.length) return;
|
||||
active.value =
|
||||
@@ -67,6 +93,9 @@ function navigate() {
|
||||
const entry = results.value[active.value];
|
||||
if (entry) void navigateTo(entry);
|
||||
}
|
||||
function guardEscape(event: KeyboardEvent) {
|
||||
if (event.isComposing) event.preventDefault();
|
||||
}
|
||||
function closeAutoFocus(event: Event) {
|
||||
if (navigating.value) event.preventDefault();
|
||||
}
|
||||
@@ -74,83 +103,113 @@ onMounted(() => window.addEventListener("keydown", shortcut));
|
||||
onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
||||
</script>
|
||||
<template>
|
||||
<DialogRoot v-model:open="open">
|
||||
<DialogTrigger class="search-trigger" aria-label="搜索文档">
|
||||
<IconSearch aria-hidden="true" :size="17" />
|
||||
<span>搜索文档…</span>
|
||||
<kbd>⌘ / Ctrl K</kbd>
|
||||
</DialogTrigger>
|
||||
<DialogPortal>
|
||||
<DialogOverlay class="search-overlay" />
|
||||
<DialogContent
|
||||
class="search-dialog"
|
||||
@open-auto-focus.prevent="field?.focus()"
|
||||
@close-auto-focus="closeAutoFocus"
|
||||
>
|
||||
<DialogTitle class="sr-only">搜索文档</DialogTitle>
|
||||
<DialogDescription class="sr-only">
|
||||
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
||||
</DialogDescription>
|
||||
<div class="search-field">
|
||||
<input
|
||||
ref="field"
|
||||
v-model="query"
|
||||
placeholder="搜索组件、参数或用法…"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
role="combobox"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="doc-search-results"
|
||||
:aria-expanded="Boolean(query.trim())"
|
||||
:aria-activedescendant="
|
||||
results.length ? 'search-result-' + active : undefined
|
||||
"
|
||||
@keydown.down.prevent="move(1)"
|
||||
@keydown.up.prevent="move(-1)"
|
||||
@keydown.enter.prevent="navigate"
|
||||
/>
|
||||
<DialogClose class="search-close" aria-label="关闭搜索">
|
||||
Esc
|
||||
</DialogClose>
|
||||
</div>
|
||||
<div
|
||||
class="search-results"
|
||||
id="doc-search-results"
|
||||
role="listbox"
|
||||
aria-label="搜索结果"
|
||||
<Modal v-model:open="open">
|
||||
<ModalTrigger as-child>
|
||||
<Button class="search-trigger" variant="secondary" aria-label="搜索文档">
|
||||
<IconSearch aria-hidden="true" :size="17" />
|
||||
<span>搜索文档…</span>
|
||||
<Kbd>⌘ / Ctrl K</Kbd>
|
||||
</Button>
|
||||
</ModalTrigger>
|
||||
<ModalBackdrop class="docs-search-backdrop" variant="blur">
|
||||
<ModalContainer placement="top" size="lg" class="docs-search-container">
|
||||
<ModalDialog
|
||||
class="search-dialog"
|
||||
@open-auto-focus.prevent="field?.focus()"
|
||||
@close-auto-focus="closeAutoFocus"
|
||||
@escape-key-down="guardEscape"
|
||||
>
|
||||
<p v-if="!query.trim()" class="search-empty">
|
||||
试试搜索「isPending」「主题」或「受控」
|
||||
<ModalHeading class="sr-only">搜索文档</ModalHeading>
|
||||
<p class="sr-only" id="docs-search-instructions">
|
||||
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
||||
</p>
|
||||
<p v-else-if="!results.length" class="search-empty" role="status">
|
||||
没有找到“{{ query }}”,试试组件名或参数名。
|
||||
</p>
|
||||
<a
|
||||
v-for="(entry, index) in results"
|
||||
:id="'search-result-' + index"
|
||||
:key="entry.url"
|
||||
:href="withBase(entry.url)"
|
||||
role="option"
|
||||
:aria-selected="index === active"
|
||||
:tabindex="-1"
|
||||
@mousemove="active = index"
|
||||
@click.prevent="navigateTo(entry)"
|
||||
<div class="search-field">
|
||||
<SearchField
|
||||
v-model="query"
|
||||
class="docs-search-input"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput
|
||||
ref="field"
|
||||
placeholder="搜索组件、参数或用法…"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
role="combobox"
|
||||
aria-autocomplete="list"
|
||||
aria-describedby="docs-search-instructions"
|
||||
aria-controls="doc-search-results"
|
||||
:aria-expanded="Boolean(query.trim())"
|
||||
:aria-activedescendant="
|
||||
query.trim() && results.length
|
||||
? 'search-result-' + active
|
||||
: undefined
|
||||
"
|
||||
@keydown="keydown"
|
||||
/>
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
class="search-close"
|
||||
aria-label="关闭搜索"
|
||||
@click="open = false"
|
||||
>
|
||||
<Kbd>Esc</Kbd>
|
||||
</Button>
|
||||
</div>
|
||||
<div
|
||||
class="search-results"
|
||||
id="doc-search-results"
|
||||
role="listbox"
|
||||
aria-label="搜索结果"
|
||||
>
|
||||
<span class="result-title">
|
||||
{{ entry.title }}
|
||||
<span>{{ entry.section }}</span>
|
||||
<EmptyState v-if="!query.trim()" class="search-empty">
|
||||
<IconSearch :size="24" aria-hidden="true" />
|
||||
<p>试试搜索「isPending」「主题」或「受控」</p>
|
||||
</EmptyState>
|
||||
<EmptyState
|
||||
v-else-if="!results.length"
|
||||
class="search-empty"
|
||||
role="status"
|
||||
>
|
||||
<p>没有找到“{{ query }}”,试试组件名或参数名。</p>
|
||||
</EmptyState>
|
||||
<Link
|
||||
v-for="(entry, index) in results"
|
||||
:id="'search-result-' + index"
|
||||
:key="entry.url"
|
||||
:href="withBase(entry.url)"
|
||||
role="option"
|
||||
:aria-selected="index === active"
|
||||
:tabindex="-1"
|
||||
@mousemove="active = index"
|
||||
@click.prevent="navigateTo(entry)"
|
||||
>
|
||||
<span class="result-title">
|
||||
{{ entry.title }}
|
||||
<span>{{ entry.section }}</span>
|
||||
</span>
|
||||
<span class="result-excerpt">
|
||||
{{ searchExcerpt(entry, query) || "查看文档" }}
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
<div class="search-footer" aria-live="polite">
|
||||
<span>
|
||||
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
||||
</span>
|
||||
<span class="result-excerpt">
|
||||
{{ searchExcerpt(entry, query) || "查看文档" }}
|
||||
<span>
|
||||
<Kbd>↑</Kbd>
|
||||
<Kbd>↓</Kbd>
|
||||
选择
|
||||
<Kbd>↵</Kbd>
|
||||
打开
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="search-footer" aria-live="polite">
|
||||
<span>
|
||||
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
||||
</span>
|
||||
<span>↑ ↓ 选择 ↵ 打开</span>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
</div>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { Card, CardTitle, CardDescription } from "@heroui-vue/components";
|
||||
import { withBase } from "vitepress";
|
||||
import { IconArrowUpRight } from "@tabler/icons-vue";
|
||||
import { searchIndex } from "virtual:docs-data";
|
||||
import { componentItems } from "./navigation";
|
||||
const props = defineProps<{ category: string }>();
|
||||
const items = computed(() =>
|
||||
componentItems.filter((item) => item.category === props.category),
|
||||
);
|
||||
function description(url: string) {
|
||||
return (
|
||||
searchIndex.find((entry) => entry.url === url && entry.section === "概览")
|
||||
?.text ?? "查看组件用法与 API"
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="components-grid not-prose">
|
||||
<Card
|
||||
v-for="item in items"
|
||||
:key="item.url"
|
||||
as="a"
|
||||
:href="withBase(item.url)"
|
||||
class="component-index-card"
|
||||
variant="transparent"
|
||||
>
|
||||
<CardTitle>
|
||||
{{ item.title }}
|
||||
<IconArrowUpRight aria-hidden="true" :size="16" />
|
||||
</CardTitle>
|
||||
<CardDescription>{{ description(item.url) }}</CardDescription>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from "@heroui-vue/components";
|
||||
import { withBase } from "vitepress";
|
||||
import type { DocsGroup } from "./navigation";
|
||||
defineProps<{ groups: DocsGroup[]; current: string; label?: string }>();
|
||||
const emit = defineEmits<{ navigate: [] }>();
|
||||
</script>
|
||||
<template>
|
||||
<nav :aria-label="label ?? '文档导航'" class="sidebar-tree">
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<Link
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:aria-current="current === item.url ? 'page' : undefined"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
{{ item.title }}
|
||||
</Link>
|
||||
</section>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from "@heroui-vue/components";
|
||||
interface TocEntry {
|
||||
title: string;
|
||||
slug: string;
|
||||
children?: TocEntry[];
|
||||
}
|
||||
defineProps<{ headers: TocEntry[]; active: string }>();
|
||||
const emit = defineEmits<{ navigate: [slug: string, event: MouseEvent] }>();
|
||||
</script>
|
||||
<template>
|
||||
<nav class="toc-links" aria-label="本页目录">
|
||||
<template v-for="heading in headers" :key="heading.slug">
|
||||
<Link
|
||||
:href="'#' + heading.slug"
|
||||
:aria-current="active === heading.slug ? 'location' : undefined"
|
||||
@click="emit('navigate', heading.slug, $event)"
|
||||
>
|
||||
{{ heading.title }}
|
||||
</Link>
|
||||
<Link
|
||||
v-for="child in heading.children"
|
||||
:key="child.slug"
|
||||
class="nested"
|
||||
:href="'#' + child.slug"
|
||||
:aria-current="active === child.slug ? 'location' : undefined"
|
||||
@click="emit('navigate', child.slug, $event)"
|
||||
>
|
||||
{{ child.title }}
|
||||
</Link>
|
||||
</template>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -1,11 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
IconSun,
|
||||
IconMoon,
|
||||
IconMenu2,
|
||||
IconX,
|
||||
IconArrowUpRight,
|
||||
} from "@tabler/icons-vue";
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
@@ -14,173 +7,186 @@ import {
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
} from "vue";
|
||||
import { useData, useRoute, withBase, onContentUpdated } from "vitepress";
|
||||
import {
|
||||
DialogRoot,
|
||||
DialogTrigger,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
DialogClose,
|
||||
} from "reka-ui";
|
||||
useData,
|
||||
useRoute,
|
||||
useRouter,
|
||||
withBase,
|
||||
onContentUpdated,
|
||||
} from "vitepress";
|
||||
import {
|
||||
Button,
|
||||
Link,
|
||||
Chip,
|
||||
Separator,
|
||||
Breadcrumbs,
|
||||
BreadcrumbsItem,
|
||||
Card,
|
||||
Drawer,
|
||||
DrawerTrigger,
|
||||
DrawerBackdrop,
|
||||
DrawerContent,
|
||||
DrawerDialog,
|
||||
DrawerHeader,
|
||||
DrawerHeading,
|
||||
DrawerBody,
|
||||
DrawerCloseTrigger,
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
ScrollShadow,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconMenu2,
|
||||
IconArrowUpRight,
|
||||
IconBook2,
|
||||
IconComponents,
|
||||
IconList,
|
||||
IconChevronDown,
|
||||
IconBrandVue,
|
||||
IconBrandGithub,
|
||||
IconArrowLeft,
|
||||
IconArrowRight,
|
||||
} from "@tabler/icons-vue";
|
||||
import DocSearch from "./DocSearch.vue";
|
||||
const { frontmatter, page, isDark } = useData();
|
||||
import DocsSidebar from "./DocsSidebar.vue";
|
||||
import DocsToc from "./DocsToc.vue";
|
||||
import DocsThemeSwitch from "./DocsThemeSwitch.vue";
|
||||
import {
|
||||
guideGroups,
|
||||
componentGroups,
|
||||
componentItems,
|
||||
docsPath,
|
||||
docsSection,
|
||||
adjacentPages,
|
||||
} from "./navigation";
|
||||
const { frontmatter, page, site } = useData();
|
||||
const route = useRoute();
|
||||
const mobile = ref(false),
|
||||
activeSlug = ref("");
|
||||
const copyMessage = ref("");
|
||||
let copyTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
onBeforeUnmount(() => clearTimeout(copyTimer));
|
||||
const groups = [
|
||||
{
|
||||
title: "开始使用",
|
||||
items: [
|
||||
{ title: "介绍", url: "/introduction" },
|
||||
{ title: "安装", url: "/guide" },
|
||||
{ title: "主题", url: "/themes" },
|
||||
{ title: "字段与表单基础", url: "/fields" },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "组件",
|
||||
items: [
|
||||
{ title: "Accordion 手风琴", url: "/components/accordion" },
|
||||
{ title: "Alert 警告", url: "/components/alert" },
|
||||
{ title: "AlertDialog 警告对话框", url: "/components/alert-dialog" },
|
||||
{ title: "Avatar 头像", url: "/components/avatar" },
|
||||
{ title: "AvatarGroup 头像组", url: "/components/avatar-group" },
|
||||
{ title: "Badge 徽章", url: "/components/badge" },
|
||||
{ title: "Breadcrumbs 面包屑", url: "/components/breadcrumbs" },
|
||||
{ title: "Button 按钮", url: "/components/button" },
|
||||
{
|
||||
title: "ButtonGroup 按钮组",
|
||||
url: "/components/button-group",
|
||||
},
|
||||
{ title: "Card 卡片", url: "/components/card" },
|
||||
{ title: "Checkbox 复选框", url: "/components/checkbox" },
|
||||
{ title: "CheckboxGroup 复选框组", url: "/components/checkbox-group" },
|
||||
{ title: "Chip 标签", url: "/components/chip" },
|
||||
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
|
||||
{ title: "DateField 日期字段", url: "/components/date-field" },
|
||||
{ title: "Description 描述", url: "/components/description" },
|
||||
{ title: "Disclosure 折叠面板", url: "/components/disclosure" },
|
||||
{
|
||||
title: "DisclosureGroup 折叠面板组",
|
||||
url: "/components/disclosure-group",
|
||||
},
|
||||
{ title: "Drawer 抽屉", url: "/components/drawer" },
|
||||
{ title: "EmptyState 空状态", url: "/components/empty-state" },
|
||||
{ title: "FieldError 字段错误", url: "/components/field-error" },
|
||||
{ title: "Fieldset 字段组", url: "/components/fieldset" },
|
||||
{ title: "Header 标题", url: "/components/header" },
|
||||
{ title: "Input 输入框", url: "/components/input" },
|
||||
{ title: "InputOTP 验证码输入", url: "/components/input-otp" },
|
||||
{ title: "InputGroup 输入框组", url: "/components/input-group" },
|
||||
{ title: "Kbd 键盘按键", url: "/components/kbd" },
|
||||
{ title: "Label 标签", url: "/components/label" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "Meter 计量条", url: "/components/meter" },
|
||||
{ title: "Modal 模态框", url: "/components/modal" },
|
||||
{ title: "Pagination 分页", url: "/components/pagination" },
|
||||
{ title: "Popover 弹出框", url: "/components/popover" },
|
||||
{ title: "ProgressBar 进度条", url: "/components/progress-bar" },
|
||||
{
|
||||
title: "ProgressCircle 环形进度条",
|
||||
url: "/components/progress-circle",
|
||||
},
|
||||
{ title: "RadioGroup 单选框组", url: "/components/radio-group" },
|
||||
{ title: "ScrollShadow 滚动阴影", url: "/components/scroll-shadow" },
|
||||
{ title: "SearchField 搜索框", url: "/components/search-field" },
|
||||
{ title: "Separator 分隔符", url: "/components/separator" },
|
||||
{ title: "Skeleton 骨架屏", url: "/components/skeleton" },
|
||||
{ title: "Spinner 加载指示器", url: "/components/spinner" },
|
||||
{ title: "Surface 表面", url: "/components/surface" },
|
||||
{ title: "Switch 开关", url: "/components/switch" },
|
||||
{ title: "Tabs 标签页", url: "/components/tabs" },
|
||||
{ title: "TextArea 多行文本框", url: "/components/textarea" },
|
||||
{ title: "TextField 文本输入框", url: "/components/text-field" },
|
||||
{ title: "Toolbar 工具栏", url: "/components/toolbar" },
|
||||
{ title: "NumberField 数字输入框", url: "/components/number-field" },
|
||||
{ title: "Slider 滑块", url: "/components/slider" },
|
||||
{ title: "ListBox 列表框", url: "/components/list-box" },
|
||||
{ title: "Select 选择器", url: "/components/select" },
|
||||
{ title: "Tooltip 工具提示", url: "/components/tooltip" },
|
||||
{
|
||||
title: "ToggleButton 切换按钮",
|
||||
url: "/components/toggle-button",
|
||||
},
|
||||
{
|
||||
title: "ToggleButtonGroup 切换按钮组",
|
||||
url: "/components/toggle-button-group",
|
||||
},
|
||||
{ title: "Typography 排版", url: "/components/typography" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const items = groups.flatMap((g) => g.items);
|
||||
const currentIndex = computed(() =>
|
||||
items.findIndex((item) => selected(item.url)),
|
||||
);
|
||||
const previous = computed(() => items[currentIndex.value - 1]);
|
||||
const next = computed(() => items[currentIndex.value + 1]);
|
||||
function selected(url: string) {
|
||||
return (
|
||||
route.path === withBase(url) ||
|
||||
route.path === withBase(url + ".html") ||
|
||||
(url === "/components/button" && route.path === withBase("/"))
|
||||
);
|
||||
const router = useRouter();
|
||||
let pendingToc: { slug: string; path: string } | undefined;
|
||||
function navigateToc(slug: string, event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
pendingToc = { slug, path: current.value };
|
||||
tocOpen.value = false;
|
||||
}
|
||||
async function finishTocNavigation(event: Event) {
|
||||
const target = pendingToc;
|
||||
pendingToc = undefined;
|
||||
if (!target || current.value !== target.path) return;
|
||||
event.preventDefault();
|
||||
await router.go(
|
||||
withBase(target.path + "#" + encodeURIComponent(target.slug)),
|
||||
);
|
||||
await nextTick();
|
||||
if (current.value !== target.path) return;
|
||||
const heading = document.getElementById(target.slug);
|
||||
heading?.setAttribute("tabindex", "-1");
|
||||
heading?.focus({ preventScroll: true });
|
||||
heading?.scrollIntoView({ block: "start" });
|
||||
}
|
||||
const current = computed(() => docsPath(route.path, site.value.base));
|
||||
const section = computed(() => docsSection(route.path, site.value.base));
|
||||
const groups = computed(() =>
|
||||
section.value === "components" ? componentGroups : guideGroups,
|
||||
);
|
||||
const adjacent = computed(() => adjacentPages(route.path, site.value.base));
|
||||
const componentSlug = computed(() =>
|
||||
componentItems.some((item) => item.url === current.value)
|
||||
? current.value.split("/").pop()
|
||||
: undefined,
|
||||
);
|
||||
const headers = computed(() => page.value.headers ?? []);
|
||||
const flatHeaders = computed(() =>
|
||||
headers.value.flatMap((h) => [h, ...(h.children ?? [])]),
|
||||
headers.value.flatMap((heading) => [heading, ...(heading.children ?? [])]),
|
||||
);
|
||||
let ticking = false;
|
||||
const mobile = ref(false),
|
||||
tocOpen = ref(false),
|
||||
activeSlug = ref("");
|
||||
const sidebar = ref<{ $el?: HTMLElement }>();
|
||||
const copyMessage = ref("");
|
||||
let copyTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let frame = 0;
|
||||
function updateActive() {
|
||||
ticking = false;
|
||||
const headings = flatHeaders.value
|
||||
.map((h) => document.getElementById(h.slug))
|
||||
.filter((el): el is HTMLElement => Boolean(el));
|
||||
let active = headings[0]?.id ?? "";
|
||||
for (const heading of headings) {
|
||||
if (heading.getBoundingClientRect().top <= 120) active = heading.id;
|
||||
else break;
|
||||
frame = 0;
|
||||
let active = flatHeaders.value[0]?.slug ?? "";
|
||||
for (const heading of flatHeaders.value) {
|
||||
const element = document.getElementById(heading.slug);
|
||||
if (element && element.getBoundingClientRect().top <= 160)
|
||||
active = heading.slug;
|
||||
else if (element) break;
|
||||
}
|
||||
if (
|
||||
window.innerHeight + window.scrollY >=
|
||||
document.documentElement.scrollHeight - 2
|
||||
)
|
||||
active = flatHeaders.value.at(-1)?.slug ?? active;
|
||||
activeSlug.value = active;
|
||||
}
|
||||
function onScroll() {
|
||||
if (!ticking) {
|
||||
ticking = true;
|
||||
requestAnimationFrame(updateActive);
|
||||
}
|
||||
if (!frame) frame = requestAnimationFrame(updateActive);
|
||||
}
|
||||
function revealCurrent() {
|
||||
const element = sidebar.value?.$el?.querySelector<HTMLElement>(
|
||||
'[aria-current="page"]',
|
||||
);
|
||||
const viewport = sidebar.value?.$el;
|
||||
if (!element || !viewport || !viewport.clientHeight) return;
|
||||
const top = element.getBoundingClientRect().top,
|
||||
bounds = viewport.getBoundingClientRect();
|
||||
if (
|
||||
top < bounds.top ||
|
||||
element.getBoundingClientRect().bottom > bounds.bottom
|
||||
)
|
||||
element.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
onMounted(() => {
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
updateActive();
|
||||
revealCurrent();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("scroll", onScroll);
|
||||
cancelAnimationFrame(frame);
|
||||
clearTimeout(copyTimer);
|
||||
});
|
||||
onBeforeUnmount(() => window.removeEventListener("scroll", onScroll));
|
||||
onContentUpdated(() => {
|
||||
void nextTick(updateActive);
|
||||
void nextTick(() => {
|
||||
updateActive();
|
||||
revealCurrent();
|
||||
});
|
||||
});
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
mobile.value = false;
|
||||
tocOpen.value = false;
|
||||
void nextTick(() => {
|
||||
if (!window.location.hash)
|
||||
window.scrollTo({ top: 0, behavior: "instant" });
|
||||
updateActive();
|
||||
revealCurrent();
|
||||
});
|
||||
},
|
||||
);
|
||||
function focusPage(event: Event) {
|
||||
if (!navigationFromDrawer) return;
|
||||
event.preventDefault();
|
||||
navigationFromDrawer = false;
|
||||
document
|
||||
.querySelector<HTMLElement>(".docs-main h1")
|
||||
?.focus({ preventScroll: true });
|
||||
}
|
||||
let navigationFromDrawer = false;
|
||||
function leaveDrawer() {
|
||||
navigationFromDrawer = true;
|
||||
mobile.value = false;
|
||||
}
|
||||
async function copyMarkdownCode(event: MouseEvent) {
|
||||
const target = (event.target as HTMLElement).closest<HTMLButtonElement>(
|
||||
"button.copy",
|
||||
);
|
||||
if (!target) return;
|
||||
const code = target.parentElement?.querySelector("pre code")?.textContent;
|
||||
if (!code) return;
|
||||
const code = target?.parentElement?.querySelector("pre code")?.textContent;
|
||||
if (!target || !code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
target.classList.add("copied");
|
||||
@@ -200,167 +206,257 @@ async function copyMarkdownCode(event: MouseEvent) {
|
||||
</script>
|
||||
<template>
|
||||
<div class="docs-layout">
|
||||
<a class="skip" href="#main">跳至内容</a>
|
||||
<Link class="skip" href="#main">跳至内容</Link>
|
||||
<p class="sr-only" role="status">{{ copyMessage }}</p>
|
||||
<header class="docs-nav">
|
||||
<a class="brand" :href="withBase('/components/button')">
|
||||
heroui
|
||||
<span>Vue</span>
|
||||
</a>
|
||||
<span class="version">v0.0.1</span>
|
||||
<nav aria-label="主导航">
|
||||
<a
|
||||
:href="withBase('/guide')"
|
||||
:class="{
|
||||
active:
|
||||
!frontmatter.component && route.path !== withBase('/themes'),
|
||||
}"
|
||||
>
|
||||
文档
|
||||
</a>
|
||||
<a
|
||||
:href="withBase('/components/button')"
|
||||
:class="{ active: Boolean(frontmatter.component) }"
|
||||
>
|
||||
组件
|
||||
</a>
|
||||
<a
|
||||
:href="withBase('/themes')"
|
||||
:class="{ active: route.path === withBase('/themes') }"
|
||||
>
|
||||
主题
|
||||
</a>
|
||||
</nav>
|
||||
<div class="nav-tools">
|
||||
<div class="docs-nav-main">
|
||||
<div class="docs-brand-group">
|
||||
<Link
|
||||
class="brand"
|
||||
:href="withBase('/')"
|
||||
aria-label="HeroUI Vue 文档首页"
|
||||
>
|
||||
heroui
|
||||
<Chip size="sm" variant="soft">Vue</Chip>
|
||||
</Link>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
class="version"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
aria-label="版本信息"
|
||||
>
|
||||
v0.0.1
|
||||
<IconChevronDown :size="12" aria-hidden="true" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent placement="bottom start">
|
||||
<PopoverDialog class="version-panel">
|
||||
<PopoverHeading>HeroUI Vue</PopoverHeading>
|
||||
<p>社区独立实现 · v0.0.1</p>
|
||||
<Separator />
|
||||
<Link
|
||||
href="https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
设计基线 HeroUI v3.2.6
|
||||
<IconArrowUpRight :size="13" aria-hidden="true" />
|
||||
</Link>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
<DocSearch />
|
||||
<button
|
||||
class="theme-toggle"
|
||||
:aria-label="isDark ? '切换浅色主题' : '切换深色主题'"
|
||||
@click="isDark = !isDark"
|
||||
>
|
||||
<IconSun v-if="isDark" aria-hidden="true" :size="18" />
|
||||
<IconMoon v-else aria-hidden="true" :size="18" />
|
||||
</button>
|
||||
<DialogRoot v-model:open="mobile">
|
||||
<DialogTrigger class="mobile-menu" aria-label="打开文档目录">
|
||||
<IconMenu2 aria-hidden="true" :size="20" />
|
||||
</DialogTrigger>
|
||||
<DialogPortal>
|
||||
<DialogOverlay class="mobile-nav-overlay" />
|
||||
<DialogContent class="mobile-nav-dialog">
|
||||
<div class="mobile-nav-heading">
|
||||
<DialogTitle>文档目录</DialogTitle>
|
||||
<DialogClose aria-label="关闭文档目录">
|
||||
<IconX aria-hidden="true" :size="20" />
|
||||
</DialogClose>
|
||||
</div>
|
||||
<nav aria-label="移动端文档导航">
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<a
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
||||
@click="mobile = false"
|
||||
>
|
||||
{{ item.title }}
|
||||
</a>
|
||||
</section>
|
||||
</nav>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
<div class="nav-tools">
|
||||
<Link
|
||||
class="docs-github"
|
||||
href="https://git.myjdemo.cn/maoyingjie/heroui-vue"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
aria-label="项目源码"
|
||||
>
|
||||
<IconBrandGithub :size="19" aria-hidden="true" />
|
||||
</Link>
|
||||
<DocsThemeSwitch />
|
||||
<Drawer v-model:open="mobile">
|
||||
<DrawerTrigger as-child>
|
||||
<Button
|
||||
class="mobile-menu"
|
||||
is-icon-only
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
aria-label="打开文档目录"
|
||||
>
|
||||
<IconMenu2 :size="20" aria-hidden="true" />
|
||||
</Button>
|
||||
</DrawerTrigger>
|
||||
<DrawerBackdrop>
|
||||
<DrawerContent placement="left" class="docs-drawer-content">
|
||||
<DrawerDialog
|
||||
class="docs-drawer-dialog"
|
||||
@close-auto-focus="focusPage"
|
||||
>
|
||||
<DrawerHeader class="docs-drawer-heading">
|
||||
<DrawerHeading>文档目录</DrawerHeading>
|
||||
<DrawerCloseTrigger aria-label="关闭文档目录" />
|
||||
</DrawerHeader>
|
||||
<DrawerBody>
|
||||
<nav class="mobile-section-links" aria-label="文档栏目">
|
||||
<Link
|
||||
:href="withBase('/introduction')"
|
||||
:aria-current="section === 'guide' ? 'page' : undefined"
|
||||
@click="leaveDrawer"
|
||||
>
|
||||
快速开始
|
||||
</Link>
|
||||
<Link
|
||||
:href="withBase('/components')"
|
||||
:aria-current="
|
||||
section === 'components' ? 'page' : undefined
|
||||
"
|
||||
@click="leaveDrawer"
|
||||
>
|
||||
组件
|
||||
</Link>
|
||||
</nav>
|
||||
<Separator />
|
||||
<DocsSidebar
|
||||
:groups="groups"
|
||||
:current="current"
|
||||
label="移动端文档导航"
|
||||
@navigate="leaveDrawer"
|
||||
/>
|
||||
</DrawerBody>
|
||||
</DrawerDialog>
|
||||
</DrawerContent>
|
||||
</DrawerBackdrop>
|
||||
</Drawer>
|
||||
</div>
|
||||
</div>
|
||||
<div class="docs-nav-sections">
|
||||
<nav aria-label="主导航">
|
||||
<Link
|
||||
:href="withBase('/introduction')"
|
||||
:aria-current="section === 'guide' ? 'page' : undefined"
|
||||
>
|
||||
<IconBook2 :size="16" aria-hidden="true" />
|
||||
快速开始
|
||||
</Link>
|
||||
<Link
|
||||
:href="withBase('/components')"
|
||||
:aria-current="section === 'components' ? 'page' : undefined"
|
||||
>
|
||||
<IconComponents :size="16" aria-hidden="true" />
|
||||
组件
|
||||
</Link>
|
||||
</nav>
|
||||
<Chip class="framework" size="sm" variant="soft">
|
||||
<IconBrandVue :size="14" aria-hidden="true" />
|
||||
Vue 3
|
||||
</Chip>
|
||||
</div>
|
||||
</header>
|
||||
<div class="docs-body">
|
||||
<aside class="docs-sidebar" aria-label="文档导航">
|
||||
<div class="framework">
|
||||
<span class="vue-mark">V</span>
|
||||
Vue
|
||||
<span class="framework-note">组件库</span>
|
||||
</div>
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<a
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:class="{ selected: selected(item.url) }"
|
||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
||||
>
|
||||
{{ item.title }}
|
||||
</a>
|
||||
</section>
|
||||
<p class="community">
|
||||
独立社区实现
|
||||
<br />
|
||||
设计基线 HeroUI v3.2.6
|
||||
</p>
|
||||
<aside class="docs-sidebar" aria-label="侧栏">
|
||||
<ScrollShadow
|
||||
ref="sidebar"
|
||||
class="docs-sidebar-scroll"
|
||||
:hide-scroll-bar="false"
|
||||
>
|
||||
<DocsSidebar :groups="groups" :current="current" />
|
||||
<p class="community">
|
||||
独立社区实现
|
||||
<br />
|
||||
设计基线 HeroUI v3.2.6
|
||||
</p>
|
||||
</ScrollShadow>
|
||||
</aside>
|
||||
<main id="main" class="docs-main">
|
||||
<div class="breadcrumb">
|
||||
{{ frontmatter.group ?? "文档" }}
|
||||
<span>›</span>
|
||||
{{ frontmatter.title }}
|
||||
</div>
|
||||
<h1>{{ frontmatter.title }}</h1>
|
||||
<p class="page-description">{{ frontmatter.description }}</p>
|
||||
<div v-if="frontmatter.component" class="source-links">
|
||||
<a
|
||||
:href="`https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/react/src/components/${frontmatter.component}`"
|
||||
<div v-if="headers.length" class="mobile-toc">
|
||||
<Popover v-model:open="tocOpen" is-non-modal>
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="ghost" size="sm">
|
||||
<IconList :size="16" aria-hidden="true" />
|
||||
本页内容
|
||||
<IconChevronDown :size="14" aria-hidden="true" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
placement="bottom start"
|
||||
class="mobile-toc-content"
|
||||
@close-auto-focus="finishTocNavigation"
|
||||
>
|
||||
<PopoverDialog>
|
||||
<PopoverHeading class="sr-only">本页内容</PopoverHeading>
|
||||
<DocsToc
|
||||
:headers="headers"
|
||||
:active="activeSlug"
|
||||
@navigate="navigateToc"
|
||||
/>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
<main id="main" class="docs-main" tabindex="-1">
|
||||
<nav aria-label="面包屑">
|
||||
<Breadcrumbs class="breadcrumb" aria-label="页面路径">
|
||||
<BreadcrumbsItem
|
||||
:href="
|
||||
withBase(
|
||||
section === 'components' ? '/components' : '/introduction',
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ section === "components" ? "组件" : "快速开始" }}
|
||||
</BreadcrumbsItem>
|
||||
<BreadcrumbsItem>{{ frontmatter.title }}</BreadcrumbsItem>
|
||||
</Breadcrumbs>
|
||||
</nav>
|
||||
<h1 tabindex="-1">{{ frontmatter.title }}</h1>
|
||||
<p v-if="frontmatter.description" class="page-description">
|
||||
{{ frontmatter.description }}
|
||||
</p>
|
||||
<div v-if="componentSlug" class="source-links">
|
||||
<Link
|
||||
:href="`https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/react/src/components/${componentSlug}`"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
React 参考源码
|
||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
||||
</a>
|
||||
<a
|
||||
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${frontmatter.component}.css`"
|
||||
<IconArrowUpRight :size="12" aria-hidden="true" />
|
||||
</Link>
|
||||
<Link
|
||||
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${componentSlug}.css`"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
样式源码
|
||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
||||
</a>
|
||||
<IconArrowUpRight :size="12" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
<div @click="copyMarkdownCode"><Content class="docs-content" /></div>
|
||||
<nav class="page-navigation" aria-label="相邻页面">
|
||||
<a v-if="previous" :href="withBase(previous.url)">
|
||||
<span>上一页</span>
|
||||
<strong>{{ previous.title }}</strong>
|
||||
</a>
|
||||
<a v-if="next" class="page-next" :href="withBase(next.url)">
|
||||
<span>下一页</span>
|
||||
<strong>{{ next.title }}</strong>
|
||||
</a>
|
||||
<Card
|
||||
v-if="adjacent.previous"
|
||||
as="a"
|
||||
:href="withBase(adjacent.previous.url)"
|
||||
class="page-prev"
|
||||
variant="transparent"
|
||||
>
|
||||
<IconArrowLeft :size="18" aria-hidden="true" />
|
||||
<span>
|
||||
上一页
|
||||
<strong>{{ adjacent.previous.title }}</strong>
|
||||
</span>
|
||||
</Card>
|
||||
<Card
|
||||
v-if="adjacent.next"
|
||||
as="a"
|
||||
:href="withBase(adjacent.next.url)"
|
||||
class="page-next"
|
||||
variant="transparent"
|
||||
>
|
||||
<span>
|
||||
下一页
|
||||
<strong>{{ adjacent.next.title }}</strong>
|
||||
</span>
|
||||
<IconArrowRight :size="18" aria-hidden="true" />
|
||||
</Card>
|
||||
</nav>
|
||||
<footer class="docs-footer">
|
||||
基于 HeroUI v3 设计的 Vue 实现 ·
|
||||
<a :href="withBase('/introduction')">实现范围与差异</a>
|
||||
<Link :href="withBase('/introduction')">实现范围与差异</Link>
|
||||
</footer>
|
||||
</main>
|
||||
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录">
|
||||
<p>本页内容</p>
|
||||
<template v-for="h in headers" :key="h.slug">
|
||||
<a
|
||||
:href="'#' + h.slug"
|
||||
:class="{ current: activeSlug === h.slug }"
|
||||
:aria-current="activeSlug === h.slug ? 'location' : undefined"
|
||||
>
|
||||
{{ h.title }}
|
||||
</a>
|
||||
<a
|
||||
v-for="child in h.children"
|
||||
:key="child.slug"
|
||||
class="nested"
|
||||
:class="{ current: activeSlug === child.slug }"
|
||||
:aria-current="activeSlug === child.slug ? 'location' : undefined"
|
||||
:href="'#' + child.slug"
|
||||
>
|
||||
{{ child.title }}
|
||||
</a>
|
||||
</template>
|
||||
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录区域">
|
||||
<p>
|
||||
<IconList :size="16" aria-hidden="true" />
|
||||
本页内容
|
||||
</p>
|
||||
<ScrollShadow class="docs-toc-scroll">
|
||||
<DocsToc :headers="headers" :active="activeSlug" />
|
||||
</ScrollShadow>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import type { Theme } from "vitepress";
|
||||
import { IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import DocsComponents from "./DocsComponents.vue";
|
||||
import Layout from "./Layout.vue";
|
||||
import Demo from "./Demo.vue";
|
||||
import "@heroui-vue/styles/css";
|
||||
import "./utilities.css";
|
||||
import "./style.css";
|
||||
import "./shell.css";
|
||||
export default {
|
||||
Layout,
|
||||
enhanceApp({ app }) {
|
||||
app.component("ComponentPreview", Demo);
|
||||
app.component("DocsCopyButton", Button);
|
||||
app.component("DocsComponents", DocsComponents);
|
||||
app.component("DocsCopyIcon", IconCopy);
|
||||
app.component("DocsCheckIcon", IconCheck);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
/** Local manifest in pinned HeroUI meta.json order. Only real Vue pages belong here.
|
||||
* Sidebar, overview, breadcrumbs, previous/next and tests share this data. */
|
||||
export interface DocsItem {
|
||||
title: string;
|
||||
url: string;
|
||||
category?: string;
|
||||
}
|
||||
export interface DocsGroup {
|
||||
title: string;
|
||||
items: DocsItem[];
|
||||
}
|
||||
export const componentItems: DocsItem[] = [
|
||||
{
|
||||
title: "Accordion 手风琴",
|
||||
url: "/components/accordion",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Alert 警告",
|
||||
url: "/components/alert",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "AlertDialog 警告对话框",
|
||||
url: "/components/alert-dialog",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "Avatar 头像",
|
||||
url: "/components/avatar",
|
||||
category: "media",
|
||||
},
|
||||
{
|
||||
title: "AvatarGroup 头像组",
|
||||
url: "/components/avatar-group",
|
||||
category: "media",
|
||||
},
|
||||
{
|
||||
title: "Badge 徽章",
|
||||
url: "/components/badge",
|
||||
category: "data-display",
|
||||
},
|
||||
{
|
||||
title: "Breadcrumbs 面包屑",
|
||||
url: "/components/breadcrumbs",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Button 按钮",
|
||||
url: "/components/button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "ButtonGroup 按钮组",
|
||||
url: "/components/button-group",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "Card 卡片",
|
||||
url: "/components/card",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Checkbox 复选框",
|
||||
url: "/components/checkbox",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "CheckboxGroup 复选框组",
|
||||
url: "/components/checkbox-group",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Chip 标签",
|
||||
url: "/components/chip",
|
||||
category: "data-display",
|
||||
},
|
||||
{
|
||||
title: "CloseButton 关闭按钮",
|
||||
url: "/components/close-button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "DateField 日期字段",
|
||||
url: "/components/date-field",
|
||||
category: "date-and-time",
|
||||
},
|
||||
{
|
||||
title: "Description 描述",
|
||||
url: "/components/description",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Disclosure 折叠面板",
|
||||
url: "/components/disclosure",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "DisclosureGroup 折叠面板组",
|
||||
url: "/components/disclosure-group",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Drawer 抽屉",
|
||||
url: "/components/drawer",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "EmptyState 空状态",
|
||||
url: "/components/empty-state",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "FieldError 字段错误",
|
||||
url: "/components/field-error",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Fieldset 字段组",
|
||||
url: "/components/fieldset",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Header 标题",
|
||||
url: "/components/header",
|
||||
category: "typography",
|
||||
},
|
||||
{
|
||||
title: "Input 输入框",
|
||||
url: "/components/input",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "InputGroup 输入框组",
|
||||
url: "/components/input-group",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "InputOTP 验证码输入",
|
||||
url: "/components/input-otp",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Kbd 键盘按键",
|
||||
url: "/components/kbd",
|
||||
category: "typography",
|
||||
},
|
||||
{
|
||||
title: "Label 标签",
|
||||
url: "/components/label",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Link 链接",
|
||||
url: "/components/link",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "ListBox 列表框",
|
||||
url: "/components/list-box",
|
||||
category: "collections",
|
||||
},
|
||||
{
|
||||
title: "Meter 计量条",
|
||||
url: "/components/meter",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "Modal 模态框",
|
||||
url: "/components/modal",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "NumberField 数字输入框",
|
||||
url: "/components/number-field",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Pagination 分页",
|
||||
url: "/components/pagination",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Popover 弹出框",
|
||||
url: "/components/popover",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "ProgressBar 进度条",
|
||||
url: "/components/progress-bar",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "ProgressCircle 环形进度条",
|
||||
url: "/components/progress-circle",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "RadioGroup 单选框组",
|
||||
url: "/components/radio-group",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "ScrollShadow 滚动阴影",
|
||||
url: "/components/scroll-shadow",
|
||||
category: "utilities",
|
||||
},
|
||||
{
|
||||
title: "SearchField 搜索框",
|
||||
url: "/components/search-field",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Select 选择器",
|
||||
url: "/components/select",
|
||||
category: "pickers",
|
||||
},
|
||||
{
|
||||
title: "Separator 分隔符",
|
||||
url: "/components/separator",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Skeleton 骨架屏",
|
||||
url: "/components/skeleton",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "Slider 滑块",
|
||||
url: "/components/slider",
|
||||
category: "controls",
|
||||
},
|
||||
{
|
||||
title: "Spinner 加载指示器",
|
||||
url: "/components/spinner",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "Surface 表面",
|
||||
url: "/components/surface",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Switch 开关",
|
||||
url: "/components/switch",
|
||||
category: "controls",
|
||||
},
|
||||
{
|
||||
title: "Tabs 标签页",
|
||||
url: "/components/tabs",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "TextArea 多行文本框",
|
||||
url: "/components/textarea",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "TextField 文本输入框",
|
||||
url: "/components/text-field",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "ToggleButton 切换按钮",
|
||||
url: "/components/toggle-button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "ToggleButtonGroup 切换按钮组",
|
||||
url: "/components/toggle-button-group",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "Toolbar 工具栏",
|
||||
url: "/components/toolbar",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Tooltip 工具提示",
|
||||
url: "/components/tooltip",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "Typography 排版",
|
||||
url: "/components/typography",
|
||||
category: "typography",
|
||||
},
|
||||
];
|
||||
export const guideGroups: DocsGroup[] = [
|
||||
{
|
||||
title: "概述",
|
||||
items: [
|
||||
{ title: "介绍", url: "/introduction" },
|
||||
{ title: "快速开始", url: "/guide" },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "手册",
|
||||
items: [
|
||||
{ title: "主题", url: "/themes" },
|
||||
{ title: "字段与表单基础", url: "/fields" },
|
||||
],
|
||||
},
|
||||
];
|
||||
export const componentGroups: DocsGroup[] = [
|
||||
{ title: "概述", items: [{ title: "所有组件(Vue)", url: "/components" }] },
|
||||
{ title: "组件", items: componentItems },
|
||||
];
|
||||
export const categories = [
|
||||
["buttons", "按钮"],
|
||||
["collections", "集合"],
|
||||
["colors", "颜色"],
|
||||
["controls", "控件"],
|
||||
["data-display", "数据展示"],
|
||||
["date-and-time", "日期与时间"],
|
||||
["feedback", "反馈"],
|
||||
["forms", "表单"],
|
||||
["layout", "布局"],
|
||||
["media", "媒体"],
|
||||
["navigation", "导航"],
|
||||
["overlays", "浮层"],
|
||||
["pickers", "选择器"],
|
||||
["typography", "排版"],
|
||||
["utilities", "工具"],
|
||||
] as const;
|
||||
export function docsPath(path: string, base = "/") {
|
||||
let value = path.split(/[?#]/)[0];
|
||||
if (base !== "/" && value === base.replace(/\/$/, "")) value = "/";
|
||||
if (base !== "/" && value.startsWith(base))
|
||||
value = "/" + value.slice(base.length);
|
||||
value = value.replace(/\.html$/, "").replace(/\/$/, "");
|
||||
return !value || value === "/index" ? "/introduction" : value;
|
||||
}
|
||||
export function docsSection(path: string, base = "/"): "guide" | "components" {
|
||||
const normalized = docsPath(path, base);
|
||||
return normalized === "/components" || normalized.startsWith("/components/")
|
||||
? "components"
|
||||
: "guide";
|
||||
}
|
||||
export function adjacentPages(path: string, base = "/") {
|
||||
const groups =
|
||||
docsSection(path, base) === "components" ? componentGroups : guideGroups;
|
||||
const items = groups.flatMap((group) => group.items);
|
||||
const index = items.findIndex((item) => item.url === docsPath(path, base));
|
||||
return {
|
||||
previous: index > 0 ? items[index - 1] : undefined,
|
||||
next: index >= 0 ? items[index + 1] : undefined,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,689 @@
|
||||
/* Adapted from HeroUI ce90ea3 notebook layout + global.css; see docs/upstream.md.
|
||||
* Local routes/community version replace React/Native and unavailable services. */
|
||||
:root {
|
||||
--docs-width: 1400px;
|
||||
--docs-header-height: 96px;
|
||||
--docs-sidebar-width: 220px;
|
||||
--docs-toc-width: 240px;
|
||||
}
|
||||
html {
|
||||
scroll-padding-top: 154px;
|
||||
}
|
||||
.docs-layout {
|
||||
max-width: var(--docs-width);
|
||||
margin: auto;
|
||||
}
|
||||
.docs-nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 30;
|
||||
height: var(--docs-header-height);
|
||||
background: var(--background);
|
||||
}
|
||||
.docs-nav-main {
|
||||
height: 56px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr minmax(220px, 400px) 1fr;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 0 24px;
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-brand-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
.docs-nav .brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--foreground);
|
||||
font-size: 25px;
|
||||
font-weight: 800;
|
||||
letter-spacing: -1.4px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.docs-nav .brand .hv-chip {
|
||||
letter-spacing: 0;
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
}
|
||||
.docs-nav .version {
|
||||
padding: 4px 0;
|
||||
height: auto;
|
||||
min-width: 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.version-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 210px;
|
||||
}
|
||||
.version-panel p {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.version-panel .hv-link {
|
||||
font-size: 13px;
|
||||
gap: 6px;
|
||||
}
|
||||
.nav-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
.docs-github {
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-nav-sections {
|
||||
display: flex;
|
||||
height: 40px;
|
||||
align-items: flex-end;
|
||||
gap: 24px;
|
||||
padding: 0 24px;
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-nav-sections nav {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 24px;
|
||||
height: 100%;
|
||||
}
|
||||
.docs-nav-sections nav .hv-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 0 7px;
|
||||
height: 100%;
|
||||
border-bottom: 2px solid transparent;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--muted);
|
||||
border-radius: 0;
|
||||
}
|
||||
.docs-nav-sections nav .hv-link[aria-current="page"] {
|
||||
border-color: var(--foreground);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.docs-nav-sections .framework {
|
||||
margin: 0 0 6px auto;
|
||||
}
|
||||
.docs-theme-wide {
|
||||
padding: 2px;
|
||||
border-radius: 14px;
|
||||
background: var(--default);
|
||||
gap: 0;
|
||||
}
|
||||
.docs-theme-wide .hv-toggle-button {
|
||||
min-width: 28px;
|
||||
width: 28px;
|
||||
height: 26px;
|
||||
border: 0;
|
||||
border-radius: 12px;
|
||||
padding: 4px;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-theme-wide .hv-toggle-button[data-selected="true"] {
|
||||
background: var(--surface);
|
||||
color: var(--foreground);
|
||||
box-shadow: var(--surface-shadow);
|
||||
}
|
||||
.docs-theme-compact,
|
||||
.mobile-menu {
|
||||
display: none;
|
||||
}
|
||||
.docs-body {
|
||||
display: grid;
|
||||
grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr) var(
|
||||
--docs-toc-width
|
||||
);
|
||||
align-items: start;
|
||||
}
|
||||
.docs-sidebar {
|
||||
position: sticky;
|
||||
top: var(--docs-header-height);
|
||||
height: calc(100dvh - var(--docs-header-height));
|
||||
padding: 16px 0 8px 12px;
|
||||
}
|
||||
.docs-sidebar-scroll {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 8px 16px 16px 4px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: transparent transparent;
|
||||
}
|
||||
.docs-sidebar-scroll:hover,
|
||||
.docs-sidebar-scroll:focus-within {
|
||||
scrollbar-color: var(--muted) transparent;
|
||||
}
|
||||
.sidebar-tree section {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.sidebar-tree h2 {
|
||||
margin: 0;
|
||||
padding: 8px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.sidebar-tree .hv-link {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding: 7px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--muted);
|
||||
border-radius: var(--radius-field);
|
||||
word-break: keep-all;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.sidebar-tree .hv-link:hover {
|
||||
background: var(--default-soft);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.sidebar-tree .hv-link[aria-current="page"] {
|
||||
background: var(--surface);
|
||||
box-shadow: var(--surface-shadow);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.community {
|
||||
font-size: 11px;
|
||||
line-height: 1.8;
|
||||
color: var(--muted);
|
||||
padding: 16px 12px;
|
||||
}
|
||||
.docs-main {
|
||||
min-width: 0;
|
||||
padding: 32px 48px 64px;
|
||||
width: 100%;
|
||||
outline: none;
|
||||
}
|
||||
.docs-main > .page-description {
|
||||
font-size: 18px;
|
||||
line-height: 1.65;
|
||||
color: var(--muted);
|
||||
margin: 0 0 32px;
|
||||
}
|
||||
.docs-main > h1 {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
letter-spacing: -0.6px;
|
||||
margin: 16px 0;
|
||||
outline: none;
|
||||
}
|
||||
.docs-main .breadcrumb {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-main .breadcrumb .hv-link {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-main .breadcrumb [aria-current="page"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.source-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin: -12px 0 32px;
|
||||
}
|
||||
.source-links .hv-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 5px 9px;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 7px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.source-links .hv-link:hover {
|
||||
background: var(--default-soft);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.docs-toc {
|
||||
position: sticky;
|
||||
top: var(--docs-header-height);
|
||||
height: calc(100dvh - var(--docs-header-height));
|
||||
padding: 24px 16px 16px;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.docs-toc > p {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
.docs-toc-scroll {
|
||||
max-height: calc(100% - 40px);
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
.toc-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.toc-links .hv-link {
|
||||
display: block;
|
||||
padding: 6px 8px 6px 12px;
|
||||
line-height: 1.5;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.toc-links .hv-link.nested {
|
||||
padding-left: 24px;
|
||||
}
|
||||
.toc-links .hv-link:hover,
|
||||
.toc-links .hv-link[aria-current="location"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.mobile-toc {
|
||||
display: none;
|
||||
}
|
||||
.page-navigation {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
margin-top: 48px;
|
||||
}
|
||||
.page-navigation .hv-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 12px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.page-navigation .hv-card:hover {
|
||||
background: var(--default-soft);
|
||||
}
|
||||
.page-navigation span {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.page-navigation strong {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--foreground);
|
||||
}
|
||||
.page-navigation .page-next {
|
||||
grid-column: 2;
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
.docs-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-top: 28px;
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--docs-border);
|
||||
font-size: 12px;
|
||||
line-height: 1.8;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-footer .hv-link {
|
||||
font-size: 12px;
|
||||
}
|
||||
.components-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.component-index-card {
|
||||
padding: 18px;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 12px;
|
||||
}
|
||||
.component-index-card:hover {
|
||||
background: var(--default-soft);
|
||||
}
|
||||
.component-index-card .hv-card__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.component-index-card .hv-card__description {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.search-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
justify-content: flex-start;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
border-radius: 12px;
|
||||
background: var(--field);
|
||||
box-shadow: var(--field-shadow);
|
||||
}
|
||||
.search-trigger .hv-kbd {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
padding: 2px 5px;
|
||||
background: var(--default);
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
box-shadow: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.docs-search-container {
|
||||
padding-top: min(16vh, 120px);
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
.search-dialog {
|
||||
width: min(620px, calc(100vw - 32px));
|
||||
max-width: 620px;
|
||||
padding: 0;
|
||||
gap: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--overlay-shadow);
|
||||
}
|
||||
.search-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.docs-search-input .hv-search-field__group {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
}
|
||||
.docs-search-input .hv-search-field__input {
|
||||
font-size: 16px;
|
||||
padding: 8px 6px;
|
||||
}
|
||||
.search-close {
|
||||
padding: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.search-close .hv-kbd {
|
||||
font-size: 11px;
|
||||
border: 1px solid var(--docs-border);
|
||||
box-shadow: none;
|
||||
}
|
||||
.search-results {
|
||||
max-height: calc(65dvh - 100px);
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
.search-results .hv-link {
|
||||
display: block;
|
||||
padding: 12px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
color: var(--foreground);
|
||||
}
|
||||
.search-results .hv-link[aria-selected="true"] {
|
||||
background: var(--default);
|
||||
border-color: var(--docs-border);
|
||||
}
|
||||
.result-title {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.result-title > span {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: var(--muted);
|
||||
}
|
||||
.result-excerpt {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
margin-top: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: var(--muted);
|
||||
}
|
||||
.search-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 32px 16px;
|
||||
min-height: 150px;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
.search-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 18px;
|
||||
border-top: 1px solid var(--docs-border);
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.search-footer > span:last-child {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.search-footer .hv-kbd {
|
||||
font-size: 10px;
|
||||
box-shadow: none;
|
||||
border: 0;
|
||||
}
|
||||
.docs-drawer-dialog {
|
||||
width: min(340px, 88vw);
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
border-radius: 0;
|
||||
touch-action: auto !important;
|
||||
}
|
||||
.docs-drawer-heading {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.docs-drawer-heading [data-slot="drawer-close-trigger"] {
|
||||
position: static;
|
||||
}
|
||||
.mobile-section-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 4px 12px 16px;
|
||||
}
|
||||
.mobile-section-links .hv-link {
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.mobile-section-links [aria-current="page"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.mobile-toc-content {
|
||||
max-height: min(60dvh, 480px);
|
||||
width: min(340px, calc(100vw - 32px));
|
||||
overflow-y: auto;
|
||||
}
|
||||
.skip {
|
||||
position: fixed;
|
||||
top: -60px;
|
||||
left: 16px;
|
||||
z-index: 100;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--surface);
|
||||
}
|
||||
.skip:focus {
|
||||
top: 8px;
|
||||
}
|
||||
@media (max-width: 1279px) {
|
||||
.docs-body {
|
||||
grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr);
|
||||
}
|
||||
.docs-toc {
|
||||
display: none;
|
||||
}
|
||||
.docs-main {
|
||||
grid-column: 2;
|
||||
padding: 20px 24px 64px;
|
||||
}
|
||||
.mobile-toc {
|
||||
display: block;
|
||||
grid-column: 2;
|
||||
position: sticky;
|
||||
top: var(--docs-header-height);
|
||||
z-index: 15;
|
||||
padding: 4px 16px;
|
||||
background: var(--background);
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-sidebar {
|
||||
grid-row: 1 / span 2;
|
||||
}
|
||||
.version {
|
||||
display: none;
|
||||
}
|
||||
.docs-nav-main {
|
||||
grid-template-columns: 1fr minmax(180px, 360px) 1fr;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
:root {
|
||||
--docs-header-height: 92px;
|
||||
}
|
||||
.docs-nav-main {
|
||||
height: 56px;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.docs-nav-sections {
|
||||
height: 36px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.docs-nav-sections nav {
|
||||
gap: 20px;
|
||||
}
|
||||
.docs-nav-sections nav .hv-link {
|
||||
font-size: 13px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
.docs-sidebar {
|
||||
display: none;
|
||||
}
|
||||
.docs-body {
|
||||
display: block;
|
||||
}
|
||||
.docs-main {
|
||||
padding: 24px 20px 48px;
|
||||
}
|
||||
.docs-main > h1 {
|
||||
font-size: 28px;
|
||||
}
|
||||
.docs-main > .page-description {
|
||||
font-size: 16px;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
.docs-nav .brand {
|
||||
font-size: 23px;
|
||||
gap: 6px;
|
||||
}
|
||||
.nav-tools {
|
||||
gap: 4px;
|
||||
}
|
||||
.docs-github,
|
||||
.docs-theme-wide {
|
||||
display: none;
|
||||
}
|
||||
.docs-theme-compact,
|
||||
.mobile-menu {
|
||||
display: inline-flex;
|
||||
}
|
||||
.search-trigger {
|
||||
justify-self: end;
|
||||
min-width: 36px;
|
||||
width: 36px;
|
||||
padding: 8px;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
.search-trigger span,
|
||||
.search-trigger .hv-kbd {
|
||||
display: none;
|
||||
}
|
||||
.mobile-toc {
|
||||
top: var(--docs-header-height);
|
||||
padding: 4px 12px;
|
||||
}
|
||||
.docs-search-container {
|
||||
padding-top: 12px;
|
||||
}
|
||||
.search-dialog {
|
||||
max-height: calc(100dvh - 24px);
|
||||
}
|
||||
.search-results {
|
||||
max-height: calc(70dvh - 110px);
|
||||
}
|
||||
.source-links .hv-link {
|
||||
font-size: 11px;
|
||||
}
|
||||
.components-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.page-navigation .hv-card {
|
||||
padding: 12px;
|
||||
}
|
||||
.page-navigation strong {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
}
|
||||
.component-index-card:focus-visible,
|
||||
.page-navigation a:focus-visible {
|
||||
outline: 2px solid var(--focus);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user