docs: complete handbook and prepare component verification tasks
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<script setup lang="ts">
|
||||
// Adapted from HeroUI ce90ea3 apps/docs/src/components/color-section.tsx.
|
||||
// Copyright 2025 NextUI Inc. Apache-2.0; see third-party/HEROUI-LICENSE.
|
||||
// Vue DOM/CSS token display; copying keeps the browser's resolved CSS color.
|
||||
import { ref } from "vue";
|
||||
import { Button, Tooltip, TooltipContent } from "@heroui-vue/components";
|
||||
defineProps<{ name: string; tokens: string[] }>();
|
||||
const message = ref("");
|
||||
async function copy(event: MouseEvent, token: string) {
|
||||
const value = getComputedStyle(
|
||||
event.currentTarget as HTMLElement,
|
||||
).backgroundColor;
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
message.value = `已复制 ${token}: ${value}`;
|
||||
} catch {
|
||||
message.value = `无法复制,请使用变量 ${token}`;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="docs-color-section not-prose">
|
||||
<div
|
||||
v-for="theme in ['light', 'dark']"
|
||||
:key="theme"
|
||||
:data-theme="theme"
|
||||
class="docs-color-column"
|
||||
>
|
||||
<div class="docs-color-header">
|
||||
<strong>{{ name }}</strong>
|
||||
<span>{{ theme === "light" ? "Light" : "Dark" }}</span>
|
||||
</div>
|
||||
<Tooltip v-for="token in tokens" :key="token" :delay="0">
|
||||
<Button
|
||||
variant="ghost"
|
||||
class="docs-color-token"
|
||||
:style="{ backgroundColor: `var(${token})` }"
|
||||
:aria-label="`复制 ${theme} ${token}`"
|
||||
@click="copy($event, token)"
|
||||
>
|
||||
<span>{{ token }}</span>
|
||||
</Button>
|
||||
<TooltipContent>
|
||||
{{ token }} · 点击复制浏览器解析后的颜色值
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<span class="docs-color-message" role="status">{{ message }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.docs-color-section {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-block: 20px;
|
||||
}
|
||||
.docs-color-column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
background: var(--surface);
|
||||
color: var(--foreground);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.docs-color-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.docs-color-header span {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-color-token {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
min-height: 48px;
|
||||
padding: 12px;
|
||||
justify-content: start;
|
||||
border-radius: 12px;
|
||||
border: 1px solid color-mix(in oklab, var(--foreground) 12%, transparent);
|
||||
}
|
||||
.docs-color-token span {
|
||||
background: inherit;
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
color: transparent;
|
||||
filter: invert(1) grayscale(1) contrast(100);
|
||||
font-size: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
white-space: normal;
|
||||
}
|
||||
.docs-color-message {
|
||||
grid-column: 1 / -1;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.docs-color-section {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,6 +2,7 @@ import type { Theme } from "vitepress";
|
||||
import { IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import DocsComponents from "./DocsComponents.vue";
|
||||
import DocsColorSection from "./DocsColorSection.vue";
|
||||
import Layout from "./Layout.vue";
|
||||
import Demo from "./Demo.vue";
|
||||
import "@heroui-vue/styles/css";
|
||||
@@ -14,6 +15,7 @@ export default {
|
||||
app.component("ComponentPreview", Demo);
|
||||
app.component("DocsCopyButton", Button);
|
||||
app.component("DocsComponents", DocsComponents);
|
||||
app.component("DocsColorSection", DocsColorSection);
|
||||
app.component("DocsCopyIcon", IconCopy);
|
||||
app.component("DocsCheckIcon", IconCheck);
|
||||
},
|
||||
|
||||
@@ -392,7 +392,12 @@ export const guideGroups: DocsGroup[] = [
|
||||
{
|
||||
title: "手册",
|
||||
items: [
|
||||
{ title: "颜色", url: "/colors" },
|
||||
{ title: "主题", url: "/themes" },
|
||||
{ title: "深色模式", url: "/dark-mode" },
|
||||
{ title: "样式", url: "/styling" },
|
||||
{ title: "动画", url: "/animation" },
|
||||
{ title: "组合", url: "/composition" },
|
||||
{ title: "字段与表单基础", url: "/fields" },
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user