feat: add Separator Kbd and Chip components

This commit is contained in:
maoyingjie
2026-10-21 18:35:24 +08:00
parent 3d05fea7bd
commit 3515a47f5e
51 changed files with 2813 additions and 21 deletions
+7 -2
View File
@@ -1,5 +1,10 @@
<script setup lang="ts">
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
import {
Avatar,
AvatarImage,
AvatarFallback,
Separator,
} from "@heroui-vue/components";
import { IconUser } from "@tabler/icons-vue";
const colors = ["accent", "default", "success", "warning", "danger"] as const;
@@ -44,7 +49,7 @@ const variants = [
</div>
</div>
<div class="h-px w-full bg-separator" />
<Separator />
<!-- 变体行 -->
<div
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { Chip } from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-wrap items-center gap-3">
<Chip>默认</Chip>
<Chip color="accent">强调</Chip>
<Chip color="success">成功</Chip>
<Chip color="warning">警告</Chip>
<Chip color="danger">危险</Chip>
</div>
</template>
+23
View File
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { Chip } from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-wrap items-center gap-2">
<Chip
class="rounded-full bg-default-soft px-3 text-default-soft-foreground"
>
草稿
</Chip>
<Chip
class="rounded-full bg-warning-soft px-3 text-warning-soft-foreground"
>
审核中
</Chip>
<Chip
class="rounded-full bg-success-soft px-3 text-success-soft-foreground"
>
已发布
</Chip>
</div>
</template>
+52
View File
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { Chip, ChipLabel } from "@heroui-vue/components";
import {
IconBan,
IconCheck,
IconCircleFilled,
IconInfoCircle,
IconAlertTriangle,
} from "@tabler/icons-vue";
</script>
<template>
<div class="flex flex-col gap-4">
<div class="flex flex-wrap items-center gap-3">
<Chip variant="primary">
<IconCircleFilled :size="6" aria-hidden="true" />
<ChipLabel>默认</ChipLabel>
</Chip>
<Chip color="success" variant="primary">
<IconCircleFilled :size="6" aria-hidden="true" />
<ChipLabel>活跃</ChipLabel>
</Chip>
<Chip color="warning" variant="primary">
<IconCircleFilled :size="6" aria-hidden="true" />
<ChipLabel>待处理</ChipLabel>
</Chip>
<Chip color="danger" variant="primary">
<IconCircleFilled :size="6" aria-hidden="true" />
<ChipLabel>未激活</ChipLabel>
</Chip>
</div>
<div class="flex flex-wrap items-center gap-3">
<Chip>
<IconInfoCircle :size="12" aria-hidden="true" />
<ChipLabel>新功能</ChipLabel>
</Chip>
<Chip color="success">
<IconCheck :size="12" aria-hidden="true" />
<ChipLabel>可用</ChipLabel>
</Chip>
<Chip color="warning">
<IconAlertTriangle :size="12" aria-hidden="true" />
<ChipLabel>测试版</ChipLabel>
</Chip>
<Chip color="danger">
<IconBan :size="12" aria-hidden="true" />
<ChipLabel>已弃用</ChipLabel>
</Chip>
</div>
</div>
</template>
+78
View File
@@ -0,0 +1,78 @@
<script setup lang="ts">
import { Chip, ChipLabel, Separator } from "@heroui-vue/components";
import { IconCircleDashed } from "@tabler/icons-vue";
const sizes = ["lg", "md", "sm"] as const;
const SIZE_LABELS: Record<(typeof sizes)[number], string> = {
lg: "大",
md: "中",
sm: "小",
};
const variants = ["primary", "secondary", "tertiary", "soft"] as const;
const VARIANT_LABELS: Record<(typeof variants)[number], string> = {
primary: "主要",
secondary: "次要",
soft: "柔和",
tertiary: "第三",
};
const colors = ["accent", "default", "success", "warning", "danger"] as const;
const COLOR_LABELS: Record<(typeof colors)[number], string> = {
accent: "强调",
danger: "危险",
default: "默认",
success: "成功",
warning: "警告",
};
</script>
<template>
<div class="flex flex-col gap-8 overflow-x-auto">
<template v-for="(size, index) in sizes" :key="size">
<div class="flex flex-col gap-4">
<h3 class="text-sm font-semibold text-muted">
{{ SIZE_LABELS[size] }}
</h3>
<div class="flex items-center gap-3">
<div class="w-24 shrink-0" />
<div
v-for="color in colors"
:key="color"
class="flex shrink-0 items-center justify-center"
style="width: 130px"
>
<span class="text-xs text-muted">{{ COLOR_LABELS[color] }}</span>
</div>
</div>
<div class="flex flex-col gap-3">
<div
v-for="variant in variants"
:key="variant"
class="flex items-center gap-3"
>
<div class="w-24 shrink-0 text-sm text-muted">
{{ VARIANT_LABELS[variant] }}
</div>
<div
v-for="color in colors"
:key="color"
class="flex shrink-0 items-center justify-center"
style="width: 130px"
>
<Chip :color="color" :size="size" :variant="variant">
<IconCircleDashed aria-hidden="true" />
<ChipLabel>标签</ChipLabel>
<IconCircleDashed aria-hidden="true" />
</Chip>
</div>
</div>
</div>
</div>
<Separator v-if="index < sizes.length - 1" />
</template>
</div>
</template>
+35
View File
@@ -0,0 +1,35 @@
<script setup lang="ts">
import { Chip, ChipLabel } from "@heroui-vue/components";
import {
IconChevronDown,
IconCircleCheckFilled,
IconCircleFilled,
IconClock,
IconX,
} from "@tabler/icons-vue";
</script>
<template>
<div class="flex flex-wrap items-center gap-3">
<Chip>
<IconCircleFilled :size="6" aria-hidden="true" />
<ChipLabel>信息</ChipLabel>
</Chip>
<Chip color="success">
<IconCircleCheckFilled :size="12" aria-hidden="true" />
<ChipLabel>已完成</ChipLabel>
</Chip>
<Chip color="warning">
<IconClock :size="12" aria-hidden="true" />
<ChipLabel>待处理</ChipLabel>
</Chip>
<Chip color="danger">
<IconX :size="12" aria-hidden="true" />
<ChipLabel>失败</ChipLabel>
</Chip>
<Chip color="accent">
<ChipLabel>标签</ChipLabel>
<IconChevronDown :size="12" aria-hidden="true" />
</Chip>
</div>
</template>
+24
View File
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-4">
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>K</KbdContent>
</Kbd>
<Kbd>
<KbdAbbr key-value="shift" />
<KbdContent>P</KbdContent>
</Kbd>
<Kbd>
<KbdAbbr key-value="ctrl" />
<KbdContent>C</KbdContent>
</Kbd>
<Kbd>
<KbdAbbr key-value="option" />
<KbdContent>D</KbdContent>
</Kbd>
</div>
</template>
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-3">
<Kbd class="rounded-lg bg-accent-soft px-2.5 text-accent-soft-foreground">
<KbdAbbr key-value="command" />
<KbdContent>K</KbdContent>
</Kbd>
<Kbd class="rounded-lg bg-default px-2.5 text-muted">
<KbdAbbr key-value="shift" />
<KbdContent>P</KbdContent>
</Kbd>
</div>
</template>
+42
View File
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
</script>
<template>
<div class="space-y-4">
<p class="text-sm">
按
<Kbd>
<KbdContent>Esc</KbdContent>
</Kbd>
关闭对话框。
</p>
<p class="text-sm">
使用
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>K</KbdContent>
</Kbd>
打开命令面板。
</p>
<p class="text-sm">
使用
<Kbd>
<KbdAbbr key-value="up" />
</Kbd>
和
<Kbd>
<KbdAbbr key-value="down" />
</Kbd>
方向键进行导航。
</p>
<p class="text-sm">
使用
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>S</KbdContent>
</Kbd>
定期保存你的工作。
</p>
</div>
</template>
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
</script>
<template>
<div class="space-y-3">
<div class="rounded-lg bg-surface p-4">
<h4 class="mb-2 text-sm font-semibold">快捷操作</h4>
<ul class="space-y-2 text-sm">
<li>
• 打开搜索:
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>K</KbdContent>
</Kbd>
</li>
<li>
• 切换侧边栏:
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>B</KbdContent>
</Kbd>
</li>
<li>
• 新建文件:
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>N</KbdContent>
</Kbd>
</li>
<li>
• 快速保存:
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>S</KbdContent>
</Kbd>
</li>
</ul>
</div>
</div>
</template>
+42
View File
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { Kbd, KbdAbbr } from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-col gap-4">
<div class="flex items-center gap-2">
<span class="text-sm text-muted">方向键:</span>
<div class="flex items-center gap-2">
<Kbd>
<KbdAbbr key-value="up" />
</Kbd>
<Kbd>
<KbdAbbr key-value="down" />
</Kbd>
<Kbd>
<KbdAbbr key-value="left" />
</Kbd>
<Kbd>
<KbdAbbr key-value="right" />
</Kbd>
</div>
</div>
<div class="flex items-center gap-2">
<span class="text-sm text-muted">页面导航:</span>
<div class="flex items-center gap-2">
<Kbd>
<KbdAbbr key-value="pageup" />
</Kbd>
<Kbd>
<KbdAbbr key-value="pagedown" />
</Kbd>
<Kbd>
<KbdAbbr key-value="home" />
</Kbd>
<Kbd>
<KbdAbbr key-value="end" />
</Kbd>
</div>
</div>
</div>
</template>
+38
View File
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { Kbd, KbdAbbr } from "@heroui-vue/components";
</script>
<template>
<div class="space-y-3">
<p class="text-sm">
按
<Kbd>
<KbdAbbr key-value="enter" />
</Kbd>
确认,或按
<Kbd>
<KbdAbbr key-value="escape" />
</Kbd>
取消。
</p>
<p class="text-sm">
使用
<Kbd>
<KbdAbbr key-value="tab" />
</Kbd>
在表单字段间切换,使用
<Kbd>
<KbdAbbr key-value="shift" />
<KbdAbbr key-value="tab" />
</Kbd>
返回上一项。
</p>
<p class="text-sm">
按住
<Kbd>
<KbdAbbr key-value="space" />
</Kbd>
可临时启用平移模式。
</p>
</div>
</template>
+65
View File
@@ -0,0 +1,65 @@
<script setup lang="ts">
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-col gap-4">
<div class="flex items-center gap-2">
<span>复制:</span>
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>C</KbdContent>
</Kbd>
<Kbd variant="light">
<KbdAbbr key-value="command" />
<KbdContent>C</KbdContent>
</Kbd>
</div>
<div class="flex items-center gap-2">
<span>粘贴:</span>
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>V</KbdContent>
</Kbd>
<Kbd variant="light">
<KbdAbbr key-value="command" />
<KbdContent>V</KbdContent>
</Kbd>
</div>
<div class="flex items-center gap-2">
<span>剪切:</span>
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>X</KbdContent>
</Kbd>
<Kbd variant="light">
<KbdAbbr key-value="command" />
<KbdContent>X</KbdContent>
</Kbd>
</div>
<div class="flex items-center gap-2">
<span>撤销:</span>
<Kbd>
<KbdAbbr key-value="command" />
<KbdContent>Z</KbdContent>
</Kbd>
<Kbd variant="light">
<KbdAbbr key-value="command" />
<KbdContent>Z</KbdContent>
</Kbd>
</div>
<div class="flex items-center gap-2">
<span>重做:</span>
<Kbd>
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>Z</KbdContent>
</Kbd>
<Kbd variant="light">
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>Z</KbdContent>
</Kbd>
</div>
</div>
</template>
+22
View File
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { Separator } from "@heroui-vue/components";
</script>
<template>
<div class="max-w-md">
<div class="space-y-1">
<h4 class="text-medium font-medium">HeroUI v3 组件</h4>
<p class="text-small text-default-400">
美观、快速、现代的 React UI 库。
</p>
</div>
<Separator class="my-4" />
<div class="text-small flex h-5 items-center space-x-4">
<div>博客</div>
<Separator orientation="vertical" />
<div>文档</div>
<Separator orientation="vertical" />
<div>源码</div>
</div>
</div>
</template>
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { Separator } from "@heroui-vue/components";
</script>
<template>
<div class="max-w-xs space-y-4">
<p class="text-sm font-medium text-foreground">账户设置</p>
<Separator class="bg-separator-secondary" />
<div class="flex items-center gap-3 text-sm text-muted">
<span>个人资料</span>
<Separator class="h-4 bg-separator" orientation="vertical" />
<span>账单</span>
<Separator class="h-4 bg-separator" orientation="vertical" />
<span>安全</span>
</div>
</div>
</template>
@@ -0,0 +1,28 @@
<script setup lang="ts">
import { Separator } from "@heroui-vue/components";
</script>
<template>
<div class="max-w-md">
<div class="space-y-1">
<h4 class="text-medium font-medium">HeroUI v3 组件</h4>
<p class="text-small text-default-400">
美观、快速、现代的 React UI 库。
</p>
</div>
<Separator class="my-4" as-child>
<div data-custom="foo"></div>
</Separator>
<div class="text-small flex h-5 items-center space-x-4">
<div>博客</div>
<Separator orientation="vertical" as-child>
<div data-custom="foo"></div>
</Separator>
<div>文档</div>
<Separator orientation="vertical" as-child>
<div data-custom="foo"></div>
</Separator>
<div>源码</div>
</div>
</div>
</template>
+14
View File
@@ -0,0 +1,14 @@
<script setup lang="ts">
import { Separator } from "@heroui-vue/components";
</script>
<template>
<div class="flex max-w-md flex-col items-center gap-3">
<div>默认变体</div>
<Separator variant="default" />
<div>次要变体</div>
<Separator variant="secondary" />
<div>第三变体</div>
<Separator variant="tertiary" />
</div>
</template>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { Separator } from "@heroui-vue/components";
</script>
<template>
<div class="text-small flex h-5 items-center space-x-4">
<div>博客</div>
<Separator orientation="vertical" />
<div>文档</div>
<Separator orientation="vertical" />
<div>源码</div>
</div>
</template>
@@ -0,0 +1,39 @@
<script setup lang="ts">
import { Separator } from "@heroui-vue/components";
const items = [
{
iconUrl:
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/3dicons/bell-small.png",
subtitle: "接收账户活动更新",
title: "设置通知",
},
{
iconUrl:
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/3dicons/compass-small.png",
subtitle: "将浏览器连接到你的账户",
title: "设置浏览器扩展",
},
{
iconUrl:
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/3dicons/mint-collective-small.png",
subtitle: "创建你的第一件收藏品",
title: "铸造收藏品",
},
];
</script>
<template>
<div class="max-w-md space-y-4">
<div v-for="(item, index) in items" :key="item.title">
<div class="flex items-center gap-3">
<img :alt="item.title" class="size-12" :src="item.iconUrl" />
<div class="flex-1 space-y-0">
<h4 class="text-small font-medium">{{ item.title }}</h4>
<p class="text-sm text-muted">{{ item.subtitle }}</p>
</div>
</div>
<Separator v-if="index < items.length - 1" class="my-4" />
</div>
</div>
</template>
@@ -0,0 +1,51 @@
<script setup lang="ts">
import { Separator, Surface } from "@heroui-vue/components";
</script>
<template>
<div class="flex flex-col gap-8">
<div class="flex flex-col gap-2">
<Surface
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
variant="default"
>
<h3 class="text-base font-semibold text-foreground">默认表面</h3>
<Separator />
<p class="text-sm text-muted">表面内容</p>
</Surface>
</div>
<div class="flex flex-col gap-2">
<Surface
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
variant="secondary"
>
<h3 class="text-base font-semibold text-foreground">次要表面</h3>
<Separator variant="secondary" />
<p class="text-sm text-muted">表面内容</p>
</Surface>
</div>
<div class="flex flex-col gap-2">
<Surface
class="flex min-w-[320px] flex-col gap-3 rounded-3xl p-6"
variant="tertiary"
>
<h3 class="text-base font-semibold text-foreground">第三表面</h3>
<Separator variant="tertiary" />
<p class="text-sm text-muted">表面内容</p>
</Surface>
</div>
<div class="flex flex-col gap-2">
<Surface
class="flex min-w-[320px] flex-col gap-3 rounded-3xl border p-6"
variant="transparent"
>
<h3 class="text-base font-semibold text-foreground">透明表面</h3>
<Separator />
<p class="text-sm text-muted">表面内容</p>
</Surface>
</div>
</div>
</template>