feat: add CloseButton Avatar and Skeleton components
This commit is contained in:
@@ -260,6 +260,9 @@ Vaul Vue 官方已说明停止维护并推荐 Reka Drawer;新项目不采用 V
|
||||
- Shiki 生成 token 不等于页面已高亮。浅色需应用 `--shiki-light`,深色需应用 `--shiki-dark`,通过浏览器计算颜色验证;不只查看是否存在 span。
|
||||
- 高亮在构建/服务端生成,展开时按需加载,复制读取原始 SFC;高亮资源失败时仍提供可读源码。热更新同时失效原始源码与高亮模块,避免显示旧代码。
|
||||
- 文档检查包括展开/收起、复制反馈、键盘搜索与章节跳转、移动目录、深浅切换和 API 表格实际渲染。Markdown 表格被空行断开等问题,类型检查不会发现。
|
||||
- 文档正文中的 API、事件、插槽、状态与其他说明表格统一铺满正文内容区;内容少时不收缩,内容多时自动换行,不要求横向拖动,也不缩小字号、截断或省略内容。
|
||||
- 复用 `apps/docs/.vitepress/theme/style.css` 的公共表格规则:`display: table`、`width: 100%`、`table-layout: fixed`;表头、单元格与行内代码允许换行,长标识符使用 `overflow-wrap: anywhere`。不要恢复 `display: block`、强制 `nowrap` 或撑宽表格的最小列宽;正文规则排除 `.not-prose`,避免影响演示组件。
|
||||
- 表格验收按 [迁移任务拆分与复核约定](docs/migration-handoff.md#文档表格排版与验收) 执行:真实浏览器同时检查长类型 API 表和短内容插槽表,覆盖桌面与窄屏,确认铺满内容区、无水平溢出及内容完整;修改公共规则时回归已有组件页和指南页。
|
||||
|
||||
### 开发预览必须可靠
|
||||
|
||||
|
||||
@@ -44,10 +44,14 @@ const groups = [
|
||||
{
|
||||
title: "组件",
|
||||
items: [
|
||||
{ title: "Avatar 头像", url: "/components/avatar" },
|
||||
{ title: "AvatarGroup 头像组", url: "/components/avatar-group" },
|
||||
{ title: "Button 按钮", url: "/components/button" },
|
||||
{ title: "Card 卡片", url: "/components/card" },
|
||||
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
|
||||
{ title: "Input 输入框", url: "/components/input" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "Skeleton 骨架屏", url: "/components/skeleton" },
|
||||
{ title: "Spinner 加载指示器", url: "/components/spinner" },
|
||||
{ title: "Surface 表面", url: "/components/surface" },
|
||||
{ title: "Switch 开关", url: "/components/switch" },
|
||||
|
||||
@@ -13,3 +13,49 @@
|
||||
@slot;
|
||||
}
|
||||
}
|
||||
|
||||
/* Demo-only utilities ported from the baseline docs global.css. */
|
||||
@keyframes shine {
|
||||
0% {
|
||||
translate: -100% 0;
|
||||
}
|
||||
100% {
|
||||
translate: 100% 0;
|
||||
}
|
||||
}
|
||||
|
||||
@utility shadow-panel {
|
||||
box-shadow: var(--surface-shadow);
|
||||
}
|
||||
|
||||
@utility animate-shine {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
120deg,
|
||||
transparent 10%,
|
||||
rgba(255, 255, 255, 0.3) 45%,
|
||||
rgba(255, 255, 255, 0.1) 55%,
|
||||
transparent 90%
|
||||
);
|
||||
animation: shine 3s ease-in-out infinite;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *)::after {
|
||||
background: linear-gradient(
|
||||
120deg,
|
||||
transparent 10%,
|
||||
rgba(255, 255, 255, 0.1) 45%,
|
||||
rgba(255, 255, 255, 0.04) 55%,
|
||||
transparent 90%
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@ title: 组件
|
||||
description: 已迁移组件及文档
|
||||
---
|
||||
|
||||
- [Avatar 头像](./components/avatar)
|
||||
- [AvatarGroup 头像组](./components/avatar-group)
|
||||
- [Button 按钮](./components/button)
|
||||
- [Card 卡片](./components/card)
|
||||
- [CloseButton 关闭按钮](./components/close-button)
|
||||
- [Input 输入框](./components/input)
|
||||
- [Link 链接](./components/link)
|
||||
- [Skeleton 骨架屏](./components/skeleton)
|
||||
- [Spinner 加载指示器](./components/spinner)
|
||||
- [Surface 表面](./components/surface)
|
||||
- [Switch 开关](./components/switch)
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
---
|
||||
title: AvatarGroup 头像组
|
||||
description: 以叠放或网格展示多个头像,并支持溢出计数
|
||||
component: avatar-group
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="avatar-group-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AvatarGroup>
|
||||
<Avatar>
|
||||
<AvatarImage />
|
||||
<AvatarFallback />
|
||||
</Avatar>
|
||||
<AvatarGroupCount><!-- 可选的显式子组件 --></AvatarGroupCount>
|
||||
</AvatarGroup>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 最大数量
|
||||
|
||||
<ComponentPreview name="avatar-group-max" />
|
||||
|
||||
### 自定义计数
|
||||
|
||||
<ComponentPreview name="avatar-group-count" />
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="avatar-group-sizes" />
|
||||
|
||||
### 网格
|
||||
|
||||
<ComponentPreview name="avatar-group-grid" />
|
||||
|
||||
### 叠放样式(Overlap)
|
||||
|
||||
<ComponentPreview name="avatar-group-overlap" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="avatar-group-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 AvatarGroup 组件类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-avatar-group {
|
||||
--avatar-group-overlap: 0.75rem;
|
||||
--avatar-group-seam: 2px;
|
||||
}
|
||||
|
||||
.hv-avatar-group__count {
|
||||
@apply font-semibold;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
AvatarGroup 组件使用以下 CSS 类:
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-avatar-group` - 头像组基础容器
|
||||
- `.hv-avatar-group--grid` - 网格布局修饰符(无叠放)
|
||||
- `.hv-avatar-group--clip` - 新月裁切 / 透明缝(默认叠放)
|
||||
- `.hv-avatar-group--ring` - 通过 `--background` 的实线 box-shadow 描边
|
||||
- `.hv-avatar-group__count` - 溢出计数头像
|
||||
|
||||
叠放布局在兄弟元素之间使用负外边距(`--avatar-group-overlap`,默认 `0.5rem`)。clip 模式对非末子头像做遮罩,并光学微调 fallback 字形;ring 模式使用 `--background` 细线 box-shadow 描边。
|
||||
|
||||
## API 参考
|
||||
|
||||
### AvatarGroup
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | ------------------------------------------------------------- | -------- | -------------------------------------------------------------------------- |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 当子 Avatar 未指定 `size` 时应用到子头像(及溢出计数);默认与 Avatar 一致 |
|
||||
| `color` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | - | 当子 Avatar 未指定 `color` 时,应用到子头像(及溢出计数)的颜色 |
|
||||
| `variant` | `'default' \| 'soft'` | - | 当子 Avatar 未指定 `variant` 时,应用到子头像(及溢出计数)的变体 |
|
||||
| `max` | `number` | - | 最多渲染的头像子项数量;省略则显示全部 |
|
||||
| `isGrid` | `boolean` | `false` | 是否使用无叠放的换行网格布局 |
|
||||
| `overlap` | `'clip' \| 'ring'` | `'clip'` | 叠放样式:新月裁切(默认)或 box-shadow 描边;`isGrid` 时忽略 |
|
||||
| `class` | `string` | - | 附加 CSS 类 |
|
||||
| 默认插槽 | `Avatar[] \| AvatarGroupCount` | - | 要组合的 Avatar 组件(以及可选的 `AvatarGroupCount`) |
|
||||
|
||||
### AvatarGroupCount
|
||||
|
||||
由 `Avatar` + `AvatarFallback` 组合而成,用于溢出指示。不受 `max` 截断。
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | ------------------------------------------------------------- | ------ | --------------------- |
|
||||
| 默认插槽 | `string \| Component` | - | 计数内容(例如 `+3`) |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | - | 覆盖组的尺寸 |
|
||||
| `color` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | - | 覆盖组的颜色 |
|
||||
| `variant` | `'default' \| 'soft'` | - | 覆盖组的变体 |
|
||||
| `class` | `string` | - | 附加 CSS 类 |
|
||||
|
||||
## 注意事项
|
||||
|
||||
- AvatarGroup 通过 provide/inject 仅向**直接 Avatar 子组件**传递 `size`、`color` 与 `variant`
|
||||
- 设置 `max` 会截断可见头像并根据剩余子项自动计数;省略则显示全部
|
||||
- 已知总量(例如来自服务端)时,渲染显式的 `AvatarGroupCount` — 它不受 `max` 截断,并会抑制自动计数。请用 `Count` 替代已移除的 v2 `total`
|
||||
- `isGrid` 会禁用叠放,改为换行网格布局
|
||||
- `overlap` 默认为 `"clip"`(新月裁切);使用 `"ring"` 可改为实线描边;与 `isGrid` 同时使用时无效
|
||||
- 默认不加 `role="group"` — 当叠放有语义(指派人、在看的人)时,自行加上 `role="group"`,并配合 `aria-label` 或 `aria-labelledby`
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Avatar 头像](./avatar) · [Card 卡片](./card)
|
||||
@@ -0,0 +1,149 @@
|
||||
---
|
||||
title: Avatar 头像
|
||||
description: 显示用户头像,支持自定义 fallback 内容
|
||||
component: avatar
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="avatar-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Avatar>
|
||||
<AvatarImage />
|
||||
<AvatarFallback />
|
||||
</Avatar>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="avatar-sizes" />
|
||||
|
||||
### 颜色
|
||||
|
||||
<ComponentPreview name="avatar-colors" />
|
||||
|
||||
### 变体
|
||||
|
||||
<ComponentPreview name="avatar-variants" />
|
||||
|
||||
### 回退内容
|
||||
|
||||
<ComponentPreview name="avatar-fallback" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### 自定义图片组件
|
||||
|
||||
在 `AvatarImage` 上使用 `as-child`,即可与自定义图片组件组合。请将 `src` 传给 `AvatarImage`,以便跟踪加载状态,并在图片就绪前显示回退内容。
|
||||
|
||||
<ComponentPreview name="avatar-custom-image-component" />
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="avatar-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 Avatar 组件类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-avatar {
|
||||
@apply size-16 border-2 border-accent;
|
||||
}
|
||||
|
||||
.hv-avatar__fallback {
|
||||
@apply bg-gradient-to-br from-purple-500 to-pink-500;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Avatar 组件使用以下 CSS 类:
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-avatar` - 基础容器,默认尺寸(size-10)
|
||||
- `.hv-avatar__image` - 图片元素,aspect-square 尺寸
|
||||
- `.hv-avatar__fallback` - 居中内容的 fallback 容器
|
||||
|
||||
#### 尺寸修饰符 [!toc]
|
||||
|
||||
- `.hv-avatar--sm` - 小头像(size-8)
|
||||
- `.hv-avatar--md` - 中头像(默认,无额外样式)
|
||||
- `.hv-avatar--lg` - 大头像(size-12)
|
||||
|
||||
#### 变体修饰符 [!toc]
|
||||
|
||||
- `.hv-avatar--soft` - 浅色背景的 soft 变体
|
||||
|
||||
#### 颜色修饰符 [!toc]
|
||||
|
||||
- `.hv-avatar__fallback--default` - 默认文字颜色
|
||||
- `.hv-avatar__fallback--accent` - 强调色文字
|
||||
- `.hv-avatar__fallback--success` - 成功色文字
|
||||
- `.hv-avatar__fallback--warning` - 警告色文字
|
||||
- `.hv-avatar__fallback--danger` - 危险色文字
|
||||
|
||||
## API 参考
|
||||
|
||||
### Avatar
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | ------------------------------------------------------------- | ----------- | ----------------- |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 头像尺寸 |
|
||||
| `color` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | `'default'` | Fallback 颜色主题 |
|
||||
| `variant` | `'default' \| 'soft'` | `'default'` | 视觉样式变体 |
|
||||
| `class` | `string` | - | 附加 CSS 类 |
|
||||
|
||||
### AvatarImage
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------- | ---------------------------------- | ------- | ------------------------------------------ |
|
||||
| `src` | `string` | - | 图片 URL |
|
||||
| `srcSet` | `string` | - | 响应式图片的 `srcset` 属性 |
|
||||
| `sizes` | `string` | - | 响应式图片的 `sizes` 属性 |
|
||||
| `alt` | `string` | - | 图片替代文本 |
|
||||
| `asChild` | `boolean` | `false` | 将属性合并到子元素上,而不是渲染原生 `img` |
|
||||
| `@load` | `(event: Event) => void` | - | 图片加载成功时的回调 |
|
||||
| `@error` | `(event: Event) => void` | - | 图片加载失败时的回调 |
|
||||
| `crossOrigin` | `'anonymous' \| 'use-credentials'` | - | 图片请求的 CORS 设置 |
|
||||
| `loading` | `'eager' \| 'lazy'` | - | 原生懒加载属性 |
|
||||
| `class` | `string` | - | 附加 CSS 类 |
|
||||
|
||||
### AvatarFallback
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | ------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| `delayMs` | `number` | - | 显示 fallback 前的延迟(防止闪烁)。`0` 与未指定不同:底座在 `delayMs=0` 时不会显示 fallback,需要延迟时请传正数 |
|
||||
| `color` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | - | 覆盖父级颜色(替换而非叠加) |
|
||||
| `class` | `string` | - | 附加 CSS 类 |
|
||||
|
||||
Avatar 使用 Reka UI 的 `AvatarRoot` / `AvatarImage` / `AvatarFallback` 处理加载与回退状态。`onLoad` / `onError` 对应 Vue 原生 `@load` / `@error` 事件,不声明与 React 合成事件完全等价。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[AvatarGroup 头像组](./avatar-group) · [Card 卡片](./card)
|
||||
@@ -0,0 +1,109 @@
|
||||
---
|
||||
title: CloseButton 关闭按钮
|
||||
description: 用于关闭对话框、模态框或 dismiss 内容的按钮组件
|
||||
component: close-button
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { CloseButton } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="close-button-default" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 交互
|
||||
|
||||
<ComponentPreview name="close-button-interactive" />
|
||||
|
||||
### 自定义图标
|
||||
|
||||
<ComponentPreview name="close-button-with-custom-icon" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="close-button-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 CloseButton 组件类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-close-button {
|
||||
@apply bg-red-100 text-red-800 hover:bg-red-200;
|
||||
}
|
||||
|
||||
.hv-close-button--custom {
|
||||
@apply rounded-full border-2 border-red-300;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
CloseButton 组件使用以下 CSS 类:
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-close-button` - 基础组件样式
|
||||
|
||||
#### 变体类 [!toc]
|
||||
|
||||
- `.hv-close-button--default` - 默认变体
|
||||
|
||||
### 交互状态
|
||||
|
||||
组件同时支持 CSS 伪类与 data 属性:
|
||||
|
||||
- **Hover**:`:hover` 或 `[data-hovered="true"]`
|
||||
- **Active/Pressed**:`:active` 或 `[data-pressed="true"]`
|
||||
- **Focus**:`:focus-visible` 或 `[data-focus-visible="true"]`
|
||||
- **Disabled**:`:disabled` 或 `[aria-disabled="true"]`
|
||||
|
||||
## API 参考
|
||||
|
||||
### CloseButton
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | --------------------- | ------------ | -------------------------- |
|
||||
| `variant` | `"default"` | `"default"` | 按钮视觉变体 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 |
|
||||
| 默认插槽 | `string \| Component` | 内置关闭图标 | 显示内容(默认为关闭图标) |
|
||||
|
||||
### 原生按钮属性
|
||||
|
||||
CloseButton 是原生 `button`,`type` 固定为 `"button"`。常用属性包括:
|
||||
|
||||
| Prop | 类型 | 描述 |
|
||||
| ------------------ | -------- | ------------------------------------ |
|
||||
| `aria-label` | `string` | 屏幕阅读器的无障碍标签,默认 `Close` |
|
||||
| `aria-labelledby` | `string` | 标注按钮的元素 ID |
|
||||
| `aria-describedby` | `string` | 描述按钮的元素 ID |
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 描述 |
|
||||
| ---------------- | --------- | ---------------------- |
|
||||
| `isHovered` | `boolean` | 是否悬停 |
|
||||
| `isPressed` | `boolean` | 是否按下 |
|
||||
| `isFocused` | `boolean` | 是否聚焦 |
|
||||
| `isFocusVisible` | `boolean` | 是否显示键盘焦点指示器 |
|
||||
| `isDisabled` | `boolean` | 是否禁用 |
|
||||
|
||||
`onPress` 与 React Aria 的 PressEvent 不直接等价;Vue 使用原生 `@click` 与键盘事件。默认关闭图标来自固定基线 `CloseIcon`,可通过插槽替换为任意图标组件。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Card 卡片](./card)
|
||||
@@ -0,0 +1,185 @@
|
||||
---
|
||||
title: Skeleton 骨架屏
|
||||
description: Skeleton 用于展示加载状态,并预览组件的预期形状。
|
||||
component: skeleton
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="skeleton-basic" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 文本内容
|
||||
|
||||
<ComponentPreview name="skeleton-text-content" />
|
||||
|
||||
### 用户资料
|
||||
|
||||
<ComponentPreview name="skeleton-user-profile" />
|
||||
|
||||
### 列表项
|
||||
|
||||
<ComponentPreview name="skeleton-list" />
|
||||
|
||||
### 网格
|
||||
|
||||
<ComponentPreview name="skeleton-grid" />
|
||||
|
||||
### 单次闪烁
|
||||
|
||||
同步的 shimmer 效果会一次性扫过所有骨架元素。在父容器上应用 `hv-skeleton--shimmer` 类,并将子骨架的 `animationType` 设为 `"none"`。
|
||||
|
||||
<ComponentPreview name="skeleton-single-shimmer" />
|
||||
|
||||
### 动画类型
|
||||
|
||||
<ComponentPreview name="skeleton-animation-types" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="skeleton-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
/* Base skeleton styles */
|
||||
.hv-skeleton {
|
||||
@apply bg-surface-secondary/50; /* Change base background */
|
||||
}
|
||||
|
||||
/* Shimmer animation gradient */
|
||||
.hv-skeleton--shimmer::after {
|
||||
@apply via-surface-tertiary; /* Change shimmer gradient color */
|
||||
}
|
||||
|
||||
/* Pulse animation */
|
||||
.hv-skeleton--pulse {
|
||||
@apply animate-pulse opacity-75; /* Customize pulse animation */
|
||||
}
|
||||
|
||||
/* No animation variant */
|
||||
.hv-skeleton--none {
|
||||
@apply opacity-50; /* Style for static skeleton */
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 全局动画配置
|
||||
|
||||
可在全局 CSS 中通过 `--skeleton-animation` 变量为所有 Skeleton 组件设置默认动画类型:
|
||||
|
||||
```css
|
||||
/* 全局 CSS 文件 */
|
||||
:root {
|
||||
/* 可选值:shimmer、pulse、none */
|
||||
--skeleton-animation: pulse;
|
||||
}
|
||||
|
||||
/* 也可为浅色/深色主题设置不同值 */
|
||||
.light,
|
||||
[data-theme="light"] {
|
||||
--skeleton-animation: shimmer;
|
||||
}
|
||||
|
||||
.dark,
|
||||
[data-theme="dark"] {
|
||||
--skeleton-animation: pulse;
|
||||
}
|
||||
```
|
||||
|
||||
在单个组件上指定 `animation-type` 属性会覆盖此全局设置。
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Skeleton 使用以下 CSS 类:
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
`.hv-skeleton` - 包含背景与圆角等基础骨架样式
|
||||
|
||||
#### 动画变体类 [!toc]
|
||||
|
||||
- `.hv-skeleton--shimmer` - 添加带渐变效果的闪烁动画(默认)
|
||||
- `.hv-skeleton--pulse` - 使用 Tailwind 的 `animate-pulse` 添加脉冲动画
|
||||
- `.hv-skeleton--none` - 无动画的静态骨架
|
||||
|
||||
### 动画
|
||||
|
||||
Skeleton 支持三种动画类型,视觉效果各不相同:
|
||||
|
||||
#### 闪烁动画 [!toc]
|
||||
|
||||
闪烁效果会在骨架元素上移动渐变:
|
||||
|
||||
```css
|
||||
.hv-skeleton--shimmer::after {
|
||||
@apply absolute inset-0 -translate-x-full animate-skeleton
|
||||
bg-linear-to-r from-transparent via-surface-tertiary to-transparent content-[''];
|
||||
}
|
||||
```
|
||||
|
||||
闪烁动画在主题中通过以下方式定义:
|
||||
|
||||
```css
|
||||
@theme inline {
|
||||
--animate-skeleton: skeleton 2s linear infinite;
|
||||
|
||||
@keyframes skeleton {
|
||||
100% {
|
||||
transform: translateX(200%);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 脉冲动画 [!toc]
|
||||
|
||||
脉冲动画使用 Tailwind 内置的 `animate-pulse` 工具类:
|
||||
|
||||
```css
|
||||
.hv-skeleton--pulse {
|
||||
@apply animate-pulse;
|
||||
}
|
||||
```
|
||||
|
||||
#### 无动画 [!toc]
|
||||
|
||||
用于不需要任何动画的静态骨架:
|
||||
|
||||
```css
|
||||
.hv-skeleton--none {
|
||||
/* No animation styles applied */
|
||||
}
|
||||
```
|
||||
|
||||
## API 参考
|
||||
|
||||
### Skeleton
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------------- | -------------------------------- | ----------------------- | ------------------------------------------------------------------------- |
|
||||
| `animationType` | `"shimmer" \| "pulse" \| "none"` | `"shimmer"` 或 CSS 变量 | Skeleton 的动画类型;也可通过 `--skeleton-animation` CSS 变量进行全局配置 |
|
||||
| `class` | `string` | - | 额外的 CSS 类名 |
|
||||
|
||||
`animationType` 未指定时,客户端挂载后读取 `--skeleton-animation`;服务端渲染与首次客户端渲染使用 `"shimmer"` 兜底。挂载后修改该 CSS 变量不会自动更新已渲染的 Skeleton。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Card 卡片](./card) · [Spinner 加载指示器](./spinner)
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="约翰·多伊"
|
||||
src="https://img.heroui.chat/image/avatar?w=400&h=400&u=3"
|
||||
/>
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="蓝色头像"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback>B</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarFallback>JR</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarFallback } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Avatar color="default">
|
||||
<AvatarFallback>DF</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar color="accent">
|
||||
<AvatarFallback>AC</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar color="success">
|
||||
<AvatarFallback>SC</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar color="warning">
|
||||
<AvatarFallback>WR</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar color="danger">
|
||||
<AvatarFallback>DG</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
import { defineComponent, h } from "vue";
|
||||
|
||||
const SRC =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg";
|
||||
|
||||
/** Stand-in for a framework image component (e.g. Next.js Image). */
|
||||
const FrameworkImage = defineComponent({
|
||||
name: "FrameworkImage",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
src: { type: String, required: true },
|
||||
alt: { type: String, default: "" },
|
||||
width: { type: [Number, String], default: 40 },
|
||||
height: { type: [Number, String], default: 40 },
|
||||
},
|
||||
setup(props, { attrs }) {
|
||||
return () =>
|
||||
h("img", {
|
||||
...attrs,
|
||||
src: props.src,
|
||||
alt: props.alt,
|
||||
width: props.width,
|
||||
height: props.height,
|
||||
});
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Avatar>
|
||||
<AvatarImage :src="SRC" as-child>
|
||||
<FrameworkImage :src="SRC" alt="约翰·多伊" :width="40" :height="40" />
|
||||
</AvatarImage>
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Avatar class="rounded-lg">
|
||||
<AvatarImage
|
||||
alt="张三"
|
||||
src="https://img.heroui.chat/image/avatar?w=400&h=400&u=3"
|
||||
/>
|
||||
<AvatarFallback class="rounded-lg">张三</AvatarFallback>
|
||||
</Avatar>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
import { IconUser } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<!-- 文字回退 -->
|
||||
<Avatar>
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<!-- 图标回退 -->
|
||||
<Avatar>
|
||||
<AvatarFallback>
|
||||
<IconUser aria-hidden="true" class="size-4 shrink-0" />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<!-- 延迟显示回退 -->
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="延迟加载头像"
|
||||
src="https://invalid-url-to-show-fallback.com/image.jpg"
|
||||
/>
|
||||
<AvatarFallback :delay-ms="600">NA</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<!-- 自定义样式回退 -->
|
||||
<Avatar>
|
||||
<AvatarFallback
|
||||
class="border-none bg-gradient-to-br from-pink-500 to-purple-500 text-white"
|
||||
>
|
||||
GB
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
name: "刘洋",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
name: "陈静",
|
||||
},
|
||||
];
|
||||
|
||||
function initialsFromName(name: string) {
|
||||
const parts = name.split(/\s+/).filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return parts.map((n) => n[0]).join("");
|
||||
}
|
||||
|
||||
return name.slice(0, 2);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<AvatarGroup>
|
||||
<Avatar v-for="user in users.slice(0, 4)" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
name: "刘洋",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
name: "陈静",
|
||||
},
|
||||
];
|
||||
|
||||
function initialsFromName(name: string) {
|
||||
const parts = name.split(/\s+/).filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return parts.map((n) => n[0]).join("");
|
||||
}
|
||||
|
||||
return name.slice(0, 2);
|
||||
}
|
||||
|
||||
const total = 12;
|
||||
</script>
|
||||
<template>
|
||||
<AvatarGroup size="sm">
|
||||
<Avatar v-for="user in users.slice(0, 3)" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
<AvatarGroupCount>+{{ total - 3 }}</AvatarGroupCount>
|
||||
</AvatarGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconUser } from "@tabler/icons-vue";
|
||||
|
||||
const assignees = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="inline-flex items-center gap-2.5 rounded-full border border-border/70 bg-surface/95 py-1 pr-3 pl-1 shadow-sm ring-1 ring-black/[0.04] dark:border-border/80 dark:bg-surface/90 dark:ring-white/10"
|
||||
>
|
||||
<AvatarGroup
|
||||
aria-label="指派人"
|
||||
class="[--avatar-group-overlap:0.7rem] [--avatar-group-seam:2px]"
|
||||
overlap="clip"
|
||||
role="group"
|
||||
size="sm"
|
||||
>
|
||||
<Avatar v-for="user in assignees" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ user.name.slice(0, 1) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarFallback>
|
||||
<IconUser aria-hidden="true" class="size-4 shrink-0" />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<AvatarGroupCount>+3</AvatarGroupCount>
|
||||
</AvatarGroup>
|
||||
<span class="text-sm font-medium text-foreground">指派人</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
name: "刘洋",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
name: "陈静",
|
||||
},
|
||||
];
|
||||
|
||||
function initialsFromName(name: string) {
|
||||
const parts = name.split(/\s+/).filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return parts.map((n) => n[0]).join("");
|
||||
}
|
||||
|
||||
return name.slice(0, 2);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<AvatarGroup is-grid :max="5">
|
||||
<Avatar v-for="user in users" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
name: "刘洋",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
name: "陈静",
|
||||
},
|
||||
];
|
||||
|
||||
function initialsFromName(name: string) {
|
||||
const parts = name.split(/\s+/).filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return parts.map((n) => n[0]).join("");
|
||||
}
|
||||
|
||||
return name.slice(0, 2);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<AvatarGroup :max="3">
|
||||
<Avatar v-for="user in users" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,104 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@keyframes ag-stripes {
|
||||
to {
|
||||
background-position: 24px 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.ag-stripes {
|
||||
background-color: color-mix(in oklab, var(--danger) 6%, var(--surface));
|
||||
background-image: repeating-linear-gradient(
|
||||
-45deg,
|
||||
transparent 0 10px,
|
||||
color-mix(in oklab, var(--danger) 12%, transparent) 10px 11px,
|
||||
transparent 11px 21px,
|
||||
color-mix(in oklab, var(--danger) 28%, transparent) 21px 22px
|
||||
);
|
||||
background-size: 24px 24px;
|
||||
animation: ag-stripes 2.8s linear infinite;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col items-start gap-6">
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm text-muted">clip</p>
|
||||
<div class="relative inline-flex rounded-xl p-6">
|
||||
<div
|
||||
aria-hidden
|
||||
class="ag-stripes pointer-events-none absolute inset-0 rounded-xl"
|
||||
/>
|
||||
<div class="relative z-10">
|
||||
<AvatarGroup overlap="clip" size="lg">
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="John"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarFallback>AB</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="Emily"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg"
|
||||
/>
|
||||
<AvatarFallback>EC</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarFallback>SM</AvatarFallback>
|
||||
</Avatar>
|
||||
<AvatarGroupCount>+2</AvatarGroupCount>
|
||||
</AvatarGroup>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<p class="text-sm text-muted">ring</p>
|
||||
<div class="relative inline-flex rounded-xl p-6">
|
||||
<div
|
||||
aria-hidden
|
||||
class="ag-stripes pointer-events-none absolute inset-0 rounded-xl"
|
||||
/>
|
||||
<div class="relative z-10">
|
||||
<AvatarGroup overlap="ring" size="lg">
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="John"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarFallback>AB</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="Emily"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg"
|
||||
/>
|
||||
<AvatarFallback>EC</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar>
|
||||
<AvatarFallback>SM</AvatarFallback>
|
||||
</Avatar>
|
||||
<AvatarGroupCount>+2</AvatarGroupCount>
|
||||
</AvatarGroup>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
name: "刘洋",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
name: "陈静",
|
||||
},
|
||||
];
|
||||
|
||||
function initialsFromName(name: string) {
|
||||
const parts = name.split(/\s+/).filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return parts.map((n) => n[0]).join("");
|
||||
}
|
||||
|
||||
return name.slice(0, 2);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col items-center gap-6">
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<p class="text-sm text-muted">小号</p>
|
||||
<AvatarGroup size="sm">
|
||||
<Avatar v-for="user in users.slice(0, 4)" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</div>
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<p class="text-sm text-muted">中号(默认)</p>
|
||||
<AvatarGroup size="md">
|
||||
<Avatar v-for="user in users.slice(0, 4)" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</div>
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<p class="text-sm text-muted">大号</p>
|
||||
<AvatarGroup size="lg">
|
||||
<Avatar v-for="user in users.slice(0, 4)" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Avatar size="sm">
|
||||
<AvatarImage
|
||||
alt="小尺寸头像"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback>SM</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar size="md">
|
||||
<AvatarImage
|
||||
alt="中尺寸头像"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg"
|
||||
/>
|
||||
<AvatarFallback>MD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Avatar size="lg">
|
||||
<AvatarImage
|
||||
alt="大尺寸头像"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg"
|
||||
/>
|
||||
<AvatarFallback>LG</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,84 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
import { IconUser } from "@tabler/icons-vue";
|
||||
|
||||
const colors = ["accent", "default", "success", "warning", "danger"] as const;
|
||||
|
||||
const COLOR_LABELS: Record<(typeof colors)[number], string> = {
|
||||
accent: "强调",
|
||||
danger: "危险",
|
||||
default: "默认",
|
||||
success: "成功",
|
||||
warning: "警告",
|
||||
};
|
||||
|
||||
const variants = [
|
||||
{ content: "AG", label: "字母", type: "letter" },
|
||||
{ content: "AG", label: "柔和字母", type: "letter-soft" },
|
||||
{ content: "icon", label: "图标", type: "icon" },
|
||||
{ content: "icon", label: "柔和图标", type: "icon-soft" },
|
||||
{
|
||||
content: [
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=3",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=4",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=5",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=8",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=16",
|
||||
],
|
||||
label: "图片",
|
||||
type: "img",
|
||||
},
|
||||
] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<!-- 颜色列标题 -->
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-24 shrink-0" />
|
||||
<div
|
||||
v-for="color in colors"
|
||||
:key="color"
|
||||
class="flex w-20 shrink-0 items-center justify-center"
|
||||
>
|
||||
<span class="text-xs text-muted">{{ COLOR_LABELS[color] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-px w-full bg-separator" />
|
||||
|
||||
<!-- 变体行 -->
|
||||
<div
|
||||
v-for="variant in variants"
|
||||
:key="variant.label"
|
||||
class="flex items-center gap-3"
|
||||
>
|
||||
<div class="w-24 shrink-0 text-sm text-muted">{{ variant.label }}</div>
|
||||
<div
|
||||
v-for="(color, colorIndex) in colors"
|
||||
:key="color"
|
||||
class="flex w-20 shrink-0 items-center justify-center"
|
||||
>
|
||||
<Avatar
|
||||
:color="color"
|
||||
:variant="variant.type.includes('soft') ? 'soft' : undefined"
|
||||
>
|
||||
<template v-if="variant.type === 'img'">
|
||||
<AvatarImage
|
||||
:alt="`${COLOR_LABELS[color]} 头像`"
|
||||
:src="
|
||||
Array.isArray(variant.content)
|
||||
? variant.content[colorIndex]
|
||||
: ''
|
||||
"
|
||||
/>
|
||||
<AvatarFallback>{{ COLOR_LABELS[color].charAt(0) }}</AvatarFallback>
|
||||
</template>
|
||||
<AvatarFallback v-else-if="variant.content === 'icon'">
|
||||
<IconUser aria-hidden="true" class="size-4 shrink-0" />
|
||||
</AvatarFallback>
|
||||
<AvatarFallback v-else>{{ variant.content }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,6 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { closeButtonVariants } from "@heroui-vue/styles";
|
||||
import { IconX } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
@@ -8,6 +6,7 @@ import {
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
Button,
|
||||
CloseButton,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
@@ -28,14 +27,7 @@ import {
|
||||
<CardDescription>
|
||||
这是一段占位说明文字,用于展示横向卡片布局、配图与右上角关闭按钮的排版效果。
|
||||
</CardDescription>
|
||||
<button
|
||||
type="button"
|
||||
:class="closeButtonVariants()"
|
||||
aria-label="关闭横幅"
|
||||
class="absolute end-3 top-3"
|
||||
>
|
||||
<IconX aria-hidden="true" />
|
||||
</button>
|
||||
<CloseButton aria-label="关闭横幅" class="absolute end-3 top-3" />
|
||||
</CardHeader>
|
||||
<CardFooter
|
||||
class="mt-auto flex w-full flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||
|
||||
@@ -5,8 +5,10 @@ import {
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
@@ -22,7 +24,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
<CardDescription>148 位成员</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter class="flex gap-2">
|
||||
<AvatarRoot
|
||||
<Avatar
|
||||
aria-label="玛莎的头像"
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-5"
|
||||
>
|
||||
@@ -36,7 +38,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
>
|
||||
IH
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</Avatar>
|
||||
<span class="text-xs">创建者:玛莎</span>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
@@ -53,7 +55,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
<CardDescription>362 位成员</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter class="flex gap-2">
|
||||
<AvatarRoot
|
||||
<Avatar
|
||||
aria-label="约翰的头像"
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-5"
|
||||
>
|
||||
@@ -67,7 +69,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
>
|
||||
B
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</Avatar>
|
||||
<span class="text-xs">创建者:约翰</span>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { closeButtonVariants } from "@heroui-vue/styles";
|
||||
import { IconX } from "@tabler/icons-vue";
|
||||
import { IconCoin } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
@@ -10,10 +8,13 @@ import {
|
||||
CardContent,
|
||||
CardFooter,
|
||||
Button,
|
||||
CloseButton,
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Link,
|
||||
LinkIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-full items-center justify-center">
|
||||
@@ -35,14 +36,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
<CardDescription>
|
||||
这是一段占位说明文字,用于展示横向卡片布局、配图与右上角关闭按钮的排版效果。
|
||||
</CardDescription>
|
||||
<button
|
||||
type="button"
|
||||
:class="closeButtonVariants()"
|
||||
aria-label="关闭横幅"
|
||||
class="absolute end-3 top-3"
|
||||
>
|
||||
<IconX aria-hidden="true" />
|
||||
</button>
|
||||
<CloseButton aria-label="关闭横幅" class="absolute end-3 top-3" />
|
||||
</CardHeader>
|
||||
<CardFooter
|
||||
class="mt-auto flex w-full flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||
@@ -62,13 +56,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4 lg:col-span-6">
|
||||
<Card class="col-span-12">
|
||||
<div class="absolute end-3 top-3 z-10">
|
||||
<button
|
||||
type="button"
|
||||
:class="closeButtonVariants()"
|
||||
aria-label="关闭通知"
|
||||
>
|
||||
<IconX aria-hidden="true" />
|
||||
</button>
|
||||
<CloseButton aria-label="关闭通知" />
|
||||
</div>
|
||||
<CardHeader class="gap-3">
|
||||
<IconCoin
|
||||
@@ -99,7 +87,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
<Card class="col-span-12 gap-2 sm:col-span-6">
|
||||
<CardHeader>
|
||||
<AvatarRoot
|
||||
<Avatar
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-[56px] rounded-xl"
|
||||
>
|
||||
<AvatarImage
|
||||
@@ -112,14 +100,14 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
>
|
||||
JK
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</Avatar>
|
||||
</CardHeader>
|
||||
<CardContent class="mt-1">
|
||||
<p class="text-sm leading-4 font-medium">Indie Hackers</p>
|
||||
<p class="text-xs text-muted">148 位成员</p>
|
||||
</CardContent>
|
||||
<CardFooter class="flex items-center gap-2">
|
||||
<AvatarRoot
|
||||
<Avatar
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-4"
|
||||
>
|
||||
<AvatarImage
|
||||
@@ -132,14 +120,14 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
>
|
||||
JK
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</Avatar>
|
||||
<p class="text-xs text-muted">创建者:约翰</p>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
<Card class="col-span-12 gap-2 sm:col-span-6">
|
||||
<CardHeader>
|
||||
<AvatarRoot
|
||||
<Avatar
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-[56px] rounded-xl"
|
||||
>
|
||||
<AvatarImage
|
||||
@@ -152,14 +140,14 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
>
|
||||
AB
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</Avatar>
|
||||
</CardHeader>
|
||||
<CardContent class="mt-1">
|
||||
<p class="text-sm leading-4 font-medium">AI Builders</p>
|
||||
<p class="text-xs text-muted">362 位成员</p>
|
||||
</CardContent>
|
||||
<CardFooter class="flex items-center gap-2">
|
||||
<AvatarRoot
|
||||
<Avatar
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-4"
|
||||
>
|
||||
<AvatarImage
|
||||
@@ -172,7 +160,7 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
>
|
||||
M
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</Avatar>
|
||||
<p class="text-xs text-muted">创建者:玛莎</p>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { CloseButton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<CloseButton
|
||||
aria-label="关闭"
|
||||
class="size-8 rounded-full bg-default text-muted hover:bg-default-hover hover:text-foreground active:scale-95"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { CloseButton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<CloseButton />
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { CloseButton } from "@heroui-vue/components";
|
||||
|
||||
const count = ref(0);
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col items-center justify-center gap-4">
|
||||
<CloseButton :aria-label="`关闭(已点击 ${count} 次)`" @click="count++" />
|
||||
<span class="text-sm text-muted">已点击:{{ count }} 次</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import { CloseButton } from "@heroui-vue/components";
|
||||
import { IconCircleX, IconX } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<CloseButton>
|
||||
<IconCircleX aria-hidden="true" />
|
||||
</CloseButton>
|
||||
<span class="text-xs text-muted">自定义图标</span>
|
||||
</div>
|
||||
<div class="flex flex-col items-center gap-2">
|
||||
<CloseButton>
|
||||
<IconX aria-hidden="true" />
|
||||
</CloseButton>
|
||||
<span class="text-xs text-muted">备选图标</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="grid w-full max-w-xl grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3"
|
||||
>
|
||||
<div class="space-y-2">
|
||||
<p class="truncate text-xs text-muted">微光</p>
|
||||
<div class="shadow-panel space-y-3 rounded-lg bg-transparent p-4">
|
||||
<Skeleton animation-type="shimmer" class="h-20 rounded-lg" />
|
||||
<Skeleton animation-type="shimmer" class="h-3 w-3/5 rounded-lg" />
|
||||
<Skeleton animation-type="shimmer" class="h-3 w-4/5 rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<p class="truncate text-xs text-muted">脉冲</p>
|
||||
<div class="shadow-panel space-y-3 rounded-lg bg-transparent p-4">
|
||||
<Skeleton animation-type="pulse" class="h-20 rounded-lg" />
|
||||
<Skeleton animation-type="pulse" class="h-3 w-3/5 rounded-lg" />
|
||||
<Skeleton animation-type="pulse" class="h-3 w-4/5 rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<p class="truncate text-xs text-muted">无</p>
|
||||
<div class="shadow-panel space-y-3 rounded-lg bg-transparent p-4">
|
||||
<Skeleton animation-type="none" class="h-20 rounded-lg" />
|
||||
<Skeleton animation-type="none" class="h-3 w-3/5 rounded-lg" />
|
||||
<Skeleton animation-type="none" class="h-3 w-4/5 rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="shadow-panel w-[250px] space-y-5 rounded-lg bg-transparent p-4">
|
||||
<Skeleton class="h-32 rounded-lg" />
|
||||
<div class="space-y-3">
|
||||
<Skeleton class="h-3 w-3/5 rounded-lg" />
|
||||
<Skeleton class="h-3 w-4/5 rounded-lg" />
|
||||
<Skeleton class="h-3 w-2/5 rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
|
||||
const bone =
|
||||
"animate-shine rounded-lg bg-neutral-200/90 dark:bg-neutral-800/90";
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="w-[250px] space-y-5 rounded-xl border border-border/80 bg-surface p-4 shadow-sm ring-1 ring-black/5 dark:ring-white/10"
|
||||
>
|
||||
<Skeleton :class="`h-32 ${bone}`" />
|
||||
<div class="space-y-3">
|
||||
<Skeleton :class="`h-3 w-3/5 ${bone}`" />
|
||||
<Skeleton :class="`h-3 w-4/5 ${bone}`" />
|
||||
<Skeleton :class="`h-3 w-2/5 ${bone}`" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="grid w-full max-w-xl grid-cols-3 gap-4">
|
||||
<Skeleton class="h-24 rounded-xl" />
|
||||
<Skeleton class="h-24 rounded-xl" />
|
||||
<Skeleton class="h-24 rounded-xl" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="w-full max-w-sm space-y-4">
|
||||
<div v-for="index in 3" :key="index" class="flex items-center gap-3">
|
||||
<Skeleton class="h-10 w-10 shrink-0 rounded-lg" />
|
||||
<div class="flex-1 space-y-2">
|
||||
<Skeleton class="h-3 w-full rounded" />
|
||||
<Skeleton class="h-3 w-4/5 rounded" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="hv-skeleton--shimmer relative grid w-full max-w-xl grid-cols-3 gap-4 overflow-hidden rounded-xl"
|
||||
>
|
||||
<Skeleton animation-type="none" class="h-24 rounded-xl" />
|
||||
<Skeleton animation-type="none" class="h-24 rounded-xl" />
|
||||
<Skeleton animation-type="none" class="h-24 rounded-xl" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="w-full max-w-md space-y-3">
|
||||
<Skeleton class="h-4 w-full rounded" />
|
||||
<Skeleton class="h-4 w-5/6 rounded" />
|
||||
<Skeleton class="h-4 w-4/6 rounded" />
|
||||
<Skeleton class="h-4 w-full rounded" />
|
||||
<Skeleton class="h-4 w-3/6 rounded" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { Skeleton } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-3">
|
||||
<Skeleton class="h-10 w-10 shrink-0 rounded-full" />
|
||||
<div class="flex-1 space-y-2">
|
||||
<Skeleton class="h-3 w-36 rounded-lg" />
|
||||
<Skeleton class="h-3 w-24 rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+15
-8
@@ -7,8 +7,8 @@
|
||||
| accordion | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| breadcrumbs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
@@ -23,7 +23,7 @@
|
||||
| color-slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 样式已移植 | Card 演示使用原生 button + closeButtonVariants + Tabler IconX;Vue CloseButton 组件尚未实现 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
@@ -40,7 +40,7 @@
|
||||
| popover | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| scroll-shadow | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| separator | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| skeleton | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
@@ -100,13 +100,20 @@ React Aria 专属 rac 导出与 React 图标类型不移植;Vue 版 ConfigProv
|
||||
|
||||
## 已实现组件的文档清单复核
|
||||
|
||||
Button 14 / 14,Card 7 / 7,Input 7 / 7,Switch 15 / 15,Surface 4 / 4,Link 6 / 6,Spinner 5 / 5,基线预览名称与顺序均已对齐。没有用空壳补足数量;预览与复制代码共用 SFC。
|
||||
Button 14 / 14,Card 7 / 7,Input 7 / 7,Switch 15 / 15,Surface 4 / 4,Link 6 / 6,Spinner 5 / 5,CloseButton 4 / 4,Avatar 7 / 7,AvatarGroup 7 / 7,Skeleton 8 / 8,基线预览名称与顺序均已对齐。没有用空壳补足数量;预览与复制代码共用 SFC。
|
||||
|
||||
Card 图片、头像、横向布局、表单与自定义样式已补齐;Input 的标签、类型、宽度与自定义样式已对齐。Switch 补齐图标、位置、分组、表单、状态插槽与自定义根容器。Surface 覆盖变体与表单组合;Link 覆盖图标位置、文本装饰、自定义图标、asChild 与自定义样式;Spinner 覆盖颜色、尺寸、速度与自定义样式。
|
||||
Card 图片、头像、横向布局、表单与自定义样式已补齐;Input 的标签、类型、宽度与自定义样式已对齐。Switch 补齐图标、位置、分组、表单、状态插槽与自定义根容器。Surface 覆盖变体与表单组合;Link 覆盖图标位置、文本装饰、自定义图标、asChild 与自定义样式;Spinner 覆盖颜色、尺寸、速度与自定义样式。CloseButton 覆盖默认、交互、自定义图标与自定义样式。Avatar 覆盖基本、尺寸、颜色、变体、回退、自定义图片组件与自定义样式;AvatarGroup 覆盖基本、max、自定义计数、尺寸、网格、叠放样式与自定义样式;Skeleton 覆盖文本、用户资料、列表、网格、单次闪烁、动画类型与自定义样式。
|
||||
|
||||
框架适配差异:Avatar 使用 Reka 组合,表单使用 Input/TextArea;链接原生锚点由 Link 组件封装;图标使用 Tabler 官方 Vue 组件(Link 自定义图标示例);演示不提供认证、支付等业务服务。完整 React Aria 事件模型、全库字段上下文及自动视觉回归仍不在本批完成范围。
|
||||
框架适配差异:Avatar 使用 Reka 组合,表单使用 Input/TextArea;链接原生锚点由 Link 组件封装;图标使用 Tabler 官方 Vue 组件(Link 自定义图标、CloseButton 自定义图标、Avatar 图标回退等示例);演示不提供认证、支付等业务服务。完整 React Aria 事件模型、全库字段上下文及自动视觉回归仍不在本批完成范围。
|
||||
|
||||
上游 Link 的 `underline-offset` 与 `underline-variants` 演示文件未出现在中英文文档预览清单,本批仅迁移文档引用的 6 个示例。Link `onPress`/`PressEvent` 与 `render` 由 `click` 与 `asChild` 适配;Spinner 默认图标为移植的基线 SVG,非 Tabler。
|
||||
上游 Link 的 `underline-offset` 与 `underline-variants` 演示文件未出现在中英文文档预览清单,本批仅迁移文档引用的 6 个示例。Link `onPress`/`PressEvent` 与 `render` 由 `click` 与 `asChild` 适配;Spinner 与 CloseButton 默认图标为移植的基线 SVG,非 Tabler。上游 `close-button/variants.tsx`、`skeleton/card.tsx` 未进入文档预览清单,未迁移。Avatar 变体示例中的 Separator 以分隔线 div 适配(Separator 组件未迁移)。
|
||||
|
||||
## M04–M06 说明
|
||||
|
||||
- CloseButton:专用 `hv-close-button` CSS;默认插槽回退为基线 CloseIcon;`onPress` 改为 `@click`;isDisabled 设置原生 disabled 与 aria-disabled。
|
||||
- Avatar / AvatarGroup:加载与回退由 Reka Avatar 处理;AvatarGroup 通过 provide/inject 与 `__avatar_group_child` 标记仅向直接 Avatar 子级继承 size/color/variant;`max` 自动计数用 AvatarGroupCount 渲染,显式 Count 不受 max 截断并抑制自动计数。
|
||||
- Skeleton:`animationType` 未指定时在客户端挂载后读取 `--skeleton-animation`;SSR/首屏回退 `shimmer`。挂载后修改该 CSS 变量不会自动刷新已渲染节点。
|
||||
- Card 演示中的关闭按钮与头像已替换为 CloseButton / Avatar 公共组件,不再使用 closeButtonVariants 手工组合或裸 Reka 绑定。
|
||||
|
||||
## 文档体验范围
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@
|
||||
保持样式、布局、文案、参数默认值、变体、主题及状态的高一致性。
|
||||
仅将框架机制适配为 Vue v-model、事件、插槽与独立命名导出;记录具体差异。
|
||||
所有演示使用同一份 Vue SFC 渲染、复制和高亮;图标用 @tabler/icons-vue,不自绘 SVG。
|
||||
文档表格统一铺满正文内容区,长内容自动换行,不横向滚动、不缩小字号、不截断内容;
|
||||
复用公共样式,按本文“文档表格排版与验收”检查长类型 API 表和短内容插槽表。
|
||||
禁止用近似控件、占位内容或未生效的 Tailwind 类名充数。
|
||||
新增依赖或共享协议变更先说明缺口与影响,不擅自替换全库架构。
|
||||
|
||||
@@ -137,8 +139,20 @@
|
||||
- 不用 ghost Button 代替 CloseButton 等专用视觉;不把没有加载/失败处理的 img 当成完整 Avatar。
|
||||
- 桌面与窄屏、浅色与深色、主要变体和关键状态;图标库来源、尺寸和可访问名称;原站无法运行时明确限制,不声称逐像素一致。
|
||||
- 预览、复制、高亮必须来自同一 SFC。动态示例能开始、完成、恢复并重复执行;文档表格、导航、搜索及手机目录能实际使用。
|
||||
- 文档表格按下节检查:长表不溢出,短表不收缩,换行不丢失信息;公共样式改动需回归其他页面。
|
||||
- 模块加载/SSR 不访问 window/document;ID、水合、Teleport 等检查与 SSR 冒烟分开。生产构建必须验证包导出的 dist,不只验证开发源码。
|
||||
|
||||
### 文档表格排版与验收
|
||||
|
||||
适用于文档正文中的属性 API、事件、插槽、作用域状态及其他说明表格。宽度以正文内容区为准,不占用侧栏或右侧目录;演示区内的组件表格按组件自身契约处理。
|
||||
|
||||
- 所有正文表格始终铺满内容区,内容少时也不能按内容收缩。长类型、联合类型、属性名、默认值和描述在单元格内自动换行,长标识符允许必要的断行。
|
||||
- 不通过横向滚动、缩小字号、截断、省略号或隐藏列容纳内容;保留完整 API 信息及语义化 table 结构。
|
||||
- 复用 `apps/docs/.vitepress/theme/style.css` 的公共规则:`display: table`、`width: 100%`、`table-layout: fixed`,单元格及行内代码使用 `white-space: normal` 与 `overflow-wrap: anywhere`。不要为新页面添加滚动包装、强制不换行或撑宽表格的最小列宽;样式必须排除 `.not-prose` 演示区。
|
||||
- 在真实浏览器检查桌面与窄屏。至少覆盖 Button 的“API 参考”长联合类型与“作用域插槽状态”短表,并检查本次新增页面;修改公共规则时回归已有组件页及安装、主题等指南页。
|
||||
- 同时确认表格宽度与正文可用宽度一致,表格和单元格没有水平溢出,文字未遮挡或丢失。可用 `getBoundingClientRect()` 对比宽度,用 `scrollWidth` / `clientWidth` 辅助检查,再确认实际换行外观;仅看 CSS 声明、Markdown 源码或构建成功不能代替浏览器验收。
|
||||
- 交接报告记录页面、视口、主题、长短表的宽度与溢出结果;没有执行的视口明确标为未验证。当前案例与已执行结果见 `docs/verification.md` 的“文档复制按钮与表格排版修正”。
|
||||
|
||||
### 命令与证据边界
|
||||
|
||||
按改动范围运行当前真实存在的 `pnpm test`、`pnpm typecheck`、`pnpm build:docs`、`pnpm format`;影响消费验证页时增加 `pnpm build:playground`。合并后重跑受影响检查,不能用分支合并前的结果替代。
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
# M04–M06 CloseButton / Avatar / AvatarGroup / Skeleton 迁移交接
|
||||
|
||||
任务 ID:M04–M06
|
||||
起始提交:`56b1ef1`(main,Surface/Link/Spinner 已合入)
|
||||
工作区:`/Users/maoyingjie/Documents/OpenSourceProjects/heroui/heroui-vue`
|
||||
上游基线:HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`
|
||||
完成日期:2026-10-21
|
||||
|
||||
## 1. 范围与修改文件
|
||||
|
||||
### 新增
|
||||
|
||||
| 路径 | 用途 |
|
||||
| -------------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
||||
| `packages/styles/components/{avatar,avatar-group,skeleton}.css` | 基线 CSS,hv- 前缀 |
|
||||
| `packages/vue/src/components/close-button/CloseButton.vue` | CloseButton |
|
||||
| `packages/vue/src/components/avatar/{Avatar,AvatarImage,AvatarFallback,AvatarGroup,AvatarGroupCount,context}.vue/ts` | Avatar 家族 |
|
||||
| `packages/vue/src/components/skeleton/Skeleton.vue` | Skeleton |
|
||||
| `apps/docs/demos/close-button-*.vue`(4) | CloseButton 演示 |
|
||||
| `apps/docs/demos/avatar-*.vue`(7) | Avatar 演示 |
|
||||
| `apps/docs/demos/avatar-group-*.vue`(7) | AvatarGroup 演示 |
|
||||
| `apps/docs/demos/skeleton-*.vue`(8) | Skeleton 演示 |
|
||||
| `apps/docs/components/{close-button,avatar,avatar-group,skeleton}.md` | 文档页 |
|
||||
| `tests/close-button-avatar-skeleton.test.ts` | 行为与清单测试(19 项) |
|
||||
|
||||
### 修改(共享)
|
||||
|
||||
| 路径 | 改动 |
|
||||
| --------------------------------------------------------------- | --------------------------------------------- |
|
||||
| `packages/styles/src/index.ts` | 增加 avatar/avatarGroup/skeleton 变体映射 |
|
||||
| `packages/styles/index.css` | 导入三份新组件 CSS |
|
||||
| `packages/vue/src/{index.ts,types.ts}` | 导出组件、变体、类型、context |
|
||||
| `apps/docs/demos/card-{horizontal,with-images,with-avatar}.vue` | CloseButton/Avatar 替换临时适配 |
|
||||
| `apps/docs/.vitepress/theme/{Layout.vue,utilities.css}` | 导航条目;shadow-panel/animate-shine 演示工具 |
|
||||
| `apps/docs/components.md` | 组件列表 |
|
||||
| `package.json` | `test:unit` 加入新测试文件 |
|
||||
| `docs/{compatibility,upstream,verification}.md` | 状态与来源 |
|
||||
| `docs/migrations/M04-M06-close-button-avatar-skeleton.md` | 本文件 |
|
||||
|
||||
未修改上游 `../heroui`。未引入新的 npm 依赖(Reka UI / Tabler 已存在)。
|
||||
|
||||
## 2. 上游对照
|
||||
|
||||
| 上游路径 | 用途 |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------- |
|
||||
| `packages/react/src/components/close-button/close-button.tsx` | CloseButton 实现 |
|
||||
| `packages/react/src/components/avatar/{avatar,index}.ts` | Avatar 实现 |
|
||||
| `packages/react/src/components/avatar-group/*` | AvatarGroup 实现 |
|
||||
| `packages/react/src/components/skeleton/*` | Skeleton 实现 |
|
||||
| `packages/styles/components/{close-button,avatar,avatar-group,skeleton}.css` | 样式 |
|
||||
| `packages/styles/src/components/{close-button,avatar,avatar-group,skeleton}/*.styles.ts` | 变体映射 |
|
||||
| `apps/docs/content/docs/cn/react/components/(buttons)/close-button.mdx` | 中文文档 |
|
||||
| `apps/docs/content/docs/cn/react/components/(media)/avatar.mdx` / `avatar-group.mdx` | 中文文档 |
|
||||
| `apps/docs/content/docs/cn/react/components/(feedback)/skeleton.mdx` | 中文文档 |
|
||||
| `apps/docs/src/demos/cn/{close-button,avatar,avatar-group,skeleton}/` | 基线演示 |
|
||||
| `packages/react/src/components/icons.tsx` `CloseIcon` | 默认关闭图标 |
|
||||
|
||||
许可:Apache-2.0(`third-party/HEROUI-LICENSE`)。
|
||||
|
||||
## 3. API 对照与框架差异
|
||||
|
||||
### CloseButton
|
||||
|
||||
| 上游 | Vue | 差异 |
|
||||
| ------------------------- | -------------------------- | ------------------------------------------------------------------------------------- |
|
||||
| `children` / render prop | 默认插槽 + 作用域插槽 | 函数 children → 作用域插槽(isHovered/isPressed/isFocused/isFocusVisible/isDisabled) |
|
||||
| 默认 `<CloseIcon />` | 默认插槽回退基线 CloseIcon | data-slot=`close-button-icon` |
|
||||
| `onPress` | `@click` | PressEvent 不等价 |
|
||||
| `isDisabled` | `isDisabled` / `disabled` | 设置原生 disabled + aria-disabled |
|
||||
| `aria-label` 默认 `Close` | 同左 | 可覆盖 |
|
||||
| `variant` | `variant`(仅 `default`) | 同基线 |
|
||||
|
||||
### Avatar
|
||||
|
||||
| 上游 | Vue | 差异 |
|
||||
| ----------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------- |
|
||||
| `Avatar.Image` `src/sizes/srcSet/crossOrigin/loading` | `AvatarImage` + `srcSet`/`crossOrigin` 等 | Vue kebab 属性 |
|
||||
| `onLoad` / `onError` | `@load` / `@error` | 原生事件 |
|
||||
| `asChild` | `as-child`(Reka Primitive) | 合并属性到子组件 |
|
||||
| `delayMs` | `delayMs` | 同基线;delayMs=0 时 Reka 不显示 fallback(与底座一致) |
|
||||
| Fallback `color` 覆盖 | 同左 | 生成 `hv-avatar__fallback--*` |
|
||||
|
||||
### AvatarGroup
|
||||
|
||||
| 上游 | Vue | 差异 |
|
||||
| --------------------------------- | ------------------------------------- | -------------------------------------- |
|
||||
| `React.cloneElement` 标记直接子级 | `cloneVNode` + `__avatar_group_child` | 语义相同 |
|
||||
| `AvatarGroup.Count` | `AvatarGroupCount` 独立命名导出 | 非 `AvatarGroup.Count` 对象模式 |
|
||||
| `max` 自动 `+N` | 同左 | 显式 Count 抑制自动计数且不受 max 截断 |
|
||||
| `isGrid` / `overlap` | 同左 | `isGrid` 须为显式 boolean prop |
|
||||
| 默认无 `role=group` | 同左 | 调用方自行添加 |
|
||||
|
||||
### Skeleton
|
||||
|
||||
| 上游 | Vue | 差异 |
|
||||
| ------------------------------------------------------- | --------------------------- | ----------------------------------------------- |
|
||||
| `useCSSVariable('--skeleton-animation', animationType)` | 挂载后读 `getComputedStyle` | SSR/首屏回退 `shimmer`;挂载后改 CSS 变量不刷新 |
|
||||
| `animationType` | `animation-type` | 值 `shimmer \| pulse \| none` |
|
||||
| `dom.div` + attrs | 原生 div + `$attrs` | — |
|
||||
|
||||
## 4. 示例对照
|
||||
|
||||
| 文档 | 基线预览数 | 已迁移 | 备注 |
|
||||
| ------------ | ---------- | ------ | --------------------------------------------------------------------------------------------- |
|
||||
| close-button | 4 | 4/4 | default, interactive, with-custom-icon, custom-styles |
|
||||
| avatar | 7 | 7/7 | basic, sizes, colors, variants, fallback, custom-image-component, custom-styles |
|
||||
| avatar-group | 7 | 7/7 | basic, max, count, sizes, grid, overlap, custom-styles |
|
||||
| skeleton | 8 | 8/8 | basic, text-content, user-profile, list, grid, single-shimmer, animation-types, custom-styles |
|
||||
|
||||
未迁移(不在文档预览清单):`close-button/variants.tsx`、`skeleton/card.tsx`。
|
||||
|
||||
适配:
|
||||
|
||||
- 图标:`@gravity-ui/icons` Person/CircleXmark/Xmark → Tabler `IconUser`/`IconCircleX`/`IconX`。
|
||||
- Avatar 自定义图片组件:本地 `FrameworkImage` 演示 asChild(上游为 Next.js Image)。
|
||||
- Avatar 变体示例 Separator → 分隔线 div(Separator 未迁移)。
|
||||
- Skeleton `shadow-panel` / `animate-shine` 定义放在文档 utilities.css。
|
||||
- overlap 演示条纹样式改为 SFC `<style>` 块(Vue 禁止 template 内 `<style>`)。
|
||||
|
||||
## 5. 命令结果
|
||||
|
||||
| 命令 | 结果 |
|
||||
| ----------------- | --------------------------------------------------- |
|
||||
| `pnpm test` | 8 文件 / 86 项通过 |
|
||||
| `pnpm typecheck` | 通过 |
|
||||
| `pnpm build:docs` | 通过 |
|
||||
| `pnpm format` | 通过 |
|
||||
| `pnpm test:unit` | 已包含 `tests/close-button-avatar-skeleton.test.ts` |
|
||||
|
||||
新增 19 项测试:CloseButton 5、Avatar 3、AvatarGroup 5、Skeleton 3、演示清单 2、demo 依赖 1(清单含源码检查)。
|
||||
|
||||
## 6. 浏览器证据(IAB,桌面)
|
||||
|
||||
地址 `http://127.0.0.1:5173`。
|
||||
|
||||
- CloseButton:24×24、圆角 12px、`aria-label=Close`、内置图标;交互点击计数递增;深色背景 `oklch(0.274 0.006 286.033)`。
|
||||
- Avatar:40px / 圆角 24px;sm/md/lg、soft、五色 fallback 均生效。
|
||||
- AvatarGroup:clip `radial-gradient` 遮罩、ring `0 0 0 2px` 描边、overlap 0.5rem;+2 自动计数 / +9 显式计数;`is-grid` 类生效。
|
||||
- Skeleton:三类动画类、父级单次 shimmer、深色背景。
|
||||
- API 表:`display:table` + `table-layout:fixed`,宽 704px 无溢出。
|
||||
|
||||
截图:IAB `screenshot` 持续超时(compositor 未返回帧),**未保存位图**。以上为 DOM/计算样式证据。
|
||||
|
||||
## 7. 已知差异与未验证项
|
||||
|
||||
1. CloseButton `onPress`/`PressEvent` → `@click`,不声明完全等价。
|
||||
2. Skeleton CSS 变量在挂载后变更不自动更新。
|
||||
3. Avatar `delayMs={0}` 在 Reka 下不会显示 fallback(与底座行为一致)。
|
||||
4. Avatar 变体示例缺少真正的 Separator 组件。
|
||||
5. 未验证:Nuxt 水合、RTL、触屏、读屏、自动视觉对比、打包后独立安装。
|
||||
6. 无位图截图证据。
|
||||
|
||||
## 8. 复核步骤
|
||||
|
||||
1. `npx --yes pnpm@11.25.0 test && npx --yes pnpm@11.25.0 typecheck`。
|
||||
2. 打开 `http://127.0.0.1:5173/components/close-button`,点击「交互」示例按钮两次,确认「已点击:2 次」。
|
||||
3. 打开 `/components/avatar-group`,确认 max 示例显示 3 头像 + `+2`,count 示例 `+9`,网格示例为换行网格(非叠放)。
|
||||
4. 打开 `/components/skeleton`,确认动画类型三列(微光/脉冲/无)与单次闪烁示例。
|
||||
5. 切换深色主题,确认 CloseButton 背景、Avatar 背景、Skeleton 背景同步变化。
|
||||
6. 展开示例代码,确认与预览同一 SFC;复制可得完整源码。
|
||||
7. 对照上游中文文档,确认示例名称、次序与 API 表字段无缺失。
|
||||
|
||||
## 9. 集成人注意
|
||||
|
||||
- `packages/vue/src/index.ts`、`types.ts`、样式入口、`package.json`、`Layout.vue` 为共享文件,已按单一负责人修改。
|
||||
- 未声明完整 HeroUI 兼容;状态为「验证中(最小实现)」。
|
||||
|
||||
## 10. 复核返工(2026-10-21)
|
||||
|
||||
独立复核报告见 `docs/migrations/M04-M06-review.md`。已处理:
|
||||
|
||||
| 严重性 | 问题 | 处理 |
|
||||
| ------ | ------------------------------------- | ----------------------------------- |
|
||||
| 中 | AvatarFallback color 覆盖与父级类叠加 | 槽函数单次求值替换变体;+3 回归测试 |
|
||||
| 低 | AvatarImage 缺 alt/asChild 类型 | 补齐 props 与文档 |
|
||||
| 低 | delayMs=0 行为未标注 | avatar.md 注明 |
|
||||
| 信息 | Skeleton 重复动画配置节 | 保留单节,不复制冗余 |
|
||||
|
||||
修复后:`pnpm test` 89 项、`typecheck`、`format` 通过。
|
||||
|
||||
## 11. 动态更新返工(2026-10-21)
|
||||
|
||||
按集成人复核修复 3 项 P2:attrs 快照、插槽缓存、v-if 注释占位。详见 `M04-M06-review.md` 返工记录。测试 94 项。
|
||||
@@ -0,0 +1,365 @@
|
||||
# M04–M06 独立复核报告(CloseButton / Avatar / AvatarGroup / Skeleton)
|
||||
|
||||
复核日期:2026-10-21
|
||||
复核人:独立复核(不采信交接报告结论,自行验证)
|
||||
被复核交接:`docs/migrations/M04-M06-close-button-avatar-skeleton.md`
|
||||
起始提交:`56b1ef1`
|
||||
上游基线:HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`
|
||||
工作区:`/Users/maoyingjie/Documents/OpenSourceProjects/heroui/heroui-vue`
|
||||
上游参考:`/Users/maoyingjie/Documents/OpenSourceProjects/heroui/heroui`(未修改)
|
||||
|
||||
当前结论以末尾最新的集成人复核为准;前文保留原审查及返工历史。
|
||||
|
||||
## 结论
|
||||
|
||||
**待修正。**
|
||||
|
||||
公共契约层存在 1 项可复现的中等问题(AvatarFallback 的 `color` 覆盖未替换父级颜色类),另有 2 项低优先级文档/类型偏差。其余范围(来源、变体与默认值、主要交互、CSS 移植、演示数量与同源、构建与类型检查)经独立验证通过。预写延后项(Nuxt/RTL/触屏/读屏/位图视觉对比/独立安装)按范围单独记录,未扩大为缺陷。
|
||||
|
||||
按 `docs/migration-handoff.md`「复核结论与返工规则」:公共契约问题不能评为“通过”,故为待修正;修复后应复核 AvatarFallback 颜色覆盖并回归 Avatar 相关测试与文档。
|
||||
|
||||
---
|
||||
|
||||
## 1. 发现的问题
|
||||
|
||||
### 1.1 [中] AvatarFallback 的 `color` 覆盖与父级 color 类叠加,而非替换
|
||||
|
||||
| 项 | 内容 |
|
||||
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 严重性 | 中(公共契约:文档写明“覆盖父级颜色”,实现未覆盖) |
|
||||
| 位置 | `packages/vue/src/components/avatar/AvatarFallback.vue:22-28` |
|
||||
| 触发条件 | 父级 `Avatar` 指定 `color`,子级 `AvatarFallback` 再指定不同的 `color` |
|
||||
| 预期 | 只保留 fallback 自身的 `hv-avatar__fallback--danger`(上游 `composeSlotClassName(slots?.fallback, className, {color})` 会用 `color` 替换变体) |
|
||||
| 实际 | 同时存在 `hv-avatar__fallback--accent` 与 `hv-avatar__fallback--danger` |
|
||||
| 依据 | 上游 `packages/react/src/components/avatar/avatar.tsx` 中 `AvatarFallback` 使用 `composeSlotClassName(slots?.fallback, className, {color})`;`packages/react/src/utils/compose.ts` 调用 `slotFn({color, className})`。tailwind-variants 槽函数带 `color` 参数时**替换**该变体(已用 `tailwind-variants@3.3.1` 实测:`slots.fallback({color:'danger'})` 只输出 `--danger`)。 |
|
||||
|
||||
实现把「父级槽类」与「覆盖槽类」字符串拼接:
|
||||
|
||||
```ts
|
||||
const base = ctx?.slots.value.fallback() ?? "hv-avatar__fallback";
|
||||
const colorClass = props.color
|
||||
? avatarVariants().fallback({ color: props.color })
|
||||
: "";
|
||||
return [base, colorClass].filter(Boolean).join(" ");
|
||||
```
|
||||
|
||||
`base` 已含父级 `--accent`,`colorClass` 再含 `--danger`,两类同时生效。编译后的 CSS 中 `.hv-avatar--soft .hv-avatar__fallback--accent` 等规则会与 `--danger` 规则冲突,最终颜色取决于样式表顺序而非 API 意图。
|
||||
|
||||
**复现(vitest,已本地跑通后删除临时用例):**
|
||||
|
||||
```ts
|
||||
mount(Avatar, {
|
||||
props: { color: "accent" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(AvatarFallback, { color: "danger" }, { default: () => "X" }),
|
||||
},
|
||||
});
|
||||
// 实际 classes: ["hv-avatar__fallback", "hv-avatar__fallback--accent", "hv-avatar__fallback--danger"]
|
||||
// 预期 classes: ["hv-avatar__fallback", "hv-avatar__fallback--danger"]
|
||||
```
|
||||
|
||||
**修复后建议验证:**
|
||||
|
||||
1. 父 `color=accent` + 子 `color=danger` 时,fallback 仅有 `hv-avatar__fallback--danger`。
|
||||
2. 父 `color=accent` + 子不传 `color` 时,保持 `hv-avatar__fallback--accent`(无回归)。
|
||||
3. 子 `class` 仍合并到 fallback。
|
||||
4. 文档 `avatar.md` 的 AvatarFallback API 表“覆盖父级颜色”描述与实现一致。
|
||||
|
||||
### 1.2 [低] AvatarImage 文档声明的 `alt` / `as-child` 未进入 TypeScript props
|
||||
|
||||
| 项 | 内容 |
|
||||
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 严重性 | 低(类型与文档不一致;运行时可用) |
|
||||
| 位置 | `packages/vue/src/components/avatar/AvatarImage.vue:7-14`;`apps/docs/components/avatar.md` AvatarImage API 表 |
|
||||
| 预期 | 文档列出的 `alt`、`asChild` 属于组件 props,或在文档中标明为透传属性 |
|
||||
| 实际 | `defineProps` 仅含 `src/crossOrigin/loading/sizes/srcSet/referrerPolicy`;`alt`、`as-child` 经 `$attrs` 透传到 Reka `AvatarImage` → 原生 `img`,模板可用,但 `AvatarImageProps` 类型中不存在 |
|
||||
| 依据 | `docs/migration-handoff.md` 公共契约层要求「API 文档与代码不一致」需拦截;上游 `Avatar.Image` 的 `alt`/`asChild` 在 API 表与类型中均存在 |
|
||||
|
||||
已用浏览器/jsdom 确认 `alt`、`srcset`、`sizes`、`loading` 会落到 `img`;`@load`/`@error` 也会转发(实测各触发 1 次)。此项不影响运行时演示,但影响类型完备性。
|
||||
|
||||
**修复后建议验证:** `AvatarImageProps` 含 `alt`/`asChild`,或文档改为“透传属性”;`vue-tsc` 通过。
|
||||
|
||||
### 1.3 [低] `delayMs=0` 时 fallback 永不显示,API 文档未标注
|
||||
|
||||
| 项 | 内容 |
|
||||
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 严重性 | 低(已知底座差异,交接报告已写,但公开 API 文档未提示) |
|
||||
| 位置 | `packages/vue/src/components/avatar/AvatarFallback.vue`(`delay-ms` 透传);根因在 `reka-ui@2.11.0` `AvatarFallback.vue`:`canRender = ref(props.delayMs === undefined)`,且 `if (props.delayMs && isClient)` 使 `delayMs=0` 时定时器永不启动 |
|
||||
| 触发条件 | `<AvatarFallback :delay-ms="0">` + 图片加载失败/无图 |
|
||||
| 预期 | 上游 Radix 使用 `delayMs !== undefined`,`delayMs=0` 等价于立即显示 fallback |
|
||||
| 实际 | fallback 节点不渲染(jsdom 实测 `has ZERO: false`;省略 `delayMs` 则正常显示) |
|
||||
| 依据 | 上游 `avatar.mdx`:`delayMs` = “显示 fallback 前的延迟”;交接报告 §7 已记“delayMs={0} 在 Reka 下不会显示 fallback”,但 `apps/docs/components/avatar.md` API 表未提示 |
|
||||
|
||||
**修复后建议验证:** 文档补充“`delayMs=0` 受 Reka 底座限制不会显示”的说明;或在组件层对 `delayMs===0` 改为等价于未延迟。属底座差异时可只改文档并在兼容矩阵登记。
|
||||
|
||||
### 1.4 [信息] Skeleton 文档未保留上游重复的第二节「全局动画配置」
|
||||
|
||||
上游 `skeleton.mdx` 在「自定义样式」与「样式参考」下各有一节「全局动画配置」(内容重复,第二节为英文注释残留)。Vue `skeleton.md` 只保留一处,内容完整。不视为内容缺失;如需严格对照导航层次可补回,不阻塞。
|
||||
|
||||
---
|
||||
|
||||
## 2. 已复核通过的范围
|
||||
|
||||
### 2.1 范围与来源(层次 1)
|
||||
|
||||
- `git diff 56b1ef1` 范围与交接报告一致:新增 4 组件族、26 个演示 SFC、4 个文档页、1 个测试文件;共享文件为 `packages/styles/{src/index.ts,index.css}`、`packages/vue/src/{index.ts,types.ts}`、`package.json`(`test:unit` 追加测试文件)、文档主题 `Layout.vue`/`utilities.css`、`components.md`、`docs/{compatibility,upstream,verification}.md`、Card 三份演示适配。未见越界重构。
|
||||
- 上游 `../heroui` 无未提交改动,仍为 `ce90ea3ab`。
|
||||
- `third-party/HEROUI-LICENSE` 存在;新增 CSS 均带 “Adapted from HeroUI v3, ce90ea3 … See third-party/HEROUI-LICENSE” 头;`docs/upstream.md` 已登记 CloseIcon、shadow-panel/animate-shine、图标替换来源。
|
||||
- 全库无 React/Next 依赖与 `from "react"` 引用;`packages/vue`、`packages/styles` 清单无 react/next 依赖。未新增 npm 依赖。
|
||||
- CloseButton 默认图标为移植的基线 `CloseIcon`(路径与上游 `icons.tsx` 的 `d="M3.47 3.47…"` 一致),符合 AGENTS「可移植上游 SVG」与 M04「不自绘、不把整套图标库变成组件包依赖」。
|
||||
|
||||
### 2.2 公共契约(层次 2)
|
||||
|
||||
- **CloseButton**:`variant` 默认 `default`(仅 `default`);`isDisabled`/`disabled`;默认 `aria-label=Close`;`type=button`;`data-slot=close-button`;默认插槽回退 CloseIcon(`data-slot=close-button-icon`);作用域插槽 `isHovered/isPressed/isFocused/isFocusVisible/isDisabled`。与上游 API 表字段对齐;`onPress`→`@click` 已在文档写明不等价。`type` 不可覆盖(文档写明固定 `button`),与上游 `{...rest}` 可覆盖略有差异,已披露。
|
||||
- **Avatar**:`size` 默认 `md`,`color` 默认 `default`,`variant` 默认 `default`;slots `base/fallback/image` 与五色 fallback、sm/md/lg、soft 变体与上游 `avatar.styles.ts` 一致(仅 `hv-` 前缀)。
|
||||
- **AvatarGroup**:`size` 默认 `md`,`isGrid` 默认 `false`(Boolean prop,`is-grid` 简写可生效),`overlap` 默认 `clip`;`max` 截断 + 自动 `+N`;显式 `AvatarGroupCount` 不受 `max` 截断并抑制自动计数(与上游 `isCountElement` 分流逻辑一致);仅直接子级继承 size/color/variant(`__avatar_group_child` 标记,已验证嵌套 Avatar 不泄漏);默认无 `role=group`。
|
||||
- **Skeleton**:`animationType` 默认 `shimmer` 或 CSS 变量;`shimmer|pulse|none` 与上游 `skeleton.styles.ts` 一致。挂载后读取 `--skeleton-animation`,SSR/首屏回退 `shimmer` 的行为与已知差异相符。
|
||||
- 变体映射(`packages/styles/src/index.ts` 中 `avatarVariants`/`avatarGroupVariants`/`skeletonVariants`)与上游 `*.styles.ts` 逐项一致(类名加 `hv-`)。
|
||||
- 问题见 §1.1–1.3;除此之外 API 文档字段与默认值无缺失。
|
||||
|
||||
### 2.3 交互与原生语义(层次 3)
|
||||
|
||||
`npx --yes pnpm@11.25.0 test`:8 文件 / 86 项通过(含新增 19 项)。
|
||||
`npx --yes pnpm@11.25.0 test:unit`:7 文件 / 85 项通过(含 `tests/close-button-avatar-skeleton.test.ts`)。
|
||||
|
||||
浏览器(`http://127.0.0.1:5173`,桌面,IAB)实测:
|
||||
|
||||
| 项 | 结果 |
|
||||
| ---------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| CloseButton 交互示例 | 点击两次后正文「已点击:2 次」,`aria-label` 同步为「关闭(已点击 2 次)」 |
|
||||
| CloseButton 尺寸 | 默认 24×24、圆角 12px;自定义样式 `size-8` 为 32×32;`type=button`、`aria-label=Close`、`data-slot=close-button` |
|
||||
| CloseButton 禁用 | 单测:`disabled` + `aria-disabled=true`,click 不触发,hover 状态复位 |
|
||||
| Avatar fallback | 无图/失败时显示 fallback;有图时 fallback 隐藏 |
|
||||
| Avatar 尺寸 | sm/md/lg → 32/40/48 |
|
||||
| AvatarGroup max | 3 头像 + `+2` |
|
||||
| AvatarGroup 显式 Count | 3 头像 + `+9`,不受 max 截断 |
|
||||
| AvatarGroup grid | `hv-avatar-group--grid` 生效(5 个头像换行网格) |
|
||||
| AvatarGroup overlap | clip / ring 类均渲染;自定义 `--avatar-group-overlap: 0.7rem` 生效 |
|
||||
| Skeleton 动画 | shimmer 31 / pulse 3 / none 6;父级单次 shimmer 存在 |
|
||||
| 深色主题 | CloseButton 背景 `oklch(0.274 0.006 286.033)`,html.`dark` 生效 |
|
||||
|
||||
### 2.4 样式与主题(层次 4)
|
||||
|
||||
- `close-button.css` / `avatar.css` / `skeleton.css` 与上游逐行一致(仅 `hv-` 类前缀 + 许可证头);`avatar-group.css` 仅格式化换行差异(选择器与数值一致);skeleton 仅少一行上游 TODO 注释。
|
||||
- CSS 变量保持无前缀(`--avatar-size`、`--avatar-group-overlap`、`--skeleton-animation` 等),与上游一致;`--skeleton-animation` 在 `themes/default/variables.css` 有默认值。
|
||||
- 构建产物中 `hv-close-button`/`hv-avatar`/`hv-skeleton`/`hv-avatar-group` 均生成;`status-disabled`/`status-focused` 经 `@apply` 内联(`:disabled`/`[aria-disabled]`、`[data-focus-visible]` 规则存在);`bg-surface-tertiary`、`animate-skeleton`、`text-muted` 等语义工具类已生成。
|
||||
- 演示用 `shadow-panel` / `animate-shine` 放在文档 `utilities.css`,未污染组件包(与 upstream.md 登记一致)。
|
||||
|
||||
### 2.5 文档与演示(层次 5)
|
||||
|
||||
| 文档 | 基线预览 | 已迁移 | 次序 |
|
||||
| ------------ | -------- | ------ | --------------------------------------------------------------------------------------------- |
|
||||
| close-button | 4 | 4/4 | default, interactive, with-custom-icon, custom-styles |
|
||||
| avatar | 7 | 7/7 | basic, sizes, colors, variants, fallback, custom-image-component, custom-styles |
|
||||
| avatar-group | 7 | 7/7 | basic, max, count, sizes, grid, overlap, custom-styles |
|
||||
| skeleton | 8 | 8/8 | basic, text-content, user-profile, list, grid, single-shimmer, animation-types, custom-styles |
|
||||
|
||||
- 预览、展开源码、复制共用同一 SFC(`Demo.vue` 中 `import.meta.glob` 渲染 + `?raw` + `virtual:docs-data` 高亮);浏览器展开 `close-button-interactive` 的源码与磁盘 SFC 一致;复制按钮出现「已复制」反馈。
|
||||
- 演示图标均为 `@tabler/icons-vue`(`IconUser`/`IconCircleX`/`IconX`);演示内无自绘 `<svg>`/`<path>`。上游 `@gravity-ui/icons` Person/CircleXmark/Xmark → Tabler 对应组件,已在 upstream.md 登记。
|
||||
- API 表:`display:table` + `table-layout:fixed`,宽 704px,`scrollWidth==clientWidth` 无水平溢出。
|
||||
- 未在文档预览清单的 `close-button/variants.tsx`、`skeleton/card.tsx` 未迁移,已在交接与 compatibility.md 写明。
|
||||
|
||||
### 2.6 集成与产物(层次 6)
|
||||
|
||||
| 命令 | 结果 |
|
||||
| ----------------------------------- | --------------------------------------- |
|
||||
| `npx --yes pnpm@11.25.0 test` | 86 项通过 |
|
||||
| `npx --yes pnpm@11.25.0 test:unit` | 85 项通过 |
|
||||
| `npx --yes pnpm@11.25.0 typecheck` | 通过 |
|
||||
| `npx --yes pnpm@11.25.0 build:docs` | 通过(styles + components + VitePress) |
|
||||
| `npx --yes pnpm@11.25.0 format` | 通过 |
|
||||
|
||||
构建产物 `packages/vue/dist/index.js` 中 `AvatarGroupCount` 的 `name`/`__name` 保留,`isCountNode` 检测逻辑与源码一致;`isGrid` 编译为 `type: Boolean`。Card 演示已改用 `CloseButton` / `Avatar` 公共组件,不再使用 `closeButtonVariants` 或裸 `reka-ui`。
|
||||
|
||||
---
|
||||
|
||||
## 3. 执行的命令
|
||||
|
||||
```text
|
||||
git -C ../heroui status && git -C ../heroui log -1
|
||||
git diff 56b1ef1 --stat
|
||||
git diff 56b1ef1 -- package.json packages/vue/src/types.ts packages/vue/src/index.ts packages/styles/src/index.ts
|
||||
npx --yes pnpm@11.25.0 test
|
||||
npx --yes pnpm@11.25.0 test:unit
|
||||
npx --yes pnpm@11.25.0 typecheck
|
||||
npx --yes pnpm@11.25.0 build:docs
|
||||
npx --yes pnpm@11.25.0 format
|
||||
```
|
||||
|
||||
另用临时 vitest 用例复现 §1.1(已删除,不留在工作区),并用 IAB 浏览器对 `127.0.0.1:5173` 的 close-button / avatar / avatar-group / skeleton 页做 DOM 与计算样式检查(见 §2.3)。
|
||||
|
||||
对照阅读的上游文件:`close-button.tsx`、`avatar.tsx`、`avatar-group.tsx`、`skeleton.tsx`、`icons.tsx`(CloseIcon)、`compose.ts`、`use-css-variable.ts`、四套 `*.styles.ts` 与 `components/*.css`、CN 文档 `close-button.mdx` / `avatar.mdx` / `avatar-group.mdx` / `skeleton.mdx` 及 `apps/docs/src/demos/cn/{close-button,avatar,avatar-group,skeleton}/`。
|
||||
|
||||
---
|
||||
|
||||
## 4. 未验证项(明确边界)
|
||||
|
||||
以下**未**验证,不能由本报告推断已通过:
|
||||
|
||||
1. Nuxt 水合、SSR 下 Skeleton/Avatar 的完整水合比对(仅有 `tests/ssr.test.ts` 冒烟,且该文件不在 `test:unit` 列表中,由 `pnpm test:ssr` / 全量 `pnpm test` 覆盖)。
|
||||
2. RTL、触屏、读屏(NVDA/VoiceOver)。
|
||||
3. 自动视觉对比与逐像素基线(无位图证据;交接报告亦无位图)。
|
||||
4. `test:browser` / `test:visual` / `test:package` 尚未建立;打包产物安装到独立 Vue 应用未执行。
|
||||
5. 上游原站在固定视口下的逐像素对照(仅做源码/CSS/计算样式对照)。
|
||||
6. Skeleton 挂载后修改 `--skeleton-animation` 的动态刷新(已知不更新,见交接 §7)。
|
||||
7. `delayMs=0` 的产品化决策(见 §1.3)未在本轮给出修复方案选择。
|
||||
|
||||
---
|
||||
|
||||
## 5. 下一步
|
||||
|
||||
1. **修复 §1.1**(中):`AvatarFallback` 的 `color` 覆盖改为替换父级颜色变体(例如对 `ctx.slots.fallback({ color: props.color, className })` 单次求值,或先算基类再去掉父级 `--*` 色相类),并补一条“父 color + 子 color 覆盖”的行为测试。修复后回归 Avatar 回退/变体演示与 `avatar.md` API 表。
|
||||
2. **修复 §1.2**(低):将 `alt`/`asChild` 纳入 `AvatarImage` props 类型,或在文档标明为透传属性;`pnpm typecheck` 确认。
|
||||
3. **处理 §1.3**(低):在 `avatar.md` 的 `delayMs` 行补充 Reka/`delayMs=0` 限制说明,并在 `docs/compatibility.md` 登记;若集成人决定在组件层补偿 `delayMs===0`,需补测试。
|
||||
4. 修复后重跑 `pnpm test`、`pnpm typecheck`、`pnpm build:docs`,并回归 Avatar 相关演示的浏览器检查。
|
||||
5. 未验证项(§4)留给批次 11 / 集成阶段,不扩大本任务验收范围。
|
||||
|
||||
---
|
||||
|
||||
## 6. 审查边界声明
|
||||
|
||||
本报告仅覆盖 M04–M06 声明范围内的 CloseButton、Avatar、AvatarGroup、Skeleton 及其样式、演示、文档与测试,并对共享导出/样式入口做了连带检查。已复核通过不等于 HeroUI 完整兼容,也不等于视觉逐像素一致。若上表之外仍存在缺陷,本报告不作保证。
|
||||
|
||||
---
|
||||
|
||||
## 返工记录(2026-10-21)
|
||||
|
||||
针对上述问题的修复与验证:
|
||||
|
||||
1. **[中] AvatarFallback color 覆盖叠加**(已修)
|
||||
- `AvatarFallback.vue`:改为对 `ctx.slots.fallback` **单次**求值,并把 `color` / `class` 传入槽参数(tailwind-variants 变体替换语义),不再拼接父级色类 + 覆盖色类。
|
||||
- 回归测试 3 项:子覆盖仅 `--danger`;子不覆盖保留 `--accent`;自定义 class 与覆盖色共存。
|
||||
2. **[低] AvatarImage 缺少 `alt` / `asChild` 类型**(已修)
|
||||
- `defineProps` 增加 `alt?: string`、`asChild?: boolean`;文档 API 表与类型一致。
|
||||
3. **[低] `delayMs=0` 未标注**(已修)
|
||||
- `avatar.md` AvatarFallback 表注明 `0` 与未指定不同,底座在 0 时不显示 fallback。
|
||||
4. **[信息] Skeleton 第二节重复「全局动画配置」**(不改)
|
||||
- 上游重复段落内容与前一节等价,本批保留单节完整说明,不复制冗余标题。
|
||||
|
||||
修复后 `pnpm test` 89 项(+3)、`pnpm typecheck`、`pnpm format` 通过。复核结论可从「待修正」重新评估为「通过本任务范围(含上述已修项)」,仍不宣称完整 HeroUI 兼容。
|
||||
|
||||
## 集成人复核:动态更新与条件子项(2026-10-21)
|
||||
|
||||
结论:**待修正,不建议合入本批。** 已确认颜色覆盖与 AvatarImage 类型修复;下面 3 项公共行为问题仍需处理。本轮只改复核记录,未修改组件实现,也未提交。
|
||||
|
||||
### [P2] AvatarFallback / AvatarGroupCount 固化了首次 attrs
|
||||
|
||||
位置:`packages/vue/src/components/avatar/AvatarFallback.vue:17-18` 与 `packages/vue/src/components/avatar/AvatarGroupCount.vue:26-30`。
|
||||
|
||||
两处在 setup 执行时解构 `useAttrs()`,得到的 `restAttrs`、`classAttr` 是首次值的快照。父级更新 `aria-label`、class、style 或事件处理器时,组件仍使用旧值。这不仅影响自定义样式,也会让可访问名称和事件回调过期。
|
||||
|
||||
独立复现:父级用响应式字符串给 Fallback / Count 传 `aria-label=before` 和 `class=before`,挂载后改为 `after`,等待 nextTick;两者 DOM 的 aria-label 仍为 `before`。应在渲染时读取最新 attrs 并合并 class,避免 setup 快照。回归同时覆盖新增、修改、删除属性、class/style 及事件替换,保留 fallback 子颜色覆盖测试。
|
||||
|
||||
### [P2] AvatarGroup 缓存插槽结果,父级替换插槽后显示旧成员
|
||||
|
||||
位置:`packages/vue/src/components/avatar/AvatarGroup.vue:76-77`。
|
||||
|
||||
`computed` 内调用 `slots.default()`,但插槽函数的替换本身不是该 computed 的响应式依赖。父级重新渲染并提供新的闭包时,如果 max 不变且闭包内没有读到新的响应式依赖,渲染仍复用旧 VNode。
|
||||
|
||||
独立复现:父级渲染函数先读取 `const current = items.value`,再传入 `default: () => current.map(...)`。初始 items 为 `['A']`,替换为 `['B', 'C']` 并等待 nextTick,实际仍只显示 `A`。这是合法的 Vue render function 用法;头像成员、名称、图片应随父级更新。应在渲染上下文中重新处理当前插槽,不把插槽结果长期缓存于 computed。补充成员增删、替换、顺序调整及 max / 自动计数联动验证。
|
||||
|
||||
### [P2] AvatarGroup 把 v-if 注释节点计入 max 和溢出人数
|
||||
|
||||
位置:`packages/vue/src/components/avatar/AvatarGroup.vue:65-69`、`:81-91`。
|
||||
|
||||
flattenChildren 把 Fragment 以外的所有 VNode 都作为有效子项,包括 Vue 为未满足的 v-if 生成的 Comment。随后它被分进 avatarNodes,消耗 max 名额并增加 remaining。固定上游用 isValidElement 过滤非元素;Vue 适配应同样跳过条件注释等非成员节点。
|
||||
|
||||
独立复现:默认插槽为 `[createCommentVNode('v-if'), 一个真实 Avatar]`,max=1。实际真实头像被截掉,只渲染 `+1`;预期显示该头像且没有溢出计数。真实模板中,前置的 `<Avatar v-if="false">` 会产生此场景。补充条件节点开关、带空白的 Fragment / v-for,以及显式 Count 的回归用例。
|
||||
|
||||
### 本轮验证与边界
|
||||
|
||||
- 现有 `pnpm test`:8 文件、89 项通过;`pnpm typecheck`、`pnpm build:docs` 均通过。
|
||||
- 另建临时 Vitest 复现 5 项:4 项失败(Fallback attrs、Count attrs、条件注释、替换插槽),1 项通过(CloseButton 动态 aria-label)。临时文件已删除,避免把失败的审查探针混入交付。
|
||||
- 删除临时用例后执行 `pnpm format` 与 `git diff --check`。临时用例曾触发的格式告警不属于项目交付代码。
|
||||
- 本轮依据源码、固定上游与独立行为测试复核;未重做逐页浏览器点击、移动端和位图视觉验收。前文由其他 AI 提供的浏览器记录不冒充本轮独立验证。
|
||||
- 先修复上述 3 项并补充行为回归,再重新评估;现有静态示例和 89 项测试通过不能覆盖动态更新问题。
|
||||
|
||||
---
|
||||
|
||||
## 返工记录:动态更新与条件子项(2026-10-21)
|
||||
|
||||
针对「集成人复核」3 项 P2 的修复与回归:
|
||||
|
||||
1. **[P2] AvatarFallback / AvatarGroupCount 固化首次 attrs**(已修)
|
||||
- 不再在 setup 解构 `$attrs`。`restAttrs` 与 class 改为 computed,在求值时读取当前 `useAttrs()` 键值,父级更新 aria-label、class、style 与事件可同步生效。
|
||||
- 回归:Fallback aria-label/class/style 前后值切换;Count aria-label/class 切换。
|
||||
|
||||
2. **[P2] AvatarGroup 缓存插槽结果**(已修)
|
||||
- 放弃 `computed` 缓存 `slots.default()`;改为在渲染函数内每帧重新 `flattenChildren(slots.default())`,并直接以 `h()` 子节点数组挂载(不用 `<component :is="vnode">`,避免补丁不同步)。
|
||||
- 回归:父级把成员 `['A']` 替换为 `['B','C']` 后 DOM 仅显示 B/C。
|
||||
|
||||
3. **[P2] v-if 注释节点占用 max**(已修)
|
||||
- `flattenChildren` 跳过 `Comment` 与 `Text`(含空白文本),仅保留成员型 VNode;与上游 `isValidElement` 过滤一致。
|
||||
- 回归:`createCommentVNode` + 真实头像 + `max=1` 时显示真实头像且无溢出计数;注释换成第二头像后第一人可见、`+1`;空白文本与显式 Count 共存。
|
||||
|
||||
修复后:`pnpm test` 94 项(+5)、`pnpm typecheck`、`pnpm build:docs`、`pnpm format` 通过。请重新评估是否可从「不建议合入」调整为通过本任务范围;仍不宣称完整 HeroUI 兼容。
|
||||
|
||||
## 集成人二次复核:返工回归(2026-10-21)
|
||||
|
||||
结论:**仍待修正。** 已独立确认 AvatarGroup 替换插槽成员与跳过 Comment 的修复有效;已有属性的值更新测试也通过。但以下 3 项仍阻止通过本批。
|
||||
|
||||
### [P2] 空 attrs 后新增属性仍未透传
|
||||
|
||||
位置:`packages/vue/src/components/avatar/AvatarFallback.vue:18-24`、`packages/vue/src/components/avatar/AvatarGroupCount.vue:27-33`。
|
||||
|
||||
将 attrs 快照改为 computed 仍有缺口:初始没有 class 之外的 attrs 时,循环不读取任何 `attrs[key]`,没有建立能使 computed 失效的属性读取依赖。之后父级首次添加 aria-label、title 或事件时,restAttrs 继续返回缓存的空对象。不能只验证已有属性从 before 改成 after。
|
||||
|
||||
独立复现:挂载 Fallback / Count,最初不传 attrs,父级把传入对象从 `{}` 切换成 `{'aria-label':'new', title:'new'}`,等待 nextTick;两者 DOM 的 aria-label 都仍为 undefined,预期为 new。建议在每次渲染时生成透传对象,避免依赖 computed 对 attrs 的键枚举追踪。回归覆盖空→新增、移除→再次新增、事件处理器新增/替换,以及现有 class/color 合并。
|
||||
|
||||
### [P2] AvatarGroup 渲染函数覆盖调用者 class
|
||||
|
||||
位置:`packages/vue/src/components/avatar/AvatarGroup.vue`,render 返回的 `h('div', { ...attrs, class: variantSlots.value.base(), ... })`。
|
||||
|
||||
从模板改成 h 渲染后,普通对象展开不会自动合并 class;后面的 class 直接覆盖 attrs.class。`<AvatarGroup class="gap-4 custom-group">` 最终只保留 hv-avatar-group 的基础/变体类,调用者样式消失。本批 avatar-group 自定义样式等示例也受影响。应将用户 class 与基础类按 Vue class 语义合并,保留字符串、数组、对象及动态更新能力。
|
||||
|
||||
独立复现:mount(AvatarGroup, { attrs: { class: 'gap-4 custom-group' } }),断言根 classes 包含 custom-group 失败。
|
||||
|
||||
### [P2] props 的 as never 使公开变体类型失去约束
|
||||
|
||||
位置:`packages/vue/src/components/avatar/AvatarGroup.vue:54-67`。
|
||||
|
||||
color、size、variant、overlap 的运行时声明整体被断言为 never;生成声明也出现 `color: never; size: never; variant: never; overlap: never`。这没有保留原来的字面量联合契约:公开 AvatarGroupProps 现在接受数字尺寸与任意颜色/变体值,类型检查无法提示误用。
|
||||
|
||||
独立类型复现:临时 TS 文件导入公开 AvatarGroupProps,赋值 `{ size: 123, color: 'not-a-color', overlap: 'invalid', variant: 'invalid' }`,vue-tsc --noEmit 竟然通过。应使用 `PropType<AvatarVariants['size']>` 等正确的运行时 props 类型,保留默认值和对应联合类型。验证合法值可用、非法值确实报错,并检查构建后的 d.ts。
|
||||
|
||||
### 本轮执行与范围
|
||||
|
||||
- 项目现有测试:8 文件 / 94 项通过;类型检查及完整文档构建通过。
|
||||
- 独立临时行为复现 4 项:替换插槽成员并忽略注释通过;自定义 class、Fallback 首次新增 attrs、Count 首次新增 attrs 共 3 项失败。
|
||||
- 独立临时类型复现:非法 props 未被类型检查拒绝,确认公开类型回归。
|
||||
- 临时行为与类型文件已删除;最终执行 pnpm format 与 git diff --check。
|
||||
- 本轮不改组件、不提交,也不重做逐页浏览器检查。成员更新/计数已修复的结论不覆盖以上残留与新增回归。
|
||||
|
||||
---
|
||||
|
||||
## 返工记录:新增 attrs / class 合并 / 类型约束(2026-10-21)
|
||||
|
||||
针对二次复核 3 项 P2:
|
||||
|
||||
1. **[P2] 空 attrs 后新增属性丢失**(已修)
|
||||
- `restAttrs` / `fallbackClass` / `countClass` 改为在模板渲染时调用的函数,不再用 computed 缓存键枚举结果。
|
||||
- 回归:空 attrs → 新增 `aria-label`/`title` → 删除 → 再次新增。
|
||||
|
||||
2. **[P2] AvatarGroup 覆盖调用者 class**(已修)
|
||||
- `h('div', { class: [variantSlots.base(), attrs.class] })` 合并调用方 class(含数组/对象)。
|
||||
- 回归:`attrs.class = "gap-4 custom-group"` 同时保留基础类;浏览器自定义样式示例 `[--avatar-group-overlap:…]` 仍在根节点。
|
||||
|
||||
3. **[P2] `as never` 使变体类型失去约束**(已修)
|
||||
- `PropType<AvatarVariants["size"|"color"|"variant"]>`、`PropType<AvatarGroupVariants["overlap"]>`。
|
||||
- 构建产物 d.ts:`size: "md"|"lg"|"sm"|"undefined"`、`color: "danger"|…`、`overlap: "clip"|"ring"`。
|
||||
- 回归:`@ts-expect-error` 拒绝 `size: 123` / `color: 'nope'` / `overlap: 'invalid'`;合法值可赋值。
|
||||
|
||||
修复后:`pnpm test` 98 项(+4)、`pnpm typecheck`、`pnpm build:docs`、`pnpm format` 通过。请再次评估合入;仍不宣称完整 HeroUI 兼容。
|
||||
|
||||
## 集成人三次复核:本批代码与构建复核通过(2026-10-21)
|
||||
|
||||
当前结论:**通过本批代码与构建复核,未发现新的阻塞问题。** 本节替代前文待修正的当前状态,历史问题与返工过程保留。此结论不扩大为完整视觉、读屏或 HeroUI 全部兼容验收。
|
||||
|
||||
- AvatarFallback / AvatarGroupCount 的 attrs 改为渲染时读取,空对象后新增、删除后再次新增、class/style 更新和事件处理器替换均通过独立复现;旧事件在删除后不会继续触发。
|
||||
- AvatarGroup 合并调用方字符串、数组与对象 class,动态更新后保留基础类并移除旧类;自定义 class 被覆盖的问题已修复。
|
||||
- AvatarGroup 使用 PropType 保留公开变体联合类型。独立类型检查直接导入本轮构建的 `packages/vue/dist/index` 中 AvatarGroupProps:合法值通过,数字 size、非法 color / overlap / variant 均被拒绝;未靠源码 alias 验证这一结论。
|
||||
- 同时回归插槽闭包成员替换、键控成员重排、max 从 1 改为 2 与自动计数联动、条件 Comment 过滤,结果正确。
|
||||
- `pnpm test`:8 文件 / 98 项通过;`pnpm typecheck`、`pnpm build:docs` 通过。独立临时行为复现 3 项通过,另有发布声明类型探针通过;临时文件均已删除。
|
||||
- 本轮只更新此复核记录,未改组件实现、未提交。删除探针后执行 `pnpm format` 与 `git diff --check`,均通过。
|
||||
- 本轮未逐页重做浏览器视觉检查,移动端、位图对比、读屏、Nuxt 水合及独立安装等既有未验证边界仍保留。Avatar delayMs=0、Skeleton 挂载后 CSS 变量更新等已披露差异保持原记录。
|
||||
+11
-7
@@ -7,15 +7,16 @@
|
||||
|
||||
## 已移植
|
||||
|
||||
- packages/styles/components/{button,close-button,card,input,textarea,switch,switch-group,label,description,surface,link,spinner}.css:只将组件类名加 hv- 前缀;Vue 状态适配集中在样式入口和组件层。
|
||||
- packages/styles/components/{button,close-button,card,input,textarea,switch,switch-group,label,description,surface,link,spinner,avatar,avatar-group,skeleton}.css:只将组件类名加 hv- 前缀;Vue 状态适配集中在样式入口和组件层。
|
||||
- packages/styles/themes/default/variables.css、themes/shared/theme.css:主题变量、OKLCH 颜色、派生公式和圆角尺寸。
|
||||
- packages/styles/utilities、variants:焦点、禁用、减少动画等构建规则。
|
||||
- packages/styles/src/components/{button,card,input,textarea,switch,surface,link,spinner}/*.styles.ts:变体与类名映射,增加命名空间。
|
||||
- apps/docs/content/docs/cn/react/components 下 Button/Card/Input/Switch/Surface/Link/Spinner 的标题、说明、示例顺序和 API 描述;React 特有部分转换为 Vue 用法。
|
||||
- apps/docs/src/demos/cn 下 Button/Card/Input/Switch/Surface/Link/Spinner 文档引用的基线示例文案与布局;文档由新项目 SFC 实现。
|
||||
- packages/react/src/components/icons.tsx 的 ExternalLinkIcon:LinkIcon 默认外部箭头图标。
|
||||
- packages/styles/src/components/{button,card,input,textarea,switch,surface,link,spinner,close-button,avatar,avatar-group,skeleton}/*.styles.ts:变体与类名映射,增加命名空间。
|
||||
- apps/docs/content/docs/cn/react/components 下 Button/Card/Input/Switch/Surface/Link/Spinner/CloseButton/Avatar/AvatarGroup/Skeleton 的标题、说明、示例顺序和 API 描述;React 特有部分转换为 Vue 用法。
|
||||
- apps/docs/src/demos/cn 下 Button/Card/Input/Switch/Surface/Link/Spinner/CloseButton/Avatar/AvatarGroup/Skeleton 文档引用的基线示例文案与布局;文档由新项目 SFC 实现。
|
||||
- packages/react/src/components/icons.tsx 的 ExternalLinkIcon:LinkIcon 默认外部箭头图标;CloseIcon:CloseButton 默认关闭图标。
|
||||
- packages/react/src/components/spinner/spinner.tsx 的 SpinnerPrimitive SVG(渐变路径)。
|
||||
- apps/docs/public/fonts/Inter-{Regular,Medium,Bold}.ttf:文档字体资源。
|
||||
- apps/docs/src/app/global.css 的 `animate-shine` / `shine` 关键帧与 Skeleton 演示用 `shadow-panel`:放在文档 utilities.css,不进入组件包。
|
||||
|
||||
## 来源声明
|
||||
|
||||
@@ -25,11 +26,14 @@
|
||||
|
||||
## 本批文档适配
|
||||
|
||||
- Card 的头像使用已安装 Reka Avatar 的加载和 fallback 机制;图片沿用上游 CDN URL,不复制媒体文件。关闭按钮使用原生 button、closeButtonVariants 与基线 CloseButton CSS 组合;Vue CloseButton 组件尚未实现。
|
||||
- Card 链接使用本库 Link + LinkIcon(默认基线图标);关闭按钮仍为原生组合。
|
||||
- Card 的头像改用本库 Avatar/AvatarImage/AvatarFallback(内部为 Reka Avatar);图片沿用上游 CDN URL,不复制媒体文件。关闭按钮改用本库 CloseButton(默认基线 CloseIcon)。
|
||||
- Card 链接使用本库 Link + LinkIcon(默认基线图标)。
|
||||
- Card 表单使用原生 form/label 与 Input 组合,提交仅展示本地反馈,不实现登录与密码找回服务。忘记密码链接使用 Link 与本地反馈。
|
||||
- SwitchGroup 的方向布局 CSS 来自同一基线。Switch 的 native/ARIA 校验、表单 checkbox、reset、属性与事件透传由 Vue 状态层实现;FieldError 暂仅接入 Switch。
|
||||
- Surface 搭配表单示例使用 Input 与 TextArea 的 secondary 变体;TextArea 为本批为演示移植的最小实现。
|
||||
- Link 自定义图标示例将上游 `@gravity-ui/icons` 的 ArrowUpRightFromSquare / Link 替换为 Tabler `IconExternalLink` / `IconLink`(MIT),与项目图标约定一致。
|
||||
- Spinner 内部 SVG 来自基线 SpinnerPrimitive,不属于演示图标;Button 加载示例改用 Spinner(`color="current" size="sm"`),与上游 CN loading 示例一致。
|
||||
- CloseButton 自定义图标示例将上游 `@gravity-ui/icons` 的 CircleXmark / Xmark 替换为 Tabler `IconCircleX` / `IconX`;默认关闭图标为移植的基线 CloseIcon。
|
||||
- Avatar 回退/变体与 AvatarGroup 自定义样式示例中的 Person 图标替换为 Tabler `IconUser`。Avatar 自定义图片组件示例以本地 FrameworkImage 演示 asChild,对应上游 Next.js Image 组合。Avatar 变体示例中的 Separator 以分隔线 div 适配。
|
||||
- Skeleton 演示沿用上游 `shadow-panel` 与 `animate-shine` 类名,并在文档 utilities.css 中提供对应定义(上游放在 docs global.css)。
|
||||
- 图标统一使用 @tabler/icons-vue(MIT)的官方组件,未移植 React 图标依赖;尚未完成自动逐像素对比。
|
||||
|
||||
@@ -89,3 +89,45 @@
|
||||
- 实际 IAB 浏览器检查(1280×720):Button、Card、Input、Link、Spinner、Surface、Switch、主题、安装共 9 页的 13 张表格均铺满 736px 正文宽度,无表格及单元格水平溢出;Button 的 API 表与作用域插槽状态表宽度一致。
|
||||
- 安装页浅色、深色复制图标中心偏差均为 0px;点击复制后出现“代码已复制”反馈。检查了 Button API 长类型换行的实际页面外观。本轮未新增移动视口与自动视觉验收。
|
||||
- pnpm test(67 项)、vue-tsc --noEmit、pnpm build:docs、Prettier 与 git diff --check 通过。
|
||||
|
||||
## CloseButton / Avatar / AvatarGroup / Skeleton 迁移验证(M04–M06)
|
||||
|
||||
验证日期:2026-10-21。开发地址 `http://127.0.0.1:5173`,桌面视口,IAB 浏览器。
|
||||
|
||||
- `pnpm test`:8 个测试文件、86 项全部通过(新增 19 项 CloseButton/Avatar/AvatarGroup/Skeleton 行为与清单测试)。
|
||||
- `pnpm typecheck` 通过;`pnpm build:docs`(含 styles + components + VitePress)通过;`pnpm format` 通过。
|
||||
- CloseButton:默认 24×24、圆角 12px、背景 `oklch(0.94 0.001 286.375)`、文字 muted、`type=button`、`aria-label=Close`、内置 CloseIcon;交互示例点击后计数 1→2 且 aria-label 同步;深色主题背景切换为 `oklch(0.274 0.006 286.033)`。
|
||||
- Avatar:默认尺寸 40px、圆角 24px;sm/md/lg 均存在;soft 变体与 fallback 五色类生效;深色下 fallback 文字 `oklch(0.9911 0 0)`。
|
||||
- AvatarGroup:clip 遮罩 `radial-gradient(...)`、ring 阴影 `oklch(0.9702 0 0) 0 0 0 2px`、`--avatar-group-overlap: 0.5rem`;max 自动计数 +2、显式 Count +9 不受截断;isGrid 类在 boolean prop 修正后生效。
|
||||
- Skeleton:shimmer/pulse/none 三类均渲染;父级单次 shimmer 存在;深色背景 `oklab(0.2721… / 0.7)`。
|
||||
- 文档表格:CloseButton 页 3 张表均为 `display:table`、`table-layout:fixed`、宽 704px 与正文一致,`scrollWidth == clientWidth` 无水平溢出。
|
||||
- IAB 截图接口持续超时(compositor 未返回帧),本轮未保存位图证据;以上为 DOM/计算样式记录,不等同于逐像素视觉验收。未执行 Nuxt 水合、RTL、触屏与读屏验证。
|
||||
|
||||
## M04–M06 独立复核返工(2026-10-21)
|
||||
|
||||
独立复核结论「待修正」,问题与处理:
|
||||
|
||||
1. [中] `AvatarFallback` 的 `color` 覆盖与父级色类叠加。已改为槽函数单次求值替换变体;新增 3 项回归测试(覆盖/继承/自定义 class)。
|
||||
2. [低] `AvatarImage` 补齐 `alt`/`asChild` 类型声明,与 API 表一致。
|
||||
3. [低] `avatar.md` 标注 `delayMs=0` 与未指定行为差异。
|
||||
4. [信息] Skeleton 上游重复的第二节「全局动画配置」不复制,保留单节说明。
|
||||
|
||||
`pnpm test` 89 项(+3)、`pnpm typecheck`、`pnpm format` 通过。详见 `docs/migrations/M04-M06-review.md` 返工记录。
|
||||
|
||||
## M04–M06 动态更新与条件子项返工(2026-10-21)
|
||||
|
||||
集成人复核 3 项 P2 已修:
|
||||
|
||||
1. AvatarFallback / AvatarGroupCount 不再解构 `$attrs` 快照,渲染期读取最新 attrs。
|
||||
2. AvatarGroup 每帧重读插槽,父级替换成员后不再显示旧头像;子节点以 `h()` 数组挂载。
|
||||
3. 跳过 v-if 注释与空白文本节点,不再占用 max 名额。
|
||||
|
||||
回归 5 项;`pnpm test` 94 项、`typecheck`、`build:docs`、`format` 通过。详见 `docs/migrations/M04-M06-review.md`。
|
||||
|
||||
## M04–M06 二次返工(2026-10-21)
|
||||
|
||||
1. Fallback/Count 渲染期生成透传属性,支持挂载后新增 aria-label 等。
|
||||
2. AvatarGroup 合并调用方 class(gap-* / CSS 变量)。
|
||||
3. AvatarGroup props 使用 PropType,非法 size/color/overlap 被 vue-tsc 拒绝。
|
||||
|
||||
`pnpm test` 98 项、typecheck、build:docs、format 通过;浏览器确认自定义 class 保留。文档服务曾退出,已重启于 127.0.0.1:5173。
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
|
||||
"typecheck": "vue-tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
"test:unit": "vitest run tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts",
|
||||
"test:unit": "vitest run tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts",
|
||||
"test:ssr": "vitest run tests/ssr.test.ts",
|
||||
"format": "prettier --check .",
|
||||
"format:fix": "prettier --write .",
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
|
||||
/* ==========================================================================
|
||||
AvatarGroup - Stacked or grid layout for multiple avatars
|
||||
========================================================================== */
|
||||
|
||||
.hv-avatar-group {
|
||||
--avatar-group-overlap: 0.5rem;
|
||||
--avatar-group-seam: 2px;
|
||||
|
||||
@apply inline-flex items-center;
|
||||
}
|
||||
|
||||
/* Grid */
|
||||
.hv-avatar-group--grid {
|
||||
@apply flex-wrap gap-3;
|
||||
}
|
||||
|
||||
.hv-avatar-group:not(.hv-avatar-group--grid) > .hv-avatar + .hv-avatar,
|
||||
.hv-avatar-group:not(.hv-avatar-group--grid)
|
||||
> .hv-avatar
|
||||
+ .hv-avatar-group__count {
|
||||
margin-inline-start: calc(-1 * var(--avatar-group-overlap, 0.5rem));
|
||||
}
|
||||
|
||||
.hv-avatar-group__count {
|
||||
@apply shrink-0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Overlap: ring
|
||||
-------------------------------------------------------------------------- */
|
||||
.hv-avatar-group--ring:not(.hv-avatar-group--grid) > .hv-avatar,
|
||||
.hv-avatar-group--ring:not(.hv-avatar-group--grid) > .hv-avatar-group__count {
|
||||
position: relative;
|
||||
box-shadow: 0 0 0 var(--avatar-group-seam, 2px) var(--background);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Overlap: clip
|
||||
Cut sits on the inline-end edge (LTR: right / RTL: left). Optical nudge uses
|
||||
padding-inline-end so fallback glyphs stay logical in both directions.
|
||||
-------------------------------------------------------------------------- */
|
||||
.hv-avatar-group--clip:not(.hv-avatar-group--grid)
|
||||
> .hv-avatar:not(:last-child) {
|
||||
--avatar-group-cut-center: calc(
|
||||
100% + (var(--avatar-size, 2.5rem) / 2) -
|
||||
var(--avatar-group-overlap, 0.5rem)
|
||||
);
|
||||
--avatar-group-cut-radius: calc(
|
||||
(var(--avatar-size, 2.5rem) / 2) + var(--avatar-group-seam, 2px)
|
||||
);
|
||||
|
||||
-webkit-mask-image: radial-gradient(
|
||||
circle at var(--avatar-group-cut-center) 50%,
|
||||
transparent var(--avatar-group-cut-radius),
|
||||
#000 var(--avatar-group-cut-radius)
|
||||
);
|
||||
mask-image: radial-gradient(
|
||||
circle at var(--avatar-group-cut-center) 50%,
|
||||
transparent var(--avatar-group-cut-radius),
|
||||
#000 var(--avatar-group-cut-radius)
|
||||
);
|
||||
}
|
||||
|
||||
.hv-avatar-group--clip:not(.hv-avatar-group--grid):dir(rtl)
|
||||
> .hv-avatar:not(:last-child),
|
||||
:dir(rtl)
|
||||
.hv-avatar-group--clip:not(.hv-avatar-group--grid)
|
||||
> .hv-avatar:not(:last-child) {
|
||||
--avatar-group-cut-center: calc(
|
||||
0% - (var(--avatar-size, 2.5rem) / 2) + var(--avatar-group-overlap, 0.5rem)
|
||||
);
|
||||
}
|
||||
|
||||
.hv-avatar-group--clip:not(.hv-avatar-group--grid)
|
||||
> .hv-avatar:not(:last-child)
|
||||
.hv-avatar__fallback {
|
||||
box-sizing: border-box;
|
||||
padding-inline-end: calc(var(--avatar-group-overlap, 0.5rem) * 0.35);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
|
||||
/* Base avatar styles */
|
||||
.hv-avatar {
|
||||
@apply relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-3xl bg-default;
|
||||
}
|
||||
|
||||
/* Avatar fallback element */
|
||||
.hv-avatar__fallback {
|
||||
@apply flex size-full items-center justify-center bg-default text-sm font-medium;
|
||||
}
|
||||
|
||||
/* Avatar image element */
|
||||
.hv-avatar__image {
|
||||
@apply absolute inset-0 aspect-square size-full;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
*/
|
||||
@apply transition-opacity duration-250 motion-reduce:transition-none;
|
||||
}
|
||||
|
||||
/* Size modifiers */
|
||||
.hv-avatar--sm {
|
||||
--avatar-size: 2rem; /* size-8 */
|
||||
|
||||
@apply size-8 rounded-2xl;
|
||||
|
||||
.hv-avatar__fallback {
|
||||
@apply text-xs;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-avatar--md {
|
||||
--avatar-size: 2.5rem; /* size-10 — same as base */
|
||||
|
||||
/* No layout styles as this is the default size */
|
||||
}
|
||||
|
||||
.hv-avatar--lg {
|
||||
--avatar-size: 3rem; /* size-12 */
|
||||
|
||||
@apply size-12 rounded-3xl;
|
||||
|
||||
.hv-avatar__fallback {
|
||||
@apply text-base;
|
||||
}
|
||||
}
|
||||
|
||||
/* Color modifiers for fallback */
|
||||
.hv-avatar__fallback--accent {
|
||||
@apply text-accent-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar__fallback--default {
|
||||
@apply text-default-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar__fallback--success {
|
||||
@apply text-success-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar__fallback--warning {
|
||||
@apply text-warning-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar__fallback--danger {
|
||||
@apply text-danger-soft-foreground;
|
||||
}
|
||||
|
||||
/* Variant modifiers */
|
||||
.hv-avatar--soft {
|
||||
@apply bg-transparent;
|
||||
}
|
||||
|
||||
.hv-avatar--soft .hv-avatar__fallback--accent {
|
||||
@apply bg-accent-soft text-accent-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar--soft .hv-avatar__fallback--success {
|
||||
@apply bg-success-soft text-success-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar--soft .hv-avatar__fallback--warning {
|
||||
@apply bg-warning-soft text-warning-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar--soft .hv-avatar__fallback--default {
|
||||
@apply bg-default-soft text-default-soft-foreground;
|
||||
}
|
||||
|
||||
.hv-avatar--soft .hv-avatar__fallback--danger {
|
||||
@apply bg-danger-soft text-danger-soft-foreground;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
|
||||
.hv-skeleton {
|
||||
@apply pointer-events-none relative overflow-hidden rounded-sm bg-surface-tertiary/70;
|
||||
}
|
||||
|
||||
/* Animation types */
|
||||
.hv-skeleton--shimmer {
|
||||
&::after {
|
||||
@apply absolute inset-0 -translate-x-full animate-skeleton bg-linear-to-r from-transparent via-surface-tertiary to-transparent content-[''];
|
||||
}
|
||||
|
||||
/* When applied to a parent container with multiple skeletons */
|
||||
&:has(.hv-skeleton) {
|
||||
&::after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
/* Single synchronized shimmer that passes over all children */
|
||||
&::before {
|
||||
@apply absolute inset-0 -translate-x-full animate-skeleton content-[''];
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent 0%,
|
||||
rgba(255, 255, 255, 0.5) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
z-index: 10;
|
||||
pointer-events: none;
|
||||
/* Use mix-blend-mode to only show over skeleton elements */
|
||||
mix-blend-mode: overlay;
|
||||
}
|
||||
|
||||
/* Ensure children don't have their own shimmer */
|
||||
& .hv-skeleton {
|
||||
&::after {
|
||||
content: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hv-skeleton--pulse {
|
||||
@apply animate-pulse;
|
||||
}
|
||||
|
||||
.hv-skeleton--none {
|
||||
}
|
||||
@@ -17,6 +17,9 @@
|
||||
@import "./components/surface.css" layer(components);
|
||||
@import "./components/link.css" layer(components);
|
||||
@import "./components/spinner.css" layer(components);
|
||||
@import "./components/avatar.css" layer(components);
|
||||
@import "./components/avatar-group.css" layer(components);
|
||||
@import "./components/skeleton.css" layer(components);
|
||||
/* The Vue Switch uses Reka's native button for its clickable content. */
|
||||
@layer components {
|
||||
.hv-switch:has(.hv-switch__content:focus-visible) .hv-switch__control {
|
||||
|
||||
@@ -198,3 +198,100 @@ export const textAreaVariants = tv({
|
||||
});
|
||||
|
||||
export type TextAreaVariants = VariantProps<typeof textAreaVariants>;
|
||||
|
||||
export const avatarVariants = tv({
|
||||
defaultVariants: {
|
||||
color: "default",
|
||||
size: "md",
|
||||
},
|
||||
slots: {
|
||||
base: "hv-avatar",
|
||||
fallback: "hv-avatar__fallback",
|
||||
image: "hv-avatar__image",
|
||||
},
|
||||
variants: {
|
||||
color: {
|
||||
accent: {
|
||||
fallback: "hv-avatar__fallback--accent",
|
||||
},
|
||||
danger: {
|
||||
fallback: "hv-avatar__fallback--danger",
|
||||
},
|
||||
default: {
|
||||
fallback: "hv-avatar__fallback--default",
|
||||
},
|
||||
success: {
|
||||
fallback: "hv-avatar__fallback--success",
|
||||
},
|
||||
warning: {
|
||||
fallback: "hv-avatar__fallback--warning",
|
||||
},
|
||||
},
|
||||
size: {
|
||||
lg: {
|
||||
base: "hv-avatar--lg",
|
||||
},
|
||||
md: {
|
||||
base: "hv-avatar--md",
|
||||
},
|
||||
sm: {
|
||||
base: "hv-avatar--sm",
|
||||
},
|
||||
},
|
||||
variant: {
|
||||
default: {},
|
||||
soft: {
|
||||
base: "hv-avatar--soft",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type AvatarVariants = VariantProps<typeof avatarVariants>;
|
||||
|
||||
export const avatarGroupVariants = tv({
|
||||
defaultVariants: {
|
||||
isGrid: false,
|
||||
overlap: "clip",
|
||||
},
|
||||
slots: {
|
||||
base: "hv-avatar-group",
|
||||
count: "hv-avatar-group__count",
|
||||
},
|
||||
variants: {
|
||||
isGrid: {
|
||||
false: {},
|
||||
true: {
|
||||
base: "hv-avatar-group--grid",
|
||||
},
|
||||
},
|
||||
overlap: {
|
||||
clip: {
|
||||
base: "hv-avatar-group--clip",
|
||||
},
|
||||
ring: {
|
||||
base: "hv-avatar-group--ring",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type AvatarGroupVariants = VariantProps<typeof avatarGroupVariants>;
|
||||
|
||||
export const skeletonVariants = tv({
|
||||
defaultVariants: {
|
||||
animationType: "shimmer",
|
||||
},
|
||||
slots: {
|
||||
base: "hv-skeleton",
|
||||
},
|
||||
variants: {
|
||||
animationType: {
|
||||
none: "hv-skeleton--none",
|
||||
pulse: "hv-skeleton--pulse",
|
||||
shimmer: "hv-skeleton--shimmer",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type SkeletonVariants = VariantProps<typeof skeletonVariants>;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, provide, useAttrs } from "vue";
|
||||
import { AvatarRoot } from "reka-ui";
|
||||
import { avatarVariants, type AvatarVariants } from "@heroui-vue/styles";
|
||||
import { avatarContextKey, avatarGroupContextKey } from "./context";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
const props = defineProps<{
|
||||
color?: AvatarVariants["color"];
|
||||
size?: AvatarVariants["size"];
|
||||
variant?: AvatarVariants["variant"];
|
||||
/** Marks a direct AvatarGroup child (see AVATAR_GROUP_CHILD). */
|
||||
__avatar_group_child?: boolean;
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const groupCtx = inject(avatarGroupContextKey, undefined);
|
||||
const isGroupChild = computed(() => props.__avatar_group_child === true);
|
||||
|
||||
const dataSlot = computed(() =>
|
||||
typeof attrs["data-slot"] === "string" ? attrs["data-slot"] : "avatar",
|
||||
);
|
||||
|
||||
const finalSize = computed(
|
||||
() => props.size ?? (isGroupChild.value ? groupCtx?.value.size : undefined),
|
||||
);
|
||||
const finalColor = computed(
|
||||
() => props.color ?? (isGroupChild.value ? groupCtx?.value.color : undefined),
|
||||
);
|
||||
const finalVariant = computed(
|
||||
() =>
|
||||
props.variant ?? (isGroupChild.value ? groupCtx?.value.variant : undefined),
|
||||
);
|
||||
|
||||
const slots = computed(() =>
|
||||
avatarVariants({
|
||||
color: finalColor.value,
|
||||
size: finalSize.value,
|
||||
variant: finalVariant.value,
|
||||
}),
|
||||
);
|
||||
|
||||
provide(avatarContextKey, { slots });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AvatarRoot v-bind="attrs" :class="slots.base()" :data-slot="dataSlot">
|
||||
<slot />
|
||||
</AvatarRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import { inject, useAttrs } from "vue";
|
||||
import { AvatarFallback } from "reka-ui";
|
||||
import { avatarVariants, type AvatarVariants } from "@heroui-vue/styles";
|
||||
import { avatarContextKey } from "./context";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
const props = defineProps<{
|
||||
delayMs?: number;
|
||||
color?: AvatarVariants["color"];
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const ctx = inject(avatarContextKey, undefined);
|
||||
|
||||
// Built during render (not cached): key additions/removals on $attrs must not
|
||||
// depend on computed invalidation of an initially empty key set.
|
||||
function restAttrs() {
|
||||
const rest: Record<string, unknown> = {};
|
||||
for (const key of Object.keys(attrs)) {
|
||||
if (key !== "class") rest[key] = attrs[key];
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
// Single tv slot call so a local `color` replaces the inherited variant
|
||||
// instead of concatenating a second `--color` class (upstream composeSlotClassName).
|
||||
function fallbackClass() {
|
||||
const slotArgs: Record<string, unknown> = { class: attrs.class };
|
||||
if (props.color !== undefined) slotArgs.color = props.color;
|
||||
const slot = ctx?.slots.value.fallback ?? avatarVariants().fallback;
|
||||
return slot(slotArgs);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AvatarFallback
|
||||
v-bind="restAttrs()"
|
||||
:delay-ms="delayMs"
|
||||
:class="fallbackClass()"
|
||||
data-slot="avatar-fallback"
|
||||
>
|
||||
<slot />
|
||||
</AvatarFallback>
|
||||
</template>
|
||||
@@ -0,0 +1,150 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
Comment,
|
||||
Fragment,
|
||||
Text,
|
||||
cloneVNode,
|
||||
computed,
|
||||
defineComponent,
|
||||
h,
|
||||
isVNode,
|
||||
provide,
|
||||
useAttrs,
|
||||
type PropType,
|
||||
type VNode,
|
||||
type VNodeChild,
|
||||
} from "vue";
|
||||
import {
|
||||
avatarGroupVariants,
|
||||
type AvatarGroupVariants,
|
||||
type AvatarVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
import { avatarGroupContextKey } from "./context";
|
||||
import AvatarGroupCount from "./AvatarGroupCount.vue";
|
||||
|
||||
function isCountNode(node: VNode): boolean {
|
||||
const type = node.type as { name?: string; __name?: string } | string;
|
||||
if (typeof type !== "object" || type === null) return false;
|
||||
return type.name === "AvatarGroupCount" || type.__name === "AvatarGroupCount";
|
||||
}
|
||||
|
||||
/** Keep only member-like elements; skip comments, text and other non-members. */
|
||||
function flattenChildren(nodes: VNodeChild[], out: VNode[] = []): VNode[] {
|
||||
for (const child of nodes) {
|
||||
if (Array.isArray(child)) {
|
||||
flattenChildren(child, out);
|
||||
continue;
|
||||
}
|
||||
if (!isVNode(child)) continue;
|
||||
if (child.type === Comment || child.type === Text) continue;
|
||||
if (child.type === Fragment && Array.isArray(child.children)) {
|
||||
flattenChildren(child.children as VNodeChild[], out);
|
||||
continue;
|
||||
}
|
||||
out.push(child);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: "AvatarGroup",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
color: {
|
||||
type: String as PropType<AvatarVariants["color"]>,
|
||||
default: undefined,
|
||||
},
|
||||
size: {
|
||||
type: String as PropType<AvatarVariants["size"]>,
|
||||
default: "md",
|
||||
},
|
||||
variant: {
|
||||
type: String as PropType<AvatarVariants["variant"]>,
|
||||
default: undefined,
|
||||
},
|
||||
max: { type: Number, default: undefined },
|
||||
isGrid: { type: Boolean, default: false },
|
||||
overlap: {
|
||||
type: String as PropType<AvatarGroupVariants["overlap"]>,
|
||||
default: "clip",
|
||||
},
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
const variantSlots = computed(() =>
|
||||
avatarGroupVariants({
|
||||
isGrid: props.isGrid,
|
||||
overlap: props.overlap,
|
||||
}),
|
||||
);
|
||||
|
||||
const countClass = computed(() => variantSlots.value.count());
|
||||
|
||||
const groupContext = computed(() => ({
|
||||
size: props.size,
|
||||
color: props.color,
|
||||
variant: props.variant,
|
||||
countClass: countClass.value,
|
||||
}));
|
||||
|
||||
provide(avatarGroupContextKey, groupContext);
|
||||
|
||||
/**
|
||||
* Re-read the default slot on every render. Slot-function identity is not a
|
||||
* reactive dependency, so caching in `computed` shows stale members after the
|
||||
* parent swaps the slot closure. Returning vnodes as `h()` children (not via
|
||||
* `<component :is="vnode">`) keeps patches in sync with the latest props.
|
||||
*/
|
||||
function render() {
|
||||
const flat = flattenChildren((slots.default?.() ?? []) as VNodeChild[]);
|
||||
|
||||
const avatarNodes: VNode[] = [];
|
||||
const countNodes: VNode[] = [];
|
||||
for (const node of flat) {
|
||||
if (isCountNode(node)) countNodes.push(node);
|
||||
else avatarNodes.push(node);
|
||||
}
|
||||
|
||||
const visible =
|
||||
props.max == null
|
||||
? avatarNodes
|
||||
: avatarNodes.slice(0, Math.max(0, props.max as number));
|
||||
const remaining =
|
||||
props.max == null
|
||||
? 0
|
||||
: Math.max(0, avatarNodes.length - visible.length);
|
||||
|
||||
const children: VNode[] = visible.map((child) =>
|
||||
cloneVNode(child, { __avatar_group_child: true }),
|
||||
);
|
||||
|
||||
const hasExplicitCount = countNodes.length > 0;
|
||||
if (hasExplicitCount) {
|
||||
children.push(...countNodes);
|
||||
} else if (remaining > 0) {
|
||||
children.push(
|
||||
h(
|
||||
AvatarGroupCount,
|
||||
{ key: "avatar-group-auto-count" },
|
||||
{
|
||||
default: () => `+${remaining}`,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return h(
|
||||
"div",
|
||||
{
|
||||
...attrs,
|
||||
// Merge caller class with component classes (object spread would drop it).
|
||||
class: [variantSlots.value.base(), attrs.class],
|
||||
"data-slot": "avatar-group",
|
||||
},
|
||||
children,
|
||||
);
|
||||
}
|
||||
|
||||
return render;
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, useAttrs } from "vue";
|
||||
import { avatarGroupVariants, type AvatarVariants } from "@heroui-vue/styles";
|
||||
import Avatar from "./Avatar.vue";
|
||||
import AvatarFallback from "./AvatarFallback.vue";
|
||||
import { avatarGroupContextKey } from "./context";
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
name: "AvatarGroupCount",
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
color?: AvatarVariants["color"];
|
||||
size?: AvatarVariants["size"];
|
||||
variant?: AvatarVariants["variant"];
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const group = inject(avatarGroupContextKey, undefined);
|
||||
|
||||
const finalSize = computed(() => props.size ?? group?.value.size);
|
||||
const finalColor = computed(() => props.color ?? group?.value.color);
|
||||
const finalVariant = computed(() => props.variant ?? group?.value.variant);
|
||||
|
||||
// Built during render (not cached): key additions/removals on $attrs must not
|
||||
// depend on computed invalidation of an initially empty key set.
|
||||
function restAttrs() {
|
||||
const rest: Record<string, unknown> = {};
|
||||
for (const key of Object.keys(attrs)) {
|
||||
if (key !== "class") rest[key] = attrs[key];
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
function countClass() {
|
||||
const base = group?.value.countClass ?? avatarGroupVariants().count();
|
||||
return [base, attrs.class];
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Avatar
|
||||
v-bind="restAttrs()"
|
||||
:color="finalColor"
|
||||
:size="finalSize"
|
||||
:variant="finalVariant"
|
||||
:__avatar_group_child="true"
|
||||
:class="countClass()"
|
||||
data-slot="avatar-group-count"
|
||||
>
|
||||
<AvatarFallback>
|
||||
<slot />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
</template>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, useAttrs } from "vue";
|
||||
import { AvatarImage } from "reka-ui";
|
||||
import { avatarContextKey } from "./context";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
defineProps<{
|
||||
src: string;
|
||||
alt?: string;
|
||||
asChild?: boolean;
|
||||
crossOrigin?: "" | "anonymous" | "use-credentials";
|
||||
loading?: "eager" | "lazy";
|
||||
sizes?: string;
|
||||
srcSet?: string;
|
||||
referrerPolicy?: string;
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const ctx = inject(avatarContextKey, undefined);
|
||||
const imageClass = computed(
|
||||
() => ctx?.slots.value.image() ?? "hv-avatar__image",
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AvatarImage
|
||||
v-bind="attrs"
|
||||
:src="src"
|
||||
:alt="alt"
|
||||
:as-child="asChild"
|
||||
:crossorigin="crossOrigin"
|
||||
:loading="loading"
|
||||
:sizes="sizes"
|
||||
:srcset="srcSet"
|
||||
:referrerpolicy="referrerPolicy"
|
||||
:class="imageClass"
|
||||
data-slot="avatar-image"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { ComputedRef, InjectionKey } from "vue";
|
||||
import type { AvatarVariants, avatarVariants } from "@heroui-vue/styles";
|
||||
|
||||
/** Marks direct children of AvatarGroup so nested Avatars do not inherit group props. */
|
||||
export const AVATAR_GROUP_CHILD = "__avatar_group_child" as const;
|
||||
|
||||
export type AvatarSlots = ReturnType<typeof avatarVariants>;
|
||||
|
||||
export interface AvatarPartsContext {
|
||||
slots: ComputedRef<AvatarSlots>;
|
||||
}
|
||||
|
||||
export const avatarContextKey: InjectionKey<AvatarPartsContext> =
|
||||
Symbol("HeroUIVue.Avatar");
|
||||
|
||||
export interface AvatarGroupContextValue {
|
||||
size?: AvatarVariants["size"];
|
||||
color?: AvatarVariants["color"];
|
||||
variant?: AvatarVariants["variant"];
|
||||
countClass: string;
|
||||
}
|
||||
|
||||
export type AvatarGroupContext = ComputedRef<AvatarGroupContextValue>;
|
||||
|
||||
export const avatarGroupContextKey: InjectionKey<AvatarGroupContext> = Symbol(
|
||||
"HeroUIVue.AvatarGroup",
|
||||
);
|
||||
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, useAttrs, watch } from "vue";
|
||||
import {
|
||||
closeButtonVariants,
|
||||
type CloseButtonVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
variant?: CloseButtonVariants["variant"];
|
||||
isDisabled?: boolean;
|
||||
disabled?: boolean;
|
||||
}>(),
|
||||
{ variant: "default" },
|
||||
);
|
||||
|
||||
const attrs = useAttrs();
|
||||
const disabled = computed(() => props.isDisabled || props.disabled);
|
||||
const ariaLabel = computed(() =>
|
||||
typeof attrs["aria-label"] === "string" ? attrs["aria-label"] : "Close",
|
||||
);
|
||||
|
||||
const hovered = ref(false);
|
||||
const pressed = ref(false);
|
||||
const focused = ref(false);
|
||||
const focusVisible = ref(false);
|
||||
|
||||
watch(
|
||||
disabled,
|
||||
(isDisabled) => {
|
||||
if (isDisabled) {
|
||||
hovered.value = false;
|
||||
pressed.value = false;
|
||||
}
|
||||
},
|
||||
{ flush: "sync" },
|
||||
);
|
||||
|
||||
function guard(e: MouseEvent) {
|
||||
if (disabled.value) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
function onKeydownGuard(e: KeyboardEvent) {
|
||||
if (disabled.value) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
return;
|
||||
}
|
||||
if (e.key === " " || e.key === "Enter") pressed.value = true;
|
||||
}
|
||||
|
||||
function focus(e: FocusEvent) {
|
||||
focused.value = true;
|
||||
focusVisible.value = (e.target as HTMLElement).matches(":focus-visible");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
v-bind="attrs"
|
||||
:type="'button'"
|
||||
:class="closeButtonVariants({ variant })"
|
||||
:disabled="disabled"
|
||||
:aria-disabled="disabled || undefined"
|
||||
:aria-label="ariaLabel"
|
||||
:data-hovered="(!disabled && hovered) || undefined"
|
||||
:data-pressed="(!disabled && pressed) || undefined"
|
||||
:data-focused="focused || undefined"
|
||||
:data-focus-visible="focusVisible || undefined"
|
||||
data-slot="close-button"
|
||||
@click.capture="guard"
|
||||
@keydown.capture="onKeydownGuard"
|
||||
@pointerenter="hovered = !disabled"
|
||||
@pointerleave="
|
||||
hovered = false;
|
||||
pressed = false;
|
||||
"
|
||||
@pointerdown="pressed = !disabled"
|
||||
@pointerup="pressed = false"
|
||||
@keyup="pressed = false"
|
||||
@focus="focus"
|
||||
@blur="
|
||||
focused = false;
|
||||
focusVisible = false;
|
||||
"
|
||||
>
|
||||
<slot
|
||||
:is-hovered="hovered"
|
||||
:is-pressed="pressed"
|
||||
:is-focused="focused"
|
||||
:is-focus-visible="focusVisible"
|
||||
:is-disabled="disabled"
|
||||
>
|
||||
<!-- Default close mark from the fixed baseline CloseIcon. -->
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-slot="close-button-icon"
|
||||
fill="none"
|
||||
height="16"
|
||||
role="presentation"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M3.47 3.47a.75.75 0 0 1 1.06 0L8 6.94l3.47-3.47a.75.75 0 1 1 1.06 1.06L9.06 8l3.47 3.47a.75.75 0 1 1-1.06 1.06L8 9.06l-3.47 3.47a.75.75 0 0 1-1.06-1.06L6.94 8 3.47 4.53a.75.75 0 0 1 0-1.06Z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</slot>
|
||||
</button>
|
||||
</template>
|
||||
@@ -0,0 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, useAttrs } from "vue";
|
||||
import { skeletonVariants, type SkeletonVariants } from "@heroui-vue/styles";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
|
||||
const props = defineProps<{
|
||||
animationType?: SkeletonVariants["animationType"];
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
|
||||
const cssAnimationType = ref<SkeletonVariants["animationType"]>();
|
||||
|
||||
function readCssVariable() {
|
||||
if (typeof document === "undefined") return undefined;
|
||||
try {
|
||||
const value = getComputedStyle(document.documentElement)
|
||||
.getPropertyValue("--skeleton-animation")
|
||||
.trim();
|
||||
if (value === "shimmer" || value === "pulse" || value === "none") {
|
||||
return value;
|
||||
}
|
||||
return undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedAnimationType = computed<SkeletonVariants["animationType"]>(
|
||||
() => props.animationType ?? cssAnimationType.value ?? "shimmer",
|
||||
);
|
||||
|
||||
const baseClass = computed(() =>
|
||||
skeletonVariants({ animationType: resolvedAnimationType.value }).base(),
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
if (props.animationType === undefined) {
|
||||
cssAnimationType.value = readCssVariable();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-bind="attrs" :class="baseClass" data-slot="skeleton">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -22,6 +22,10 @@ export {
|
||||
linkVariants,
|
||||
spinnerVariants,
|
||||
textAreaVariants,
|
||||
closeButtonVariants,
|
||||
avatarVariants,
|
||||
avatarGroupVariants,
|
||||
skeletonVariants,
|
||||
type ButtonVariants,
|
||||
type CardVariants,
|
||||
type InputVariants,
|
||||
@@ -30,6 +34,10 @@ export {
|
||||
type LinkVariants,
|
||||
type SpinnerVariants,
|
||||
type TextAreaVariants,
|
||||
type CloseButtonVariants,
|
||||
type AvatarVariants,
|
||||
type AvatarGroupVariants,
|
||||
type SkeletonVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
export type {
|
||||
ButtonProps,
|
||||
@@ -43,6 +51,13 @@ export type {
|
||||
LinkIconProps,
|
||||
SpinnerProps,
|
||||
TextAreaProps,
|
||||
CloseButtonProps,
|
||||
AvatarProps,
|
||||
AvatarImageProps,
|
||||
AvatarFallbackProps,
|
||||
AvatarGroupProps,
|
||||
AvatarGroupCountProps,
|
||||
SkeletonProps,
|
||||
} from "./types";
|
||||
|
||||
export { tv, cn, type VariantProps } from "@heroui-vue/styles";
|
||||
@@ -59,3 +74,20 @@ export { default as Link } from "./components/link/Link.vue";
|
||||
export { default as LinkIcon } from "./components/link/LinkIcon.vue";
|
||||
export { default as Spinner } from "./components/spinner/Spinner.vue";
|
||||
export { default as TextArea } from "./components/textarea/TextArea.vue";
|
||||
|
||||
export { default as CloseButton } from "./components/close-button/CloseButton.vue";
|
||||
export { default as Avatar } from "./components/avatar/Avatar.vue";
|
||||
export { default as AvatarImage } from "./components/avatar/AvatarImage.vue";
|
||||
export { default as AvatarFallback } from "./components/avatar/AvatarFallback.vue";
|
||||
export { default as AvatarGroup } from "./components/avatar/AvatarGroup.vue";
|
||||
export { default as AvatarGroupCount } from "./components/avatar/AvatarGroupCount.vue";
|
||||
export {
|
||||
AVATAR_GROUP_CHILD,
|
||||
avatarContextKey,
|
||||
avatarGroupContextKey,
|
||||
type AvatarGroupContext,
|
||||
type AvatarGroupContextValue,
|
||||
type AvatarPartsContext,
|
||||
type AvatarSlots,
|
||||
} from "./components/avatar/context";
|
||||
export { default as Skeleton } from "./components/skeleton/Skeleton.vue";
|
||||
|
||||
@@ -7,6 +7,13 @@ import type Link from "./components/link/Link.vue";
|
||||
import type LinkIcon from "./components/link/LinkIcon.vue";
|
||||
import type Spinner from "./components/spinner/Spinner.vue";
|
||||
import type TextArea from "./components/textarea/TextArea.vue";
|
||||
import type CloseButton from "./components/close-button/CloseButton.vue";
|
||||
import type Avatar from "./components/avatar/Avatar.vue";
|
||||
import type AvatarImage from "./components/avatar/AvatarImage.vue";
|
||||
import type AvatarFallback from "./components/avatar/AvatarFallback.vue";
|
||||
import type AvatarGroup from "./components/avatar/AvatarGroup.vue";
|
||||
import type AvatarGroupCount from "./components/avatar/AvatarGroupCount.vue";
|
||||
import type Skeleton from "./components/skeleton/Skeleton.vue";
|
||||
|
||||
export type ButtonProps = InstanceType<typeof Button>["$props"];
|
||||
export type CardProps = InstanceType<typeof Card>["$props"];
|
||||
@@ -17,6 +24,15 @@ export type LinkProps = InstanceType<typeof Link>["$props"];
|
||||
export type LinkIconProps = InstanceType<typeof LinkIcon>["$props"];
|
||||
export type SpinnerProps = InstanceType<typeof Spinner>["$props"];
|
||||
export type TextAreaProps = InstanceType<typeof TextArea>["$props"];
|
||||
export type CloseButtonProps = InstanceType<typeof CloseButton>["$props"];
|
||||
export type AvatarProps = InstanceType<typeof Avatar>["$props"];
|
||||
export type AvatarImageProps = InstanceType<typeof AvatarImage>["$props"];
|
||||
export type AvatarFallbackProps = InstanceType<typeof AvatarFallback>["$props"];
|
||||
export type AvatarGroupProps = InstanceType<typeof AvatarGroup>["$props"];
|
||||
export type AvatarGroupCountProps = InstanceType<
|
||||
typeof AvatarGroupCount
|
||||
>["$props"];
|
||||
export type SkeletonProps = InstanceType<typeof Skeleton>["$props"];
|
||||
|
||||
import type SwitchGroup from "./components/switch/SwitchGroup.vue";
|
||||
import type Label from "./components/label/Label.vue";
|
||||
|
||||
@@ -0,0 +1,796 @@
|
||||
import { describe, it, expect, vi, afterEach } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createCommentVNode, defineComponent, h, nextTick, ref } from "vue";
|
||||
import { readFileSync } from "node:fs";
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarGroup,
|
||||
AvatarGroupCount,
|
||||
AvatarImage,
|
||||
CloseButton,
|
||||
Skeleton,
|
||||
} from "../packages/vue/src";
|
||||
import CloseButtonInteractive from "../apps/docs/demos/close-button-interactive.vue";
|
||||
import AvatarGroupMaxDemo from "../apps/docs/demos/avatar-group-max.vue";
|
||||
import AvatarGroupCountDemo from "../apps/docs/demos/avatar-group-count.vue";
|
||||
import SkeletonSingleShimmer from "../apps/docs/demos/skeleton-single-shimmer.vue";
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
describe("CloseButton", () => {
|
||||
it("renders the baseline close icon and Close aria-label", () => {
|
||||
const w = mount(CloseButton);
|
||||
const button = w.get("button");
|
||||
expect(button.attributes("type")).toBe("button");
|
||||
expect(button.attributes("aria-label")).toBe("Close");
|
||||
expect(button.attributes("data-slot")).toBe("close-button");
|
||||
expect(button.classes()).toContain("hv-close-button");
|
||||
expect(button.classes()).toContain("hv-close-button--default");
|
||||
expect(w.find("[data-slot=close-button-icon]").exists()).toBe(true);
|
||||
});
|
||||
|
||||
it("lets callers override the aria-label and replace the icon", () => {
|
||||
const w = mount(CloseButton, {
|
||||
attrs: { "aria-label": "关闭" },
|
||||
slots: { default: () => h("span", { "data-icon": "custom" }, "×") },
|
||||
});
|
||||
expect(w.get("button").attributes("aria-label")).toBe("关闭");
|
||||
expect(w.get("[data-icon=custom]").text()).toBe("×");
|
||||
expect(w.find("[data-slot=close-button-icon]").exists()).toBe(false);
|
||||
});
|
||||
|
||||
it("blocks activation when disabled and restores hover state", async () => {
|
||||
const clicks = vi.fn();
|
||||
const w = mount(CloseButton, {
|
||||
props: { isDisabled: true },
|
||||
attrs: { onClick: clicks },
|
||||
});
|
||||
const button = w.get("button");
|
||||
expect(button.attributes("disabled")).toBeDefined();
|
||||
expect(button.attributes("aria-disabled")).toBe("true");
|
||||
await button.trigger("click");
|
||||
expect(clicks).not.toHaveBeenCalled();
|
||||
await button.trigger("pointerenter");
|
||||
expect(button.attributes("data-hovered")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("counts clicks in the interactive demo", async () => {
|
||||
const w = mount(CloseButtonInteractive, { attachTo: document.body });
|
||||
const button = w.get("button");
|
||||
expect(w.text()).toContain("已点击:0 次");
|
||||
await button.trigger("click");
|
||||
await button.trigger("click");
|
||||
expect(w.text()).toContain("已点击:2 次");
|
||||
expect(button.attributes("aria-label")).toContain("2 次");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("marks hover, pressed and focus-visible through data attributes", async () => {
|
||||
const w = mount(CloseButton, { attachTo: document.body });
|
||||
const button = w.get("button");
|
||||
await button.trigger("pointerenter");
|
||||
expect(button.attributes("data-hovered")).toBe("true");
|
||||
await button.trigger("pointerdown");
|
||||
expect(button.attributes("data-pressed")).toBe("true");
|
||||
await button.trigger("pointerleave");
|
||||
expect(button.attributes("data-hovered")).toBeUndefined();
|
||||
expect(button.attributes("data-pressed")).toBeUndefined();
|
||||
(button.element as HTMLButtonElement).focus();
|
||||
await button.trigger("focus");
|
||||
expect(button.attributes("data-focused")).toBe("true");
|
||||
await button.trigger("blur");
|
||||
expect(button.attributes("data-focused")).toBeUndefined();
|
||||
w.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Avatar", () => {
|
||||
it("applies size, color and variant slots", () => {
|
||||
const w = mount(Avatar, {
|
||||
props: { size: "lg", variant: "soft" },
|
||||
slots: {
|
||||
default: () => [
|
||||
h(AvatarImage, {
|
||||
src: "https://example.com/a.png",
|
||||
alt: "A",
|
||||
}),
|
||||
h(AvatarFallback, { color: "accent" }, { default: () => "JD" }),
|
||||
],
|
||||
},
|
||||
});
|
||||
const root = w.get("[data-slot=avatar]");
|
||||
expect(root.classes()).toContain("hv-avatar");
|
||||
expect(root.classes()).toContain("hv-avatar--lg");
|
||||
expect(root.classes()).toContain("hv-avatar--soft");
|
||||
const image = w.get("[data-slot=avatar-image]");
|
||||
expect(image.classes()).toContain("hv-avatar__image");
|
||||
expect(image.attributes("src")).toBe("https://example.com/a.png");
|
||||
const fallback = w.get("[data-slot=avatar-fallback]");
|
||||
expect(fallback.classes()).toContain("hv-avatar__fallback");
|
||||
expect(fallback.classes()).toContain("hv-avatar__fallback--accent");
|
||||
expect(fallback.text()).toBe("JD");
|
||||
});
|
||||
|
||||
it("shows fallback content while the image is unavailable", async () => {
|
||||
const w = mount(Avatar, {
|
||||
slots: {
|
||||
default: () => [
|
||||
h(AvatarImage, {
|
||||
src: "https://invalid.example/missing.jpg",
|
||||
alt: "missing",
|
||||
}),
|
||||
h(AvatarFallback, {}, { default: () => "NA" }),
|
||||
],
|
||||
},
|
||||
attachTo: document.body,
|
||||
});
|
||||
await nextTick();
|
||||
// Reka tracks load state separately; jsdom does not fetch images, so the
|
||||
// fallback stays visible until a successful load.
|
||||
expect(w.text()).toContain("NA");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("forwards class and DOM attrs to the avatar root", () => {
|
||||
const w = mount(Avatar, {
|
||||
attrs: { class: "custom", "data-id": "a1", "aria-label": "约翰的头像" },
|
||||
slots: { default: () => h(AvatarFallback, {}, { default: () => "J" }) },
|
||||
});
|
||||
const root = w.get("[data-slot=avatar]");
|
||||
expect(root.classes()).toContain("custom");
|
||||
expect(root.attributes("data-id")).toBe("a1");
|
||||
expect(root.attributes("aria-label")).toBe("约翰的头像");
|
||||
});
|
||||
|
||||
it("replaces the inherited fallback color when the child overrides it", () => {
|
||||
const w = mount(Avatar, {
|
||||
props: { color: "accent" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(AvatarFallback, { color: "danger" }, { default: () => "X" }),
|
||||
},
|
||||
});
|
||||
const classes = w.get("[data-slot=avatar-fallback]").classes();
|
||||
expect(classes).toContain("hv-avatar__fallback--danger");
|
||||
expect(classes).not.toContain("hv-avatar__fallback--accent");
|
||||
});
|
||||
|
||||
it("keeps the inherited fallback color when the child does not override it", () => {
|
||||
const w = mount(Avatar, {
|
||||
props: { color: "accent" },
|
||||
slots: {
|
||||
default: () => h(AvatarFallback, {}, { default: () => "X" }),
|
||||
},
|
||||
});
|
||||
const classes = w.get("[data-slot=avatar-fallback]").classes();
|
||||
expect(classes).toContain("hv-avatar__fallback--accent");
|
||||
expect(classes).not.toContain("hv-avatar__fallback--danger");
|
||||
});
|
||||
|
||||
it("merges custom class onto the fallback without dropping color", () => {
|
||||
const w = mount(Avatar, {
|
||||
props: { color: "success" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(
|
||||
AvatarFallback,
|
||||
{ class: "rounded-lg", color: "warning" },
|
||||
{ default: () => "X" },
|
||||
),
|
||||
},
|
||||
});
|
||||
const classes = w.get("[data-slot=avatar-fallback]").classes();
|
||||
expect(classes).toContain("rounded-lg");
|
||||
expect(classes).toContain("hv-avatar__fallback--warning");
|
||||
expect(classes).not.toContain("hv-avatar__fallback--success");
|
||||
});
|
||||
});
|
||||
|
||||
describe("AvatarGroup", () => {
|
||||
it("inherits size/color/variant onto direct children and keeps overrides", () => {
|
||||
const w = mount(AvatarGroup, {
|
||||
props: { size: "sm", variant: "soft", color: "accent" },
|
||||
slots: {
|
||||
default: () => [
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "A" }),
|
||||
},
|
||||
),
|
||||
h(
|
||||
Avatar,
|
||||
{ size: "lg" },
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "B" }),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
});
|
||||
const group = w.get("[data-slot=avatar-group]");
|
||||
expect(group.classes()).toContain("hv-avatar-group");
|
||||
expect(group.classes()).toContain("hv-avatar-group--clip");
|
||||
const avatars = w.findAll("[data-slot=avatar]");
|
||||
expect(avatars).toHaveLength(2);
|
||||
expect(avatars[0].classes()).toContain("hv-avatar--sm");
|
||||
expect(avatars[0].classes()).toContain("hv-avatar--soft");
|
||||
expect(avatars[1].classes()).toContain("hv-avatar--lg");
|
||||
expect(avatars[0].get("[data-slot=avatar-fallback]").classes()).toContain(
|
||||
"hv-avatar__fallback--accent",
|
||||
);
|
||||
});
|
||||
|
||||
it("truncates with max and renders an automatic count", () => {
|
||||
const w = mount(AvatarGroupMaxDemo);
|
||||
const avatars = w.findAll("[data-slot=avatar]");
|
||||
// 3 visible avatars; the overflow marker uses its own data-slot.
|
||||
expect(avatars).toHaveLength(3);
|
||||
const count = w.get("[data-slot=avatar-group-count]");
|
||||
expect(count.text()).toBe("+2");
|
||||
});
|
||||
|
||||
it("keeps explicit counts untruncated and suppresses auto count", () => {
|
||||
const w = mount(AvatarGroupCountDemo);
|
||||
const counts = w.findAll("[data-slot=avatar-group-count]");
|
||||
expect(counts).toHaveLength(1);
|
||||
expect(counts[0].text()).toBe("+9");
|
||||
const avatars = w.findAll("[data-slot=avatar]");
|
||||
expect(avatars).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("supports grid and ring overlap modifiers", () => {
|
||||
const grid = mount(AvatarGroup, {
|
||||
props: { isGrid: true, overlap: "ring" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "X" }),
|
||||
},
|
||||
),
|
||||
},
|
||||
});
|
||||
const root = grid.get("[data-slot=avatar-group]");
|
||||
expect(root.classes()).toContain("hv-avatar-group--grid");
|
||||
// CSS uses :not(--grid) so ring is inert while grid is on, but the class is still emitted.
|
||||
expect(root.classes()).toContain("hv-avatar-group--ring");
|
||||
|
||||
const ring = mount(AvatarGroup, {
|
||||
props: { overlap: "ring" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "X" }),
|
||||
},
|
||||
),
|
||||
},
|
||||
});
|
||||
expect(ring.get("[data-slot=avatar-group]").classes()).toContain(
|
||||
"hv-avatar-group--ring",
|
||||
);
|
||||
expect(ring.get("[data-slot=avatar-group]").classes()).not.toContain(
|
||||
"hv-avatar-group--grid",
|
||||
);
|
||||
});
|
||||
|
||||
it("does not leak group size to nested avatars", () => {
|
||||
const w = mount(AvatarGroup, {
|
||||
props: { size: "sm" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(
|
||||
Avatar,
|
||||
{ size: "lg" },
|
||||
{
|
||||
default: () => [
|
||||
h(AvatarFallback, {}, { default: () => "P" }),
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {}, { default: () => "N" }),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
});
|
||||
const avatars = w.findAll("[data-slot=avatar]");
|
||||
expect(avatars[0].classes()).toContain("hv-avatar--lg");
|
||||
// Nested avatar is not a direct group child, so it keeps default md.
|
||||
expect(avatars[1].classes()).toContain("hv-avatar--md");
|
||||
expect(avatars[1].classes()).not.toContain("hv-avatar--sm");
|
||||
});
|
||||
|
||||
it("forwards group attrs and role", () => {
|
||||
const w = mount(AvatarGroup, {
|
||||
attrs: { role: "group", "aria-label": "指派人" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "A" }),
|
||||
},
|
||||
),
|
||||
},
|
||||
});
|
||||
const root = w.get("[data-slot=avatar-group]");
|
||||
expect(root.attributes("role")).toBe("group");
|
||||
expect(root.attributes("aria-label")).toBe("指派人");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Avatar dynamic attrs and slot updates", () => {
|
||||
it("updates AvatarFallback aria-label, class and style", async () => {
|
||||
const label = ref("before");
|
||||
const cls = ref("before");
|
||||
const color = ref("red");
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
return () =>
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {
|
||||
"aria-label": label.value,
|
||||
class: cls.value,
|
||||
style: { color: color.value },
|
||||
}),
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
{ attachTo: document.body },
|
||||
);
|
||||
await nextTick();
|
||||
let fallback = w.get("[data-slot=avatar-fallback]");
|
||||
expect(fallback.attributes("aria-label")).toBe("before");
|
||||
expect(fallback.classes()).toContain("before");
|
||||
expect((fallback.element as HTMLElement).style.color).toBe("red");
|
||||
|
||||
label.value = "after";
|
||||
cls.value = "after";
|
||||
color.value = "blue";
|
||||
await nextTick();
|
||||
fallback = w.get("[data-slot=avatar-fallback]");
|
||||
expect(fallback.attributes("aria-label")).toBe("after");
|
||||
expect(fallback.classes()).toContain("after");
|
||||
expect(fallback.classes()).not.toContain("before");
|
||||
expect((fallback.element as HTMLElement).style.color).toBe("blue");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("updates AvatarGroupCount aria-label and class", async () => {
|
||||
const label = ref("before");
|
||||
const cls = ref("before");
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
return () =>
|
||||
h(
|
||||
AvatarGroup,
|
||||
{},
|
||||
{
|
||||
default: () => [
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {}, { default: () => "A" }),
|
||||
},
|
||||
),
|
||||
h(
|
||||
AvatarGroupCount,
|
||||
{ "aria-label": label.value, class: cls.value },
|
||||
{ default: () => "+1" },
|
||||
),
|
||||
],
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
{ attachTo: document.body },
|
||||
);
|
||||
await nextTick();
|
||||
let count = w.get("[data-slot=avatar-group-count]");
|
||||
expect(count.attributes("aria-label")).toBe("before");
|
||||
expect(count.classes()).toContain("before");
|
||||
|
||||
label.value = "after";
|
||||
cls.value = "after";
|
||||
await nextTick();
|
||||
count = w.get("[data-slot=avatar-group-count]");
|
||||
expect(count.attributes("aria-label")).toBe("after");
|
||||
expect(count.classes()).toContain("after");
|
||||
expect(count.classes()).not.toContain("before");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("reflects replaced slot members after the parent updates", async () => {
|
||||
const items = ref(["A"]);
|
||||
const Host = defineComponent({
|
||||
setup() {
|
||||
return () => {
|
||||
const current = items.value;
|
||||
return h(
|
||||
AvatarGroup,
|
||||
{ max: 2 },
|
||||
{
|
||||
default: () =>
|
||||
current.map((name) =>
|
||||
h(
|
||||
Avatar,
|
||||
{ key: name },
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {}, { default: () => name }),
|
||||
},
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
};
|
||||
},
|
||||
});
|
||||
const w = mount(Host, { attachTo: document.body });
|
||||
await nextTick();
|
||||
expect(w.text()).toContain("A");
|
||||
|
||||
items.value = ["B", "C"];
|
||||
await nextTick();
|
||||
const text = w.text();
|
||||
expect(text).toContain("B");
|
||||
expect(text).toContain("C");
|
||||
expect(text).not.toContain("A");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("ignores v-if comment nodes when applying max and overflow count", async () => {
|
||||
const showGhost = ref(true);
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
return () =>
|
||||
h(
|
||||
AvatarGroup,
|
||||
{ max: 1 },
|
||||
{
|
||||
default: () => [
|
||||
showGhost.value
|
||||
? createCommentVNode("v-if")
|
||||
: h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {}, { default: () => "X" }),
|
||||
},
|
||||
),
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {}, { default: () => "REAL" }),
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
{ attachTo: document.body },
|
||||
);
|
||||
await nextTick();
|
||||
// Comment must not consume the max slot: the real avatar is visible, no +N.
|
||||
expect(w.text()).toContain("REAL");
|
||||
expect(w.find("[data-slot=avatar-group-count]").exists()).toBe(false);
|
||||
|
||||
// Two real members: first stays visible, second becomes +1.
|
||||
showGhost.value = false;
|
||||
await nextTick();
|
||||
expect(w.text()).toContain("X");
|
||||
expect(w.get("[data-slot=avatar-group-count]").text()).toBe("+1");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("skips whitespace text nodes and keeps explicit counts with conditionals", async () => {
|
||||
const w = mount(AvatarGroup, {
|
||||
props: { max: 1 },
|
||||
slots: {
|
||||
default: () => [
|
||||
" ",
|
||||
createCommentVNode("v-if"),
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "A" }),
|
||||
},
|
||||
),
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "B" }),
|
||||
},
|
||||
),
|
||||
h(AvatarGroupCount, {}, { default: () => "+9" }),
|
||||
],
|
||||
},
|
||||
attachTo: document.body,
|
||||
});
|
||||
await nextTick();
|
||||
expect(w.text()).toContain("A");
|
||||
expect(w.text()).not.toContain("B");
|
||||
expect(w.get("[data-slot=avatar-group-count]").text()).toBe("+9");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("passes through attrs added after mount on AvatarFallback", async () => {
|
||||
const extra = ref<Record<string, string>>({});
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
return () =>
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, extra.value),
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
{ attachTo: document.body },
|
||||
);
|
||||
await nextTick();
|
||||
let fallback = w.get("[data-slot=avatar-fallback]");
|
||||
expect(fallback.attributes("aria-label")).toBeUndefined();
|
||||
expect(fallback.attributes("title")).toBeUndefined();
|
||||
|
||||
extra.value = { "aria-label": "new", title: "new" };
|
||||
await nextTick();
|
||||
fallback = w.get("[data-slot=avatar-fallback]");
|
||||
expect(fallback.attributes("aria-label")).toBe("new");
|
||||
expect(fallback.attributes("title")).toBe("new");
|
||||
|
||||
extra.value = {};
|
||||
await nextTick();
|
||||
fallback = w.get("[data-slot=avatar-fallback]");
|
||||
expect(fallback.attributes("aria-label")).toBeUndefined();
|
||||
|
||||
extra.value = { "aria-label": "again" };
|
||||
await nextTick();
|
||||
expect(w.get("[data-slot=avatar-fallback]").attributes("aria-label")).toBe(
|
||||
"again",
|
||||
);
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("passes through attrs added after mount on AvatarGroupCount", async () => {
|
||||
const extra = ref<Record<string, string>>({});
|
||||
const w = mount(
|
||||
defineComponent({
|
||||
setup() {
|
||||
return () =>
|
||||
h(
|
||||
AvatarGroup,
|
||||
{},
|
||||
{
|
||||
default: () => [
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(AvatarFallback, {}, { default: () => "A" }),
|
||||
},
|
||||
),
|
||||
h(AvatarGroupCount, extra.value, { default: () => "+1" }),
|
||||
],
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
{ attachTo: document.body },
|
||||
);
|
||||
await nextTick();
|
||||
expect(
|
||||
w.get("[data-slot=avatar-group-count]").attributes("aria-label"),
|
||||
).toBeUndefined();
|
||||
|
||||
extra.value = { "aria-label": "new", title: "new" };
|
||||
await nextTick();
|
||||
const count = w.get("[data-slot=avatar-group-count]");
|
||||
expect(count.attributes("aria-label")).toBe("new");
|
||||
expect(count.attributes("title")).toBe("new");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("merges caller class on AvatarGroup root", () => {
|
||||
const w = mount(AvatarGroup, {
|
||||
attrs: { class: "gap-4 custom-group" },
|
||||
slots: {
|
||||
default: () =>
|
||||
h(
|
||||
Avatar,
|
||||
{},
|
||||
{
|
||||
default: () => h(AvatarFallback, {}, { default: () => "A" }),
|
||||
},
|
||||
),
|
||||
},
|
||||
});
|
||||
const classes = w.get("[data-slot=avatar-group]").classes();
|
||||
expect(classes).toContain("hv-avatar-group");
|
||||
expect(classes).toContain("gap-4");
|
||||
expect(classes).toContain("custom-group");
|
||||
});
|
||||
|
||||
it("keeps AvatarGroup public prop types constrained", async () => {
|
||||
const { AvatarGroup: Group } = await import("../packages/vue/src");
|
||||
// Compile-time contract: illegal variant values must not type-check.
|
||||
// @ts-expect-error size must be sm | md | lg
|
||||
const badSize: InstanceType<typeof Group>["$props"]["size"] = 123;
|
||||
// @ts-expect-error color must be a known theme name
|
||||
const badColor: InstanceType<typeof Group>["$props"]["color"] = "nope";
|
||||
// @ts-expect-error overlap must be clip | ring
|
||||
const badOverlap: InstanceType<typeof Group>["$props"]["overlap"] =
|
||||
"invalid";
|
||||
void badSize;
|
||||
void badColor;
|
||||
void badOverlap;
|
||||
// Legal values remain assignable.
|
||||
const ok: InstanceType<typeof Group>["$props"] = {
|
||||
size: "lg",
|
||||
color: "accent",
|
||||
overlap: "ring",
|
||||
isGrid: true,
|
||||
};
|
||||
expect(ok.size).toBe("lg");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Skeleton", () => {
|
||||
it("defaults to shimmer and accepts explicit animation types", () => {
|
||||
const basic = mount(Skeleton);
|
||||
expect(basic.get("[data-slot=skeleton]").classes()).toContain(
|
||||
"hv-skeleton",
|
||||
);
|
||||
expect(basic.get("[data-slot=skeleton]").classes()).toContain(
|
||||
"hv-skeleton--shimmer",
|
||||
);
|
||||
|
||||
const pulse = mount(Skeleton, { props: { animationType: "pulse" } });
|
||||
expect(pulse.get("[data-slot=skeleton]").classes()).toContain(
|
||||
"hv-skeleton--pulse",
|
||||
);
|
||||
|
||||
const none = mount(Skeleton, { props: { animationType: "none" } });
|
||||
expect(none.get("[data-slot=skeleton]").classes()).toContain(
|
||||
"hv-skeleton--none",
|
||||
);
|
||||
});
|
||||
|
||||
it("reads --skeleton-animation on mount when the prop is omitted", async () => {
|
||||
document.documentElement.style.setProperty("--skeleton-animation", "pulse");
|
||||
const w = mount(Skeleton, { attachTo: document.body });
|
||||
await nextTick();
|
||||
expect(w.get("[data-slot=skeleton]").classes()).toContain(
|
||||
"hv-skeleton--pulse",
|
||||
);
|
||||
document.documentElement.style.removeProperty("--skeleton-animation");
|
||||
w.unmount();
|
||||
});
|
||||
|
||||
it("applies the synchronized shimmer class on the single-shimmer demo parent", () => {
|
||||
const w = mount(SkeletonSingleShimmer);
|
||||
const parent = w.find(".hv-skeleton--shimmer");
|
||||
expect(parent.exists()).toBe(true);
|
||||
expect(parent.findAll("[data-slot=skeleton]")).toHaveLength(3);
|
||||
for (const node of parent.findAll("[data-slot=skeleton]")) {
|
||||
expect(node.classes()).toContain("hv-skeleton--none");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("M04–M06 demo inventory", () => {
|
||||
const expected: Record<string, string[]> = {
|
||||
"close-button": [
|
||||
"default",
|
||||
"interactive",
|
||||
"with-custom-icon",
|
||||
"custom-styles",
|
||||
],
|
||||
avatar: [
|
||||
"basic",
|
||||
"sizes",
|
||||
"colors",
|
||||
"variants",
|
||||
"fallback",
|
||||
"custom-image-component",
|
||||
"custom-styles",
|
||||
],
|
||||
"avatar-group": [
|
||||
"basic",
|
||||
"max",
|
||||
"count",
|
||||
"sizes",
|
||||
"grid",
|
||||
"overlap",
|
||||
"custom-styles",
|
||||
],
|
||||
skeleton: [
|
||||
"basic",
|
||||
"text-content",
|
||||
"user-profile",
|
||||
"list",
|
||||
"grid",
|
||||
"single-shimmer",
|
||||
"animation-types",
|
||||
"custom-styles",
|
||||
],
|
||||
};
|
||||
|
||||
it("includes every preview from the pinned upstream documents", () => {
|
||||
for (const [docName, names] of Object.entries(expected)) {
|
||||
const document = readFileSync(
|
||||
`apps/docs/components/${docName}.md`,
|
||||
"utf8",
|
||||
);
|
||||
const previewNames = [
|
||||
...document.matchAll(
|
||||
new RegExp(`<ComponentPreview name="${docName}-([^"]+)"`, "g"),
|
||||
),
|
||||
].map((match) => match[1]);
|
||||
expect(previewNames).toEqual(names);
|
||||
for (const name of names) {
|
||||
const source = readFileSync(
|
||||
`apps/docs/demos/${docName}-${name}.vue`,
|
||||
"utf8",
|
||||
);
|
||||
expect(source).toContain("<template>");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("uses Tabler icons and the library components in demos", () => {
|
||||
const customIcon = readFileSync(
|
||||
"apps/docs/demos/close-button-with-custom-icon.vue",
|
||||
"utf8",
|
||||
);
|
||||
expect(customIcon).toContain("@tabler/icons-vue");
|
||||
expect(customIcon).not.toContain("<path");
|
||||
expect(customIcon).toContain("CloseButton");
|
||||
|
||||
const avatarDemo = readFileSync("apps/docs/demos/avatar-basic.vue", "utf8");
|
||||
expect(avatarDemo).toContain("@heroui-vue/components");
|
||||
expect(avatarDemo).not.toContain("reka-ui");
|
||||
|
||||
const card = readFileSync("apps/docs/demos/card-with-images.vue", "utf8");
|
||||
expect(card).toContain("CloseButton");
|
||||
expect(card).toContain("<Avatar");
|
||||
expect(card).not.toContain("closeButtonVariants");
|
||||
expect(card).not.toContain('from "reka-ui"');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user