# 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 | 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 `