feat: initialize Vue component library and aligned documentation
@@ -0,0 +1,10 @@
|
||||
node_modules/
|
||||
dist/
|
||||
coverage/
|
||||
.vitepress/cache/
|
||||
.vitepress/dist/
|
||||
*.tsbuildinfo
|
||||
.DS_Store
|
||||
*.tgz
|
||||
**/.vitepress/cache/
|
||||
**/.vitepress/dist/
|
||||
@@ -0,0 +1,7 @@
|
||||
pnpm-lock.yaml
|
||||
dist
|
||||
node_modules
|
||||
.vitepress/cache
|
||||
.vitepress/dist
|
||||
**/.vitepress/cache/**
|
||||
**/.vitepress/dist/**
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"htmlWhitespaceSensitivity": "ignore"
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
# 独立 Vue 组件库实施方案与协作约定
|
||||
|
||||
## 目标与工作区边界
|
||||
|
||||
本项目计划独立建设一个 Vue 3 组件库,参考 HeroUI v3 的视觉设计、组件范围和交互体验,采用 Vue 生态的实现方式。
|
||||
|
||||
- 上游 React 参考仓库位于 `../heroui/`,不属于本项目。
|
||||
- 本项目目录为 `heroui-vue`,使用独立 Git 仓库。工作区临时包名为 `@heroui-vue/components` 与 `@heroui-vue/styles`;均 private,正式 npm scope 尚未确认。
|
||||
- 不在上游仓库新增 `packages/vue`,不改写或删除上游 React 实现,不依赖相邻参考目录才能构建。
|
||||
- 本文件是 Vue 项目的执行约定。下文阶段划分保留为路线图,实际实现与验证状态以 `docs/compatibility.md`、`docs/verification.md` 为准。
|
||||
- 项目已搭建最小工作区并开始验证 Button、Card、Input、Switch;详细状态以 docs/compatibility.md 为准。
|
||||
|
||||
成功目标:外观接近所选 HeroUI 基线,核心行为完整,API 符合 Vue 习惯,支持独立安装、按需使用、主题定制和服务端渲染。
|
||||
|
||||
## 实现原则
|
||||
|
||||
1. 复刻设计与用户可感知行为,允许底层技术和组件内部 DOM 不同。
|
||||
2. 优先使用无样式的 Vue 交互基础组件,再封装本库的视觉和公共 API。
|
||||
3. 不机械翻译 JSX、React Hooks 或 React Aria 类型,不通过运行 React 来包装成 Vue 组件。
|
||||
4. 样式与交互分别管理;默认在新项目维护自己的样式包,不运行时绑定上游 `@heroui/styles`。
|
||||
5. 可以参考或移植上游 CSS、主题变量、变体映射和 SVG;移植内容记录来源、基线提交和原有许可证声明。
|
||||
6. 组件之间复用 Label、Description、FieldError、表单状态与弹层基础设施,避免各自实现一套。
|
||||
7. 底层库未提供的能力列出差异并实现或明确延后,不用相似名称代替能力验收。
|
||||
|
||||
## 技术架构
|
||||
|
||||
| 层次 | 默认方案 | 约束 |
|
||||
| -------------- | -------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| 框架 | Vue 3、TypeScript、SFC、Composition API | 起步阶段确定最低 Vue 版本并验证;优先采用支持 `defineModel` 的版本 |
|
||||
| 交互基础 | Reka UI | 统一主要底座;公共 API 不直接照搬全部底层实现细节 |
|
||||
| 通用组合式函数 | VueUse,按需引入 | 简单状态用 Vue 原生能力;避免重复实现已有传感器与浏览器能力 |
|
||||
| 样式 | Tailwind CSS 4、CSS 自定义属性、BEM、tailwind-variants | 主题与变体独立;不动态拼接 Tailwind 类名 |
|
||||
| 日期数据 | `@internationalized/date` | 沿用日历日期、时间和时区语义,不强制转为 JS Date |
|
||||
| 构建 | Vite 库模式、vue-tsc、类型声明生成 | 输出 ESM 和声明文件,Vue 外置为 peer dependency;起步验证依赖外置策略 |
|
||||
| 工作区 | pnpm workspace | 初期不强制引入 Turborepo;确有构建编排需求时再加入 |
|
||||
| 文档与演示 | VitePress + Vue 演示页面 | 提供可运行示例;初期不同时维护 Storybook 与文档两套演示体系 |
|
||||
| 测试 | Vitest、Vue Test Utils / Testing Library Vue、Playwright | 单元行为、真实浏览器、SSR 与视觉对比分层验证 |
|
||||
|
||||
依赖版本以新项目实际清单和锁文件为准。本文中的 Alpha 状态来自 2026-10-19 的官方文档核对;选型实施时重新核对稳定发布版本、导出、类型和维护状态,不使用只存在于未发布文档中的能力。
|
||||
|
||||
## Vue 替代方案与能力差异
|
||||
|
||||
| HeroUI 能力 | Vue 实现方向 | 重点验证 |
|
||||
| --------------------------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| Button、Link | 原生 button/a + 本库封装 | 禁用、加载、表单提交、键盘激活;React Aria 的 onPress 不能简单等价于 click |
|
||||
| Card、Surface、Badge、Chip、Alert、Skeleton、Spinner、Typography、Kbd、EmptyState | Vue 展示组件 + 本库样式 | 插槽、尺寸、语义、主题、响应式布局 |
|
||||
| Avatar / AvatarGroup | Reka Avatar + 本库组合 | 加载失败、fallback、分组尺寸与重叠 |
|
||||
| Checkbox / Radio / Switch / Toggle 及分组 | Reka 对应基础组件 + 本库组上下文 | 受控与非受控、禁用、indeterminate、表单值、方向键 |
|
||||
| Accordion / Disclosure / Tabs / Toolbar | Reka Accordion、Collapsible、Tabs、Toolbar | 多项展开、方向、激活模式、焦点移动、指示器动画 |
|
||||
| Modal / AlertDialog | Reka Dialog、AlertDialog | 初始焦点、焦点恢复、焦点限制、Esc、外部点击、嵌套和滚动锁 |
|
||||
| Popover / Tooltip / Dropdown / Menu | Reka Popover、Tooltip、DropdownMenu | 定位、碰撞处理、箭头、hover 延迟、菜单键盘导航 |
|
||||
| Select / ListBox / ComboBox / Autocomplete | Reka Select、Listbox、Combobox;按语义组合 | 单选与多选、清空、对象值、过滤、异步数据、输入法、虚拟化与空状态 |
|
||||
| NumberField / Slider | Reka NumberField、Slider | 步长、范围、精度、本地化、拖动与键盘;不直接复用 React 类型 |
|
||||
| InputOTP | Reka PinInput | 字符数组与公共字符串值转换、粘贴、自动填充、删除、光标与手机输入体验 |
|
||||
| Calendar / RangeCalendar / DateField / DatePicker / DateRangePicker / TimeField | Reka 日期系列 + `@internationalized/date` | 日期系列文档标为 Alpha;验证分段输入、范围、时区、locale、禁用日期和日历切换 |
|
||||
| ColorArea / ColorField / ColorSlider / ColorSwatch / ColorSwatchPicker | Reka 颜色系列 | 文档标为 Alpha;验证格式转换、透明度、拖动、键盘和颜色类型 |
|
||||
| ColorPicker | 颜色基础组件 + Popover + 本库共享颜色状态 | 各子组件双向同步;必要时评估 Ark UI Vue ColorPicker,避免重复颜色状态源 |
|
||||
| Drawer | Reka Drawer | 文档标为 Alpha;验证方向、拖动关闭、停靠点、滚动冲突与嵌套 |
|
||||
| Toast | Reka Toast + 本库队列与命令式 API | 上限、超时暂停、关闭原因、Promise、键盘与读屏公告;Vue Sonner 为备选 |
|
||||
| Form / Fieldset / TextField / SearchField / InputGroup / FieldError | 原生表单 + 本库字段上下文与组合组件 | name/value 提交、reset、required、错误关联、异步校验与第三方表单库兼容 |
|
||||
| Tag / TagGroup | 根据交互语义采用 TagGroup、TagsInput 或本库组合 | TagGroup 文档标为 Alpha;展示标签、可删除标签、选择集合和编辑输入不得混为一种语义 |
|
||||
| Table | 语义化 table + 本库状态层 | 行选择、排序、键盘与 ARIA;大型数据处理确有需要时再评估 TanStack Vue Table,它不自动提供完整可访问交互 |
|
||||
| Pagination / Separator / Progress | Reka 对应基础组件;Meter 等使用原生语义与本库封装 | 页码边界、范围值、进度公告、未知进度 |
|
||||
| Breadcrumbs / Header / Label / Description | 语义 HTML + Vue 封装 | 导航地标、当前页、字段标签和描述关联 |
|
||||
| ScrollShadow / 响应式与测量 Hooks | VueUse 的滚动、媒体查询、ResizeObserver、CSS 变量等能力 | 容器变化、滚动边界、RTL、SSR 和清理 |
|
||||
| RouterProvider / I18nProvider / Collection 等 RAC 导出 | 本库 ConfigProvider、可选 Vue Router 适配、Vue 数据与列表模型 | 不承诺复刻 React Aria 的框架专属导出;所有公开差异写入兼容矩阵 |
|
||||
|
||||
注意:Reka Select、Combobox、Listbox 的功能范围与 React Aria 不完全相同。多选、过滤、集合更新等需求先用安装版本验证;可组合替代,不假定一个同名组件覆盖所有模式。
|
||||
|
||||
Vaul Vue 官方已说明停止维护并推荐 Reka Drawer;新项目不采用 Vaul Vue。Reka 某个 Alpha 组件未达到要求时,先记录失败场景,再评估局部替代或补充实现,不因单个缺口切换整套底座。
|
||||
|
||||
## 建议目录
|
||||
|
||||
以下为新独立仓库内部结构,仓库名及包名待定:
|
||||
|
||||
```text
|
||||
<vue-library>/
|
||||
├── AGENTS.md
|
||||
├── apps/
|
||||
│ ├── docs/ # VitePress,含组件演示
|
||||
│ └── playground/ # 独立消费场景与浏览器测试页面
|
||||
├── packages/
|
||||
│ ├── vue/
|
||||
│ │ ├── src/components/ # 每组件独立目录,SFC、类型、导出
|
||||
│ │ ├── src/composables/
|
||||
│ │ ├── src/providers/
|
||||
│ │ └── tests/
|
||||
│ └── styles/
|
||||
│ ├── themes/
|
||||
│ ├── components/ # 按组件划分 CSS
|
||||
│ └── src/ # 变体映射与类型
|
||||
├── docs/
|
||||
│ ├── compatibility.md # 完整组件、属性、行为与差异清单
|
||||
│ ├── upstream.md # 上游版本、提交与移植来源
|
||||
│ └── decisions/ # 重要架构决策及验证结果
|
||||
├── tests/ # 浏览器、视觉、独立安装与 SSR 场景
|
||||
└── pnpm-workspace.yaml
|
||||
```
|
||||
|
||||
## 公共 API 约定
|
||||
|
||||
- 简单组件导出 Button、Input、Card 等命名组件;复杂组件导出 SelectRoot、SelectTrigger、SelectContent 等部件。不以 React 的 `Select.Trigger` 对象模式作为默认 API。
|
||||
- 普通值使用 `modelValue` / `update:modelValue`,文档使用 `v-model`;展开状态使用 `v-model:open`;二态组件使用 `v-model:checked`,多选集合采用数组并明确空值语义。
|
||||
- 日期采用明确的 DateValue 等类型;颜色公共表示先在验证阶段决定,并提供字符串转换边界。不得泄漏 React 专属类型。
|
||||
- 支持受控与非受控状态,定义 defaultValue/defaultOpen 等初始值与受控值的优先级,不在内部直接修改传入值。
|
||||
- 使用具名和作用域插槽;展示配置通过 size、variant 等变体属性表达。
|
||||
- `$attrs`、ARIA、DOM 事件、class 和 style 有明确归属;多根组件使用显式透传,避免事件遗漏或重复触发。
|
||||
- `provide/inject` 使用有类型的 InjectionKey,共享响应式状态;明确子部件缺少 Root 时的处理方式。
|
||||
- DOM 引用与 focus 等方法通过 `defineExpose` 按需公开。不要将 ref 当成普通 React prop 转发。
|
||||
- ConfigProvider 统一 locale、dir、必要的弹层配置;路由链接通过可选适配接入,基础包不强依赖 Vue Router。
|
||||
- 原生必填与表单约束是基础能力;第三方校验库提供集成示例,不作为使用 Input 的强制依赖。
|
||||
|
||||
## 样式与视觉复刻策略
|
||||
|
||||
1. 固定上游参考提交,以该版本的组件、示例和主题作为第一轮目标,避免开发中不断追逐上游变化。
|
||||
2. 在新仓库保存所需设计变量、主题、变体和组件 CSS,保持独立构建。默认保留 Tailwind 4 工程接入方式;无需 Tailwind 的预编译 CSS 作为后续独立目标评估。
|
||||
3. 使用库级 CSS 类名前缀,降低 `.button` 等通用类名冲突;颜色、尺寸、圆角、阴影通过 CSS 变量提供可覆盖接口。
|
||||
4. 重新核对每个组件的 DOM、data-slot、data-state、data-disabled、定位变量和动画生命周期。原 RAC 的 data-entering/data-exiting 不会由 Reka 自动等价生成。
|
||||
5. 优先让新样式匹配 Vue 底座的真实状态;必须保留的兼容标记通过薄适配层生成。不通过伪造 ARIA 改变交互语义。
|
||||
6. 保留浅色、深色、焦点可见、禁用、错误、选中、加载、悬停与按下状态;支持 reduced-motion 和 RTL。
|
||||
7. 退出动画需要与卸载生命周期协调,定位原点与箭头方向需要映射;不只比对静态截图。
|
||||
8. 视觉对比使用固定字体、视口、主题、数据和上游基线,记录可接受差异;不能用更新截图掩盖回归。
|
||||
|
||||
## 实施阶段与交付物
|
||||
|
||||
### 阶段 0:基线、能力清单与脚手架
|
||||
|
||||
- 确定新仓库位置、包名与最低支持环境,固定上游提交。
|
||||
- 从上游公共导出生成完整组件清单,包括进行中的 calendar-year-picker;将每项标为计划、验证中、完成或延后。
|
||||
- 建立 compatibility.md:记录每个组件的子部件、变体、属性、事件、键盘行为、底座、差异、测试和阶段。
|
||||
- 核验 Reka 的实际发布版本,特别是日期、颜色、Drawer、TagGroup;记录文档与安装版本差异。
|
||||
- 建立工作区、最小构建、样式入口、文档和消费示例。确认能够脱离参考仓库完成安装与构建。
|
||||
|
||||
### 阶段 1:纵向验证,先消除高风险差异
|
||||
|
||||
验证 Button、Card、Input、Switch、Modal、Select,再重点验证 DatePicker、ColorPicker、Drawer、InputOTP。
|
||||
|
||||
每类交付一个可运行示例、API 草案、样式对比、关键行为测试和已知差异。依赖的 Label、Popover、字段上下文等只实现所需基础能力。日期、颜色、Drawer 的 Alpha 能力在这一阶段决定采用、局部替代或延后,不等整库完成再发现缺口。
|
||||
|
||||
进入下一阶段的条件:独立消费可用;基础主题一致;复杂组件的焦点、表单值、值同步和关闭生命周期有验证结果;不存在尚未决策的底座阻断。
|
||||
|
||||
### 阶段 2:完成基础组件与通用设施
|
||||
|
||||
完成展示组件、按钮族、头像族、基础输入、Label/Description/FieldError、Checkbox/Radio/Switch 及分组、表单上下文、主题与 ConfigProvider。补齐基本 ARIA、原生表单提交与重置。
|
||||
|
||||
### 阶段 3:完成组合交互与集合组件
|
||||
|
||||
按依赖关系完成 Accordion/Disclosure、Tabs/Toolbar、弹层与菜单族、Select/Listbox/Combobox/Autocomplete、NumberField/Slider、Tag 族、Toast、Pagination 和 Table。Table 第一版先达到选定上游基线的公开契约,不无条件增加数据网格功能。
|
||||
|
||||
### 阶段 4:完善复杂组件与兼容性
|
||||
|
||||
完成日期、时间、颜色、Drawer、OTP、ScrollShadow 等细节;补齐输入法、触屏、RTL、locale、嵌套弹层、SSR、水合与 Nuxt 消费场景。通过能力清单确认没有遗漏公开组件;延后项在版本文档中明确。
|
||||
|
||||
### 阶段 5:发布准备
|
||||
|
||||
完成文档、主题指南、按需使用、表单和路由集成示例、类型检查、打包安装验证和变更记录。发布范围与实际完成的兼容矩阵一致;不因视觉相似就声明完整兼容 HeroUI。
|
||||
|
||||
## 验证与完成标准
|
||||
|
||||
组件完成必须同时满足其适用条件:
|
||||
|
||||
- 有明确的公共类型、导出、变体、插槽、事件与文档示例。
|
||||
- 行为测试覆盖适用的受控/非受控状态、值变更事件、禁用、清空、表单提交/reset 和键盘操作。
|
||||
- 弹层测试覆盖焦点进入、焦点限制、关闭和恢复;嵌套及外部点击顺序在真实浏览器验证。
|
||||
- 拖动、测量、滚动、定位、退出动画与指针捕获使用真实浏览器验证,不用 jsdom 的假布局替代。
|
||||
- SSR 场景不在模块加载或服务端渲染时访问 window/document;ID 与水合稳定,Teleport 的服务端行为有说明和验证。
|
||||
- 视觉比较覆盖浅色/深色、主要变体、移动端和关键状态;焦点环、错误提示、减少动画不遗漏。
|
||||
- 自动化无障碍检查配合实际键盘操作;检查通过不等于已经完成所有读屏验证。
|
||||
- 用打包产物安装到独立 Vue 应用验证,不只运行工作区源码。确认类型可解析、CSS 不被误裁剪、命名导入可用且运行时没有 React 依赖。
|
||||
- CSS 在 package.json 的 sideEffects 中正确声明;公共导出指向发布产物,依赖与 peerDependencies 明确。
|
||||
- 记录不支持或行为不同的能力。测试验证用户行为,不复制底层库内部实现。
|
||||
|
||||
计划提供的根命令:`pnpm dev`、`pnpm build`、`pnpm lint`、`pnpm typecheck`、`pnpm test:unit`、`pnpm test:browser`、`pnpm test:ssr`、`pnpm test:visual`、`pnpm test:package`。这些命令在新项目脚手架落地后才视为可执行,届时按实际脚本更新本节。
|
||||
|
||||
## 执行与维护约定
|
||||
|
||||
- 将部分任务交给其他 AI 时,采用 [迁移任务拆分与复核约定](docs/migration-handoff.md),明确任务范围、文件归属、共享文件处理与交接报告。本文档提供计划与模板,不代表已派发任务;实现者自测不等于集成人验收。
|
||||
- 后续实施先读取本文件与新项目的局部指导,再定位对应的上游组件和样式。
|
||||
- 每批实现同步更新兼容矩阵与实际进度,区分“外观完成”和“行为验收完成”。
|
||||
- 遇到替代方案差异时先定位具体缺口,给出局部解决方案与验证结果;不直接删除能力或引入第二套整库。
|
||||
- 仅在依赖缺口得到证实后引入额外库,并记录体积、状态模型、焦点/弹层互操作和维护成本。
|
||||
- 优先完成可独立验证的小批组件;不一次生成所有组件的空壳并标记完成。
|
||||
- 本方案不规定工期。阶段 1 结束后根据实际差异和验证成本制定后续批次。
|
||||
|
||||
## 官方参考
|
||||
|
||||
- [Reka UI 概览](https://www.reka-ui.com/docs/overview/introduction)
|
||||
- [Reka Dialog](https://reka-ui.com/docs/components/dialog)、[Combobox](https://reka-ui.com/docs/components/combobox)、[Listbox](https://reka-ui.com/docs/components/listbox)
|
||||
- [Reka DatePicker](https://reka-ui.com/docs/components/date-picker)、[TimeField](https://reka-ui.com/docs/components/time-field)
|
||||
- [Reka ColorArea](https://reka-ui.com/docs/components/color-area)、[Drawer](https://reka-ui.com/docs/components/drawer)、[PinInput](https://reka-ui.com/docs/components/pin-input)
|
||||
- [Reka Toast](https://reka-ui.com/docs/components/toast)、[Vue Sonner](https://vue-sonner.vercel.app/)
|
||||
- [VueUse](https://vueuse.org/functions)、[Ark UI ColorPicker](https://ark-ui.com/docs/components/color-picker)
|
||||
- [Vaul Vue 维护状态](https://github.com/unovue/vaul-vue)
|
||||
|
||||
## 当前脚手架命令与边界
|
||||
|
||||
已配置:`pnpm dev`、`pnpm dev:docs`、`pnpm build`、`pnpm build:playground`、`pnpm build:docs`、`pnpm typecheck`、`pnpm test`、`pnpm test:unit`、`pnpm test:ssr`、`pnpm format`。浏览器、视觉与独立安装检查尚未建立,不得宣称已通过。组件 CSS 与默认主题现已按基线移植,使用 Tailwind 4 编译为独立 CSS。默认 pnpm dev 启动文档,pnpm dev:playground 启动验证页。暂不引入 VueUse 或完整日期依赖,随对应组件落地再添加。
|
||||
|
||||
这里“尚未建立”指自动化浏览器、视觉和独立安装检查。已进行的手动浏览器验证见 `docs/verification.md`,不能把手动检查描述为相应自动化命令通过。
|
||||
|
||||
## 2026-10-20:高一致性复刻要求(优先于早期近似演示方案)
|
||||
|
||||
- 组件、文档的样式、布局、文案、参数 API 和主题必须与固定 HeroUI 基线保持高度一致。禁止用自行设计的品牌配色、简化控件或另写的营销演示代替复刻。
|
||||
- 原始 CSS、语义变量、尺寸、间距、圆角、阴影、动效、data-slot 与状态属性优先移植并适配。使用 hv- 命名空间不改变视觉数值。
|
||||
- 属性名称、默认值和变体集合尽量保留;仅框架机制要求的事件、插槽、响应式值和组合导出改为 Vue 方式。参数不能无记录地删减。
|
||||
- 文档以原中文标题、介绍、示例次序、API 表格和导航层次为基线,使用专门的文档布局,不沿用默认 VitePress 外观。演示代码必须来自被渲染的同一份 SFC。
|
||||
- 默认开发入口是文档站;playground 仅用于回归场景。未迁移的示例与能力明确列出,不以占位内容充数。
|
||||
- 验收分别记录源样式移植、组件行为、文档布局和真实浏览器对比结果。移植了 CSS 不等于已经通过逐像素对比。
|
||||
|
||||
## 图标约定
|
||||
|
||||
- 演示与文档 UI 统一采用 `@tabler/icons-vue` 的官方命名组件,按需导入;不自绘 SVG、不在示例中堆放 path 数据。
|
||||
- 使用图标库里已有的品牌、功能与加载图标。图标按钮提供 aria-label,装饰图标标记 aria-hidden。
|
||||
- 图标包依赖放在 apps/docs;基础组件通过插槽接收图标,保持图标方案可替换。
|
||||
|
||||
## 迁移实践与后续执行规则(2026-10-20)
|
||||
|
||||
### 先建立清单,再实现组件和文档
|
||||
|
||||
- 固定参考版本为 HeroUI 3.2.6、提交 `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`。参考源码在 `../heroui/`;构建不能依赖它。
|
||||
- 每个组件先读上游 React 实现、组件 CSS、变体映射、中文文档及全部演示。文档路径为 `apps/docs/content/docs/cn/react/components/` 下的分类目录,演示在 `apps/docs/src/demos/cn/<component>/`。
|
||||
- 把属性及默认值、部件、变体、状态、事件、示例名称和顺序列成清单。不能只实现基础用法,就把组件或文档标为完成。
|
||||
- 示例数量对齐只是第一步;还要核对每例的控件数量、文案、图标、图片、尺寸、布局和可操作行为。Card 水平示例不能拿普通卡片改个排列代替。
|
||||
- 本轮清单为 Button 14、Card 7、Input 7、Switch 15,共 43 个基线示例。该数字是当前记录,不是整库完成指标;新增迁移必须重新核对对应基线。
|
||||
- 上游文案与实际 CSS 冲突时,记录冲突,以固定提交的真实样式和行为为依据,不默默改成自己的设计。
|
||||
|
||||
### 视觉依赖完整状态链,不能只复制 CSS
|
||||
|
||||
- 为每种状态核对“公共属性 → Vue 状态 → 真实 DOM/ARIA/data 属性 → CSS 选择器 → 浏览器效果”。Reka 不会自动生成 React Aria 的全部状态标记。
|
||||
- Button 曾只输出 `data-pending`,遗漏 `aria-disabled`,导致加载按钮仍是正常亮蓝。当前加载期间使用 `aria-disabled="true"`、阻止重复激活,复用主题的 `--disabled-opacity: 0.5`,呈现淡蓝色;不设置原生 `disabled`,保留键盘焦点。不要把加载改成灰色,也不要以“能旋转”代替视觉验收。
|
||||
- ARIA 必须反映真实交互语义;不能为了命中样式随意设置。原生禁用、暂时不可激活、只读及加载分别处理,配套验证键盘与事件拦截。
|
||||
- 进入加载或禁用状态时清除悬停、按下状态。`pointer-events: none` 可能使预期的指针清理事件不再到达,不依赖 pointerleave 完成全部清理。
|
||||
- 复用主题变量、BEM 类名、data-slot 和现有变体体系;适配写在可定位的组件层或样式入口,不往文档全局塞零散补丁掩盖组件问题。
|
||||
- 组合图标与加载指示器要检查最终尺寸及选择器继承。加载演示使用独立 `data-slot="spinner"` 容器,避免被 Button 的普通 SVG 尺寸规则覆盖;保留 reduced-motion 行为。
|
||||
- 同时检查浅色、深色、焦点、禁用、选中、错误与动态状态;截图之外检查计算样式,区分颜色变化、整体透明度和主题变量错误。
|
||||
- 运行时 CSS 变量不等于 Tailwind 编译期主题映射。文档的 utilities.css 必须在自己的编译入口导入库的 `themes/shared/theme.css`(@theme inline),否则 `from-accent/12`、`bg-accent/15`、`shadow-accent/20` 等类会静默缺失;不能只看模板类名一致。
|
||||
- 预览的通用宽度约束放在 components 层,让 utilities 层的 `max-w-md` 等显式定制优先。不要用无层的高优先级 max-width:100% 覆盖所有示例,造成卡片被拉满。
|
||||
|
||||
### Vue 组合、属性透传与表单边界
|
||||
|
||||
- 普通组件和组合组件都要测试 `$attrs` 的最终落点。Switch 的字段容器承接 class/style/data-*,实际 Content 按钮承接 ARIA 和 DOM 事件;不能因用户自定义默认插槽,就丢失根组件的 aria-label。
|
||||
- `useAttrs()` 不是普通响应式对象。需要随父级更新的属性,不用无响应式依赖的 computed 缓存快照;在渲染时读取,并测试父级动态修改 ARIA 属性。
|
||||
- `asChild` 采用 Reka Primitive 合并属性,明确要求唯一有效根元素。它是 Vue 对 React render prop 的适配,不宣称复刻原有事件模型。
|
||||
- 受控值由父组件决定,非受控值维护内部初值。父组件拒绝 Input 更新时,检查真实 input.value 是否恢复,不能只检查 update:modelValue 是否发出。
|
||||
- 表单必须检查实际 `FormData`、未选中值是否省略、禁用值是否省略、默认提交值、required、reset 与被取消的 reset。受控 reset 不能覆盖父级值;非受控 reset 恢复初始值。
|
||||
- 当前 Switch 通过本库原生 checkbox 处理表单,Reka 负责可点击控件的交互;不要再同时给底层 Reka 注入 name,造成重复表单字段。表单字段与可见状态保持同步,清理表单监听器。
|
||||
- readonly 不等于 disabled。Switch 的鼠标、Enter、空格均需验证;不能只拦截 click,然后遗漏底层键盘更新路径。
|
||||
- Label 在原生 Input 外使用 label/for;Switch 按钮内部采用非交互标签元素。Description/FieldError 使用唯一 ID,合并显式 aria-describedby;多个描述和多个实例不能共享重复 ID。
|
||||
- native 校验要实际阻止无效提交,并把焦点引向可见控件;aria 校验负责错误语义,提交由调用者处理。当前 FieldError 仅接入 Switch,不能据此声称完整 TextField/Form 已实现。
|
||||
- 定时器、动画、事件监听与描述注册均需卸载清理。SSR 不访问浏览器全局,使用 useId;SSR 渲染通过仍不代表水合与完整字段关联通过。
|
||||
|
||||
### 演示内容本身就是交付物
|
||||
|
||||
- `apps/docs/demos/*.vue` 是预览、复制和高亮的同一来源。示例必须能独立读懂,保留必要导入,移除未使用的组件和重复的 SVG 路径。
|
||||
- 固定状态示例与交互示例分别说明。加载示例应明确“固定展示”;动态上传应能触发、显示加载、阻止重复操作、恢复并再次触发。
|
||||
- 图标沿用上面的 Tabler 约定,不再自绘。图标组件只做装饰时隐藏其读屏语义,只有图标的按钮由按钮提供可访问名称。
|
||||
- 尚未迁移的依赖组件可以用原生语义或已安装的无样式组件局部组合。例如 Card 的头像采用 Reka Avatar,表单采用原生 form/label。记录替代边界,不把演示中的适配当成已发布的新组件。
|
||||
- 表单示例应展示真实提交值或明确反馈;不假装完成登录、支付等业务。示例使用上游图片 URL 时检查加载与 fallback,网络资源存在并不等于已验证离线使用。
|
||||
- 预览区与正文排版样式隔离;正文的段落、标题、表格规则不能覆盖组件。固定宽度示例保留原始目标宽度,同时受窄屏 max-width 约束。
|
||||
- Shiki 生成 token 不等于页面已高亮。浅色需应用 `--shiki-light`,深色需应用 `--shiki-dark`,通过浏览器计算颜色验证;不只查看是否存在 span。
|
||||
- 高亮在构建/服务端生成,展开时按需加载,复制读取原始 SFC;高亮资源失败时仍提供可读源码。热更新同时失效原始源码与高亮模块,避免显示旧代码。
|
||||
- 文档检查包括展开/收起、复制反馈、键盘搜索与章节跳转、移动目录、深浅切换和 API 表格实际渲染。Markdown 表格被空行断开等问题,类型检查不会发现。
|
||||
|
||||
### 开发预览必须可靠
|
||||
|
||||
- 文档固定地址为 `http://127.0.0.1:5173`,使用 strictPort。发现占用先确认监听进程的工作目录与用途,不盲目结束其他服务,也不悄悄切换到 5174 后给用户另一个地址。
|
||||
- 开发模式通过精确匹配的 alias 读取 `packages/vue/src/index.ts`、`packages/styles/src/index.ts` 与样式源码;排除工作区包预构建并去重 Vue。生产构建仍走包导出的 dist,以免源码 alias 掩盖发布问题。
|
||||
- 区分 `@heroui-vue/styles` 与 `@heroui-vue/styles/css`,避免宽泛前缀 alias 误匹配子路径。只重建 dist 无法证明浏览器的依赖缓存已经更新。
|
||||
- 开发监听忽略 `.vitepress/dist/**`,避免生产构建触发连续刷新。修改 VitePress 配置或高亮插件后,如出现已释放的 Shiki 实例错误,完整重启本项目服务后再验证。
|
||||
- 遇到“浏览器没生效”,先确认地址、监听进程、源码/产物解析路径和实际返回内容,再检查缓存;不能默认让用户强刷,也不能以本地测试通过代替页面验证。
|
||||
- 每轮交付确保给出的端口实际可访问,并在浏览器检查刚修复的示例。不要把旧标签、旧截图或另一个实例当作本轮证据。
|
||||
|
||||
### 验证、来源与交付记录
|
||||
|
||||
- 按改动运行 `pnpm test`、`pnpm typecheck`、`pnpm build:docs`、`pnpm format`;涉及消费验证页时加 `pnpm build:playground`。当前完整测试为 34 项,此数仅作本轮记录。
|
||||
- 回归优先测试用户可感知行为:重复操作、状态恢复、焦点、表单值、标签关联和只读键盘路径。文档清单测试检查预览名称与顺序;它不能证明示例内容和外观正确。
|
||||
- 单元测试、SSR 冒烟、手动浏览器检查、自动无障碍和自动视觉对比分别记录。测试通过、CSS 移植或示例齐全均不等于整组件完成兼容验收。
|
||||
- 视觉证据注明版本、视口、主题及状态,必要时附计算样式。未来建立自动对比后,不能通过更新截图掩盖回归。
|
||||
- 同步维护 `docs/compatibility.md`(能力与差异)、`docs/upstream.md`(来源与许可)、`docs/verification.md`(实际验证与限制)。详细历史留在这些文件,AGENTS.md 维护后续可执行的规则。
|
||||
- 上游部分包清单标注 MIT,但本地根许可证实际为 Apache-2.0。保留 `third-party/HEROUI-LICENSE` 与样式包许可证,不根据包清单猜测移植许可;新增第三方图标包按其自身许可记录。
|
||||
- 自动浏览器/逐像素对比、完整触屏/读屏、Nuxt 水合与打包后独立安装仍未完成,不在交付说明中暗示已通过。
|
||||
@@ -0,0 +1,32 @@
|
||||
# HeroUI Vue
|
||||
|
||||
独立的 Vue 3 组件库项目,以 HeroUI v3 为设计参考。社区实验项目,非官方发行版,当前包均未发布。
|
||||
|
||||
## 本地运行
|
||||
|
||||
需要 Node.js 22.12+(使用 Node 22 时)和 pnpm 11。更高 Node 主版本需符合 Vite 的支持范围。
|
||||
|
||||
```sh
|
||||
pnpm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
默认启动组件文档:http://127.0.0.1:5173/components/button。`pnpm dev:playground` 启动独立验证页。
|
||||
|
||||
文档开发模式直接加载工作区组件与样式源码,支持热更新;生产构建仍使用包产物。文档端口固定为 5173,占用时会报错,请先停止已有文档进程,避免打开不同实例。
|
||||
|
||||
```sh
|
||||
pnpm build
|
||||
pnpm typecheck
|
||||
pnpm test
|
||||
pnpm build:playground
|
||||
pnpm build:docs
|
||||
```
|
||||
|
||||
`packages/vue` 为组件包,`packages/styles` 为独立样式包;`apps/playground` 用于交互验证,`apps/docs` 提供 VitePress 文档。构建库不需要旁边的原 React 仓库。
|
||||
|
||||
Button、Card、Input、Switch 已移植基线主题、主要变体与组合结构,仍处于完整兼容验收阶段。日期、颜色、弹层等尚未实现。详见 [兼容矩阵](docs/compatibility.md)、[实施方案](AGENTS.md) 与 [上游基线](docs/upstream.md)。
|
||||
|
||||
临时包名为 `@heroui-vue/components`、`@heroui-vue/styles`,均设置 `private: true`;发布前需确认包名、许可证与版本策略。
|
||||
|
||||
当前文档采用上游中文标题、说明和示例次序,并提供同一 SFC 源码的可运行演示。样式来源与许可见 [上游记录](docs/upstream.md),尚未覆盖的能力见 [兼容矩阵](docs/compatibility.md)。
|
||||
@@ -0,0 +1,66 @@
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { defineConfig } from "vitepress";
|
||||
import { docsDataPlugin } from "./docs-data";
|
||||
import { fileURLToPath } from "node:url";
|
||||
export default defineConfig({
|
||||
lang: "zh-CN",
|
||||
title: "HeroUI Vue",
|
||||
description: "美观、现代的 Vue UI 组件库",
|
||||
appearance: true,
|
||||
cleanUrls: true,
|
||||
head: [["meta", { name: "theme-color", content: "#f5f5f5" }]],
|
||||
markdown: { headers: { level: [2, 3] } },
|
||||
vite: {
|
||||
plugins: [
|
||||
tailwindcss(),
|
||||
{
|
||||
name: "workspace-source-dev",
|
||||
apply: "serve",
|
||||
config: () => ({
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
find: /^@heroui-vue\/components$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL(
|
||||
"../../../packages/vue/src/index.ts",
|
||||
import.meta.url,
|
||||
),
|
||||
),
|
||||
},
|
||||
{
|
||||
find: /^@heroui-vue\/styles\/css$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL(
|
||||
"../../../packages/styles/index.css",
|
||||
import.meta.url,
|
||||
),
|
||||
),
|
||||
},
|
||||
{
|
||||
find: /^@heroui-vue\/styles$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL(
|
||||
"../../../packages/styles/src/index.ts",
|
||||
import.meta.url,
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
dedupe: ["vue"],
|
||||
},
|
||||
optimizeDeps: {
|
||||
exclude: ["@heroui-vue/components", "@heroui-vue/styles"],
|
||||
},
|
||||
}),
|
||||
},
|
||||
docsDataPlugin(fileURLToPath(new URL("..", import.meta.url))),
|
||||
],
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
watch: { ignored: ["**/.vitepress/dist/**"] },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
import { readFile, readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { createMarkdownRenderer } from "vitepress";
|
||||
import type { Plugin } from "vite";
|
||||
|
||||
// Build both highlights and the local search index from the actual documentation.
|
||||
export function docsDataPlugin(root: string): Plugin {
|
||||
const id = "\0virtual:docs-data";
|
||||
let renderer: ReturnType<typeof createMarkdownRenderer>;
|
||||
return {
|
||||
name: "heroui-docs-data",
|
||||
resolveId(source) {
|
||||
if (source === "virtual:docs-data") return id;
|
||||
if (/^virtual:docs-highlight\/[a-z0-9-]+$/.test(source))
|
||||
return "\0" + source;
|
||||
},
|
||||
async load(source) {
|
||||
if (source !== id && !source.startsWith("\0virtual:docs-highlight/"))
|
||||
return;
|
||||
renderer ??= createMarkdownRenderer(root, {
|
||||
theme: { light: "github-light", dark: "github-dark" },
|
||||
headers: { level: [2, 3] },
|
||||
});
|
||||
const md = await renderer;
|
||||
if (source.startsWith("\0virtual:docs-highlight/")) {
|
||||
const name = source.slice("\0virtual:docs-highlight/".length);
|
||||
const file = path.join(root, "demos", name + ".vue");
|
||||
this.addWatchFile(file);
|
||||
return (
|
||||
"export default " +
|
||||
JSON.stringify(
|
||||
md.render("```vue\n" + (await readFile(file, "utf8")) + "\n```"),
|
||||
)
|
||||
);
|
||||
}
|
||||
const highlights: string[] = [];
|
||||
for (const name of await readdir(path.join(root, "demos"))) {
|
||||
if (!name.endsWith(".vue")) continue;
|
||||
const file = path.join(root, "demos", name);
|
||||
this.addWatchFile(file);
|
||||
const key = name.slice(0, -4);
|
||||
highlights.push(
|
||||
JSON.stringify(key) +
|
||||
":()=>import(" +
|
||||
JSON.stringify("virtual:docs-highlight/" + key) +
|
||||
")",
|
||||
);
|
||||
}
|
||||
const pages = [
|
||||
"introduction.md",
|
||||
"guide.md",
|
||||
"themes.md",
|
||||
...(await readdir(path.join(root, "components")))
|
||||
.filter((f) => f.endsWith(".md"))
|
||||
.map((f) => "components/" + f),
|
||||
];
|
||||
const search = [];
|
||||
const plain = (value: string) =>
|
||||
value
|
||||
.replace(/^[| :\-]+$/gm, " ")
|
||||
.replace(/<[^>]*>/g, " ")
|
||||
.replace(/[`*#|]/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
for (const name of pages) {
|
||||
const file = path.join(root, name);
|
||||
this.addWatchFile(file);
|
||||
const raw = await readFile(file, "utf8");
|
||||
const title = raw.match(/^title:\s*(.+)$/m)?.[1] ?? name;
|
||||
const description = raw.match(/^description:\s*(.+)$/m)?.[1] ?? "";
|
||||
const url = "/" + name.slice(0, -3);
|
||||
search.push({ title, section: "概览", url, text: description });
|
||||
const content = raw.replace(/^---[\s\S]*?---/, "");
|
||||
// The rendered IDs come from the same Markdown renderer as the real pages.
|
||||
const env: {
|
||||
headers?: { title: string; slug: string; children?: unknown[] }[];
|
||||
} = {};
|
||||
const rendered = md.render(content, env);
|
||||
const headings = [
|
||||
...rendered.matchAll(
|
||||
/<h([23]) id="([^"]+)"[^>]*>([\s\S]*?)<\/h[23]>/g,
|
||||
),
|
||||
];
|
||||
const chunks = content.split(/^#{2,3}\s+.+$/m).slice(1);
|
||||
headings.forEach((h, i) =>
|
||||
search.push({
|
||||
title,
|
||||
section: plain(h[3].replace(/<a[\s\S]*?<\/a>/g, "")),
|
||||
url: url + "#" + h[2],
|
||||
text: plain(chunks[i] ?? "").slice(0, 2000),
|
||||
}),
|
||||
);
|
||||
}
|
||||
return (
|
||||
"export const highlights=" +
|
||||
"{" +
|
||||
highlights.join(",") +
|
||||
"}" +
|
||||
";export const searchIndex=" +
|
||||
JSON.stringify(search) +
|
||||
";"
|
||||
);
|
||||
},
|
||||
handleHotUpdate(ctx) {
|
||||
if (/\.(md|vue)$/.test(ctx.file)) {
|
||||
const mod = ctx.server.moduleGraph.getModuleById(id);
|
||||
if (mod) {
|
||||
ctx.server.moduleGraph.invalidateModule(mod);
|
||||
for (const [key, highlight] of ctx.server.moduleGraph.idToModuleMap) {
|
||||
if (key.startsWith("\0virtual:docs-highlight/"))
|
||||
ctx.server.moduleGraph.invalidateModule(highlight);
|
||||
}
|
||||
ctx.server.ws.send({ type: "full-reload" });
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
declare module "virtual:docs-data" {
|
||||
export const highlights: Record<string, () => Promise<{ default: string }>>;
|
||||
export const searchIndex: import("./theme/search").SearchEntry[];
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup lang="ts">
|
||||
import { IconCode, IconCopy } from "@tabler/icons-vue";
|
||||
import { computed, ref, watch, onBeforeUnmount, useId } from "vue";
|
||||
import { highlights } from "virtual:docs-data";
|
||||
const props = defineProps<{ name: string }>();
|
||||
const demos = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
});
|
||||
const sources = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
query: "?raw",
|
||||
import: "default",
|
||||
});
|
||||
const component = computed(() => demos[`../../demos/${props.name}.vue`]);
|
||||
const code = computed(() =>
|
||||
String(sources[`../../demos/${props.name}.vue`] ?? ""),
|
||||
);
|
||||
const expanded = ref(false),
|
||||
copyStatus = ref("复制代码");
|
||||
const id = useId();
|
||||
const highlightedCode = ref("");
|
||||
watch([expanded, () => props.name], async ([open, name], _, onCleanup) => {
|
||||
let current = true;
|
||||
onCleanup(() => {
|
||||
current = false;
|
||||
});
|
||||
highlightedCode.value = "";
|
||||
if (open) {
|
||||
try {
|
||||
const result = await highlights[name]?.();
|
||||
if (current) highlightedCode.value = result?.default ?? "";
|
||||
} catch {
|
||||
// The plain source remains available if a highlight chunk cannot load.
|
||||
}
|
||||
}
|
||||
});
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
async function copy() {
|
||||
clearTimeout(timer);
|
||||
try {
|
||||
await navigator.clipboard.writeText(code.value);
|
||||
copyStatus.value = "已复制";
|
||||
timer = setTimeout(() => {
|
||||
copyStatus.value = "复制代码";
|
||||
}, 2000);
|
||||
} catch {
|
||||
expanded.value = true;
|
||||
copyStatus.value = "复制失败,请手动选择代码";
|
||||
}
|
||||
}
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
</script>
|
||||
<template>
|
||||
<div class="component-preview-container" :data-name="name">
|
||||
<div class="preview not-prose">
|
||||
<div class="demo-row">
|
||||
<component :is="component" v-if="component" />
|
||||
<p v-else role="alert">示例不存在:{{ name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="code-section">
|
||||
<div class="code-toolbar">
|
||||
<span class="code-language">
|
||||
<span class="code-dot" aria-hidden="true" />
|
||||
Vue
|
||||
</span>
|
||||
<div>
|
||||
<button
|
||||
:aria-label="(expanded ? '收起' : '展开') + name + ' 示例代码'"
|
||||
:aria-controls="id"
|
||||
:aria-expanded="expanded"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
<IconCode aria-hidden="true" :size="14" />
|
||||
{{ expanded ? "收起代码" : "展开代码" }}
|
||||
</button>
|
||||
<button :aria-label="'复制' + name + ' 示例代码'" @click="copy">
|
||||
<IconCopy aria-hidden="true" :size="14" />
|
||||
复制代码
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="copy-feedback"
|
||||
:class="{ 'sr-only': copyStatus === '复制代码' }"
|
||||
role="status"
|
||||
>
|
||||
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
||||
</p>
|
||||
<div
|
||||
v-if="expanded"
|
||||
:id="id"
|
||||
class="highlighted-source"
|
||||
tabindex="0"
|
||||
:aria-label="name + ' 示例源码'"
|
||||
>
|
||||
<div v-if="highlightedCode" v-html="highlightedCode" />
|
||||
<pre v-else><code>{{ code }}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,156 @@
|
||||
<script setup lang="ts">
|
||||
import { IconSearch } from "@tabler/icons-vue";
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch,
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
nextTick,
|
||||
} from "vue";
|
||||
import { withBase, useRouter } from "vitepress";
|
||||
import {
|
||||
DialogRoot,
|
||||
DialogTrigger,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
DialogClose,
|
||||
} from "reka-ui";
|
||||
import { searchIndex } from "virtual:docs-data";
|
||||
import { searchDocs, searchExcerpt } from "./search";
|
||||
const router = useRouter();
|
||||
const navigating = ref(false);
|
||||
const open = ref(false),
|
||||
query = ref(""),
|
||||
active = ref(0),
|
||||
field = ref<HTMLInputElement>();
|
||||
const results = computed(() => searchDocs(searchIndex, query.value));
|
||||
watch(query, () => {
|
||||
active.value = 0;
|
||||
});
|
||||
watch(open, (value) => {
|
||||
if (!value) query.value = "";
|
||||
else navigating.value = false;
|
||||
});
|
||||
function shortcut(event: KeyboardEvent) {
|
||||
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
||||
event.preventDefault();
|
||||
open.value = !open.value;
|
||||
}
|
||||
}
|
||||
function move(delta: number) {
|
||||
if (!results.value.length) return;
|
||||
active.value =
|
||||
(active.value + delta + results.value.length) % results.value.length;
|
||||
void nextTick(() =>
|
||||
document
|
||||
.getElementById("search-result-" + active.value)
|
||||
?.scrollIntoView({ block: "nearest" }),
|
||||
);
|
||||
}
|
||||
async function navigateTo(entry: (typeof searchIndex)[number]) {
|
||||
navigating.value = true;
|
||||
open.value = false;
|
||||
await router.go(withBase(entry.url));
|
||||
await nextTick();
|
||||
const id = entry.url.split("#")[1];
|
||||
const target = id
|
||||
? document.getElementById(decodeURIComponent(id))
|
||||
: document.querySelector<HTMLElement>(".docs-main h1");
|
||||
target?.setAttribute("tabindex", "-1");
|
||||
target?.focus({ preventScroll: true });
|
||||
}
|
||||
function navigate() {
|
||||
const entry = results.value[active.value];
|
||||
if (entry) void navigateTo(entry);
|
||||
}
|
||||
function closeAutoFocus(event: Event) {
|
||||
if (navigating.value) event.preventDefault();
|
||||
}
|
||||
onMounted(() => window.addEventListener("keydown", shortcut));
|
||||
onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
||||
</script>
|
||||
<template>
|
||||
<DialogRoot v-model:open="open">
|
||||
<DialogTrigger class="search-trigger" aria-label="搜索文档">
|
||||
<IconSearch aria-hidden="true" :size="17" />
|
||||
<span>搜索文档…</span>
|
||||
<kbd>⌘ / Ctrl K</kbd>
|
||||
</DialogTrigger>
|
||||
<DialogPortal>
|
||||
<DialogOverlay class="search-overlay" />
|
||||
<DialogContent
|
||||
class="search-dialog"
|
||||
@open-auto-focus.prevent="field?.focus()"
|
||||
@close-auto-focus="closeAutoFocus"
|
||||
>
|
||||
<DialogTitle class="sr-only">搜索文档</DialogTitle>
|
||||
<DialogDescription class="sr-only">
|
||||
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
||||
</DialogDescription>
|
||||
<div class="search-field">
|
||||
<input
|
||||
ref="field"
|
||||
v-model="query"
|
||||
placeholder="搜索组件、参数或用法…"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
role="combobox"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="doc-search-results"
|
||||
:aria-expanded="Boolean(query.trim())"
|
||||
:aria-activedescendant="
|
||||
results.length ? 'search-result-' + active : undefined
|
||||
"
|
||||
@keydown.down.prevent="move(1)"
|
||||
@keydown.up.prevent="move(-1)"
|
||||
@keydown.enter.prevent="navigate"
|
||||
/>
|
||||
<DialogClose class="search-close" aria-label="关闭搜索">
|
||||
Esc
|
||||
</DialogClose>
|
||||
</div>
|
||||
<div
|
||||
class="search-results"
|
||||
id="doc-search-results"
|
||||
role="listbox"
|
||||
aria-label="搜索结果"
|
||||
>
|
||||
<p v-if="!query.trim()" class="search-empty">
|
||||
试试搜索「isPending」「主题」或「受控」
|
||||
</p>
|
||||
<p v-else-if="!results.length" class="search-empty" role="status">
|
||||
没有找到“{{ query }}”,试试组件名或参数名。
|
||||
</p>
|
||||
<a
|
||||
v-for="(entry, index) in results"
|
||||
:id="'search-result-' + index"
|
||||
:key="entry.url"
|
||||
:href="withBase(entry.url)"
|
||||
role="option"
|
||||
:aria-selected="index === active"
|
||||
:tabindex="-1"
|
||||
@mousemove="active = index"
|
||||
@click.prevent="navigateTo(entry)"
|
||||
>
|
||||
<span class="result-title">
|
||||
{{ entry.title }}
|
||||
<span>{{ entry.section }}</span>
|
||||
</span>
|
||||
<span class="result-excerpt">
|
||||
{{ searchExcerpt(entry, query) || "查看文档" }}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="search-footer" aria-live="polite">
|
||||
<span>
|
||||
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
||||
</span>
|
||||
<span>↑ ↓ 选择 ↵ 打开</span>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,300 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
IconSun,
|
||||
IconMoon,
|
||||
IconMenu2,
|
||||
IconX,
|
||||
IconArrowUpRight,
|
||||
} from "@tabler/icons-vue";
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch,
|
||||
nextTick,
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
} from "vue";
|
||||
import { useData, useRoute, withBase, onContentUpdated } from "vitepress";
|
||||
import {
|
||||
DialogRoot,
|
||||
DialogTrigger,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
DialogClose,
|
||||
} from "reka-ui";
|
||||
import DocSearch from "./DocSearch.vue";
|
||||
const { frontmatter, page, isDark } = useData();
|
||||
const route = useRoute();
|
||||
const mobile = ref(false),
|
||||
activeSlug = ref("");
|
||||
const copyMessage = ref("");
|
||||
let copyTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
onBeforeUnmount(() => clearTimeout(copyTimer));
|
||||
const groups = [
|
||||
{
|
||||
title: "开始使用",
|
||||
items: [
|
||||
{ title: "介绍", url: "/introduction" },
|
||||
{ title: "安装", url: "/guide" },
|
||||
{ title: "主题", url: "/themes" },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "组件",
|
||||
items: [
|
||||
{ title: "Button 按钮", url: "/components/button" },
|
||||
{ title: "Card 卡片", url: "/components/card" },
|
||||
{ title: "Input 输入框", url: "/components/input" },
|
||||
{ title: "Switch 开关", url: "/components/switch" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const items = groups.flatMap((g) => g.items);
|
||||
const currentIndex = computed(() =>
|
||||
items.findIndex((item) => selected(item.url)),
|
||||
);
|
||||
const previous = computed(() => items[currentIndex.value - 1]);
|
||||
const next = computed(() => items[currentIndex.value + 1]);
|
||||
function selected(url: string) {
|
||||
return (
|
||||
route.path === withBase(url) ||
|
||||
route.path === withBase(url + ".html") ||
|
||||
(url === "/components/button" && route.path === withBase("/"))
|
||||
);
|
||||
}
|
||||
const headers = computed(() => page.value.headers ?? []);
|
||||
const flatHeaders = computed(() =>
|
||||
headers.value.flatMap((h) => [h, ...(h.children ?? [])]),
|
||||
);
|
||||
let ticking = false;
|
||||
function updateActive() {
|
||||
ticking = false;
|
||||
const headings = flatHeaders.value
|
||||
.map((h) => document.getElementById(h.slug))
|
||||
.filter((el): el is HTMLElement => Boolean(el));
|
||||
let active = headings[0]?.id ?? "";
|
||||
for (const heading of headings) {
|
||||
if (heading.getBoundingClientRect().top <= 120) active = heading.id;
|
||||
else break;
|
||||
}
|
||||
activeSlug.value = active;
|
||||
}
|
||||
function onScroll() {
|
||||
if (!ticking) {
|
||||
ticking = true;
|
||||
requestAnimationFrame(updateActive);
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
updateActive();
|
||||
});
|
||||
onBeforeUnmount(() => window.removeEventListener("scroll", onScroll));
|
||||
onContentUpdated(() => {
|
||||
void nextTick(updateActive);
|
||||
});
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
mobile.value = false;
|
||||
void nextTick(() => {
|
||||
if (!window.location.hash)
|
||||
window.scrollTo({ top: 0, behavior: "instant" });
|
||||
updateActive();
|
||||
});
|
||||
},
|
||||
);
|
||||
async function copyMarkdownCode(event: MouseEvent) {
|
||||
const target = (event.target as HTMLElement).closest<HTMLButtonElement>(
|
||||
"button.copy",
|
||||
);
|
||||
if (!target) return;
|
||||
const code = target.parentElement?.querySelector("pre code")?.textContent;
|
||||
if (!code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
target.classList.add("copied");
|
||||
target.setAttribute("aria-label", "已复制");
|
||||
copyMessage.value = "代码已复制";
|
||||
clearTimeout(copyTimer);
|
||||
copyTimer = setTimeout(() => {
|
||||
target.classList.remove("copied");
|
||||
target.setAttribute("aria-label", "复制代码");
|
||||
copyMessage.value = "";
|
||||
}, 2000);
|
||||
} catch {
|
||||
target.setAttribute("aria-label", "复制失败,请手动选择代码");
|
||||
copyMessage.value = "复制失败,请手动选择代码";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="docs-layout">
|
||||
<a class="skip" href="#main">跳至内容</a>
|
||||
<p class="sr-only" role="status">{{ copyMessage }}</p>
|
||||
<header class="docs-nav">
|
||||
<a class="brand" :href="withBase('/components/button')">
|
||||
heroui
|
||||
<span>Vue</span>
|
||||
</a>
|
||||
<span class="version">v0.0.1</span>
|
||||
<nav aria-label="主导航">
|
||||
<a
|
||||
:href="withBase('/guide')"
|
||||
:class="{
|
||||
active:
|
||||
!frontmatter.component && route.path !== withBase('/themes'),
|
||||
}"
|
||||
>
|
||||
文档
|
||||
</a>
|
||||
<a
|
||||
:href="withBase('/components/button')"
|
||||
:class="{ active: Boolean(frontmatter.component) }"
|
||||
>
|
||||
组件
|
||||
</a>
|
||||
<a
|
||||
:href="withBase('/themes')"
|
||||
:class="{ active: route.path === withBase('/themes') }"
|
||||
>
|
||||
主题
|
||||
</a>
|
||||
</nav>
|
||||
<div class="nav-tools">
|
||||
<DocSearch />
|
||||
<button
|
||||
class="theme-toggle"
|
||||
:aria-label="isDark ? '切换浅色主题' : '切换深色主题'"
|
||||
@click="isDark = !isDark"
|
||||
>
|
||||
<IconSun v-if="isDark" aria-hidden="true" :size="18" />
|
||||
<IconMoon v-else aria-hidden="true" :size="18" />
|
||||
</button>
|
||||
<DialogRoot v-model:open="mobile">
|
||||
<DialogTrigger class="mobile-menu" aria-label="打开文档目录">
|
||||
<IconMenu2 aria-hidden="true" :size="20" />
|
||||
</DialogTrigger>
|
||||
<DialogPortal>
|
||||
<DialogOverlay class="mobile-nav-overlay" />
|
||||
<DialogContent class="mobile-nav-dialog">
|
||||
<div class="mobile-nav-heading">
|
||||
<DialogTitle>文档目录</DialogTitle>
|
||||
<DialogClose aria-label="关闭文档目录">
|
||||
<IconX aria-hidden="true" :size="20" />
|
||||
</DialogClose>
|
||||
</div>
|
||||
<nav aria-label="移动端文档导航">
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<a
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
||||
@click="mobile = false"
|
||||
>
|
||||
{{ item.title }}
|
||||
</a>
|
||||
</section>
|
||||
</nav>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
</div>
|
||||
</header>
|
||||
<div class="docs-body">
|
||||
<aside class="docs-sidebar" aria-label="文档导航">
|
||||
<div class="framework">
|
||||
<span class="vue-mark">V</span>
|
||||
Vue
|
||||
<span class="framework-note">组件库</span>
|
||||
</div>
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<a
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:class="{ selected: selected(item.url) }"
|
||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
||||
>
|
||||
{{ item.title }}
|
||||
</a>
|
||||
</section>
|
||||
<p class="community">
|
||||
独立社区实现
|
||||
<br />
|
||||
设计基线 HeroUI v3.2.6
|
||||
</p>
|
||||
</aside>
|
||||
<main id="main" class="docs-main">
|
||||
<div class="breadcrumb">
|
||||
{{ frontmatter.group ?? "文档" }}
|
||||
<span>›</span>
|
||||
{{ frontmatter.title }}
|
||||
</div>
|
||||
<h1>{{ frontmatter.title }}</h1>
|
||||
<p class="page-description">{{ frontmatter.description }}</p>
|
||||
<div v-if="frontmatter.component" class="source-links">
|
||||
<a
|
||||
:href="`https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/react/src/components/${frontmatter.component}`"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
React 参考源码
|
||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
||||
</a>
|
||||
<a
|
||||
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${frontmatter.component}.css`"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
样式源码
|
||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
||||
</a>
|
||||
</div>
|
||||
<div @click="copyMarkdownCode"><Content class="docs-content" /></div>
|
||||
<nav class="page-navigation" aria-label="相邻页面">
|
||||
<a v-if="previous" :href="withBase(previous.url)">
|
||||
<span>上一页</span>
|
||||
<strong>{{ previous.title }}</strong>
|
||||
</a>
|
||||
<a v-if="next" class="page-next" :href="withBase(next.url)">
|
||||
<span>下一页</span>
|
||||
<strong>{{ next.title }}</strong>
|
||||
</a>
|
||||
</nav>
|
||||
<footer class="docs-footer">
|
||||
基于 HeroUI v3 设计的 Vue 实现 ·
|
||||
<a :href="withBase('/introduction')">实现范围与差异</a>
|
||||
</footer>
|
||||
</main>
|
||||
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录">
|
||||
<p>本页内容</p>
|
||||
<template v-for="h in headers" :key="h.slug">
|
||||
<a
|
||||
:href="'#' + h.slug"
|
||||
:class="{ current: activeSlug === h.slug }"
|
||||
:aria-current="activeSlug === h.slug ? 'location' : undefined"
|
||||
>
|
||||
{{ h.title }}
|
||||
</a>
|
||||
<a
|
||||
v-for="child in h.children"
|
||||
:key="child.slug"
|
||||
class="nested"
|
||||
:class="{ current: activeSlug === child.slug }"
|
||||
:aria-current="activeSlug === child.slug ? 'location' : undefined"
|
||||
:href="'#' + child.slug"
|
||||
>
|
||||
{{ child.title }}
|
||||
</a>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { Theme } from "vitepress";
|
||||
import Layout from "./Layout.vue";
|
||||
import Demo from "./Demo.vue";
|
||||
import "@heroui-vue/styles/css";
|
||||
import "./utilities.css";
|
||||
import "./style.css";
|
||||
export default {
|
||||
Layout,
|
||||
enhanceApp({ app }) {
|
||||
app.component("ComponentPreview", Demo);
|
||||
},
|
||||
} satisfies Theme;
|
||||
@@ -0,0 +1,55 @@
|
||||
export interface SearchEntry {
|
||||
title: string;
|
||||
section: string;
|
||||
url: string;
|
||||
text: string;
|
||||
}
|
||||
export function searchDocs(
|
||||
entries: SearchEntry[],
|
||||
query: string,
|
||||
): SearchEntry[] {
|
||||
const terms = query.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean);
|
||||
if (!terms.length) return [];
|
||||
return entries
|
||||
.map((entry, index) => {
|
||||
const title = entry.title.toLocaleLowerCase(),
|
||||
section = entry.section.toLocaleLowerCase(),
|
||||
text = entry.text.toLocaleLowerCase();
|
||||
if (
|
||||
!terms.every((term) =>
|
||||
(title + " " + section + " " + text).includes(term),
|
||||
)
|
||||
)
|
||||
return null;
|
||||
const score = terms.reduce(
|
||||
(score, term) =>
|
||||
score +
|
||||
(title.includes(term) ? 12 : 0) +
|
||||
(section.includes(term) ? 8 : 0) +
|
||||
(text.includes(term) ? 1 : 0),
|
||||
0,
|
||||
);
|
||||
return { entry, score, index };
|
||||
})
|
||||
.filter((item): item is NonNullable<typeof item> => item !== null)
|
||||
.sort((a, b) => b.score - a.score || a.index - b.index)
|
||||
.slice(0, 20)
|
||||
.map((item) => item.entry);
|
||||
}
|
||||
|
||||
export function searchExcerpt(entry: SearchEntry, query: string): string {
|
||||
const text = entry.text
|
||||
.replace(/[-:|]{3,}/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
const terms = query.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
||||
const positions = terms
|
||||
.map((term) => text.toLocaleLowerCase().indexOf(term))
|
||||
.filter((index) => index >= 0);
|
||||
const start = positions.length ? Math.max(0, Math.min(...positions) - 28) : 0;
|
||||
return (
|
||||
(start ? "…" : "") +
|
||||
text.slice(start, start + 140) +
|
||||
(text.length > start + 140 ? "…" : "")
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
@import "tailwindcss/theme.css" layer(theme);
|
||||
@import "../../../../packages/styles/themes/shared/theme.css";
|
||||
@import "tailwindcss/utilities.css" layer(utilities);
|
||||
@source "../../demos";
|
||||
|
||||
/* Follow the document's explicit theme, including nested preview scopes. */
|
||||
@custom-variant dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));
|
||||
@custom-variant motion-reduce {
|
||||
&:is([data-reduce-motion="true"], [data-reduce-motion="true"] *) {
|
||||
@slot;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
@slot;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: 组件
|
||||
description: 已迁移组件及文档
|
||||
---
|
||||
|
||||
- [Button 按钮](./components/button)
|
||||
- [Card 卡片](./components/card)
|
||||
- [Input 输入框](./components/input)
|
||||
- [Switch 开关](./components/switch)
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
title: Button 按钮
|
||||
description: 可点击的按钮组件,支持多种变体与状态
|
||||
component: button
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="button-basic" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
<ComponentPreview name="button-variants" />
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="button-sizes" />
|
||||
|
||||
### 带图标
|
||||
|
||||
<ComponentPreview name="button-with-icons" />
|
||||
|
||||
### 仅图标
|
||||
|
||||
<ComponentPreview name="button-icon-only" />
|
||||
|
||||
### 加载中
|
||||
|
||||
此例固定展示上传中的外观;加载期间阻止重复提交,但保留键盘焦点。要体验开始、完成和再次上传,请使用下一例。
|
||||
|
||||
<ComponentPreview name="button-loading" />
|
||||
|
||||
### 加载中(点击触发)
|
||||
|
||||
点击“上传文件”后进入加载状态,2 秒后恢复,可重复操作。
|
||||
|
||||
<ComponentPreview name="button-loading-state" />
|
||||
|
||||
### 宽度充满
|
||||
|
||||
<ComponentPreview name="button-full-width" />
|
||||
|
||||
### 禁用状态
|
||||
|
||||
<ComponentPreview name="button-disabled" />
|
||||
|
||||
### 社交媒体按钮
|
||||
|
||||
<ComponentPreview name="button-social" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 使用 `asChild` 将按钮属性与交互合并到一个自定义原生 button,作用域插槽提供状态。对应上游 render 函数示例,不将 render prop 原样搬入 Vue。
|
||||
|
||||
<ComponentPreview name="button-render-function" />
|
||||
|
||||
### 添加自定义变体
|
||||
|
||||
可通过包装组件并添加自定义变体来扩展组件。下面使用与上游相同的 `tv` 扩展方式,提供额外的圆角与尺寸配置。
|
||||
|
||||
<ComponentPreview name="button-custom-variants" />
|
||||
|
||||
### 添加涟漪效果
|
||||
|
||||
通过组合添加涟漪。本示例使用 Vue 和 CSS 实现,支持指针、Enter 和空格触发;不直接依赖上游 React 的 m3-ripple,减少动态效果时缩短动画。
|
||||
|
||||
<ComponentPreview name="button-ripple-effect" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="button-custom-styles" />
|
||||
|
||||
使用标准 `class` 属性添加工具类。组件保持上游的尺寸、间距、BEM 结构与状态钩子;类名前缀改为 `hv-`。
|
||||
|
||||
```vue
|
||||
<Button class="rounded-lg">自定义圆角</Button>
|
||||
```
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-button--primary {
|
||||
--button-bg: oklch(0.6 0.2 300);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
基础类为 `.hv-button`,变体为 `.hv-button--primary` 等;尺寸为 `.hv-button--sm` / `md` / `lg`。支持 `.hv-button--icon-only` 和 `.hv-button--full-width`。
|
||||
|
||||
### 交互状态
|
||||
|
||||
保留 `data-hovered`、`data-pressed`、`data-focused`、`data-focus-visible`、`data-pending` 状态;键盘焦点样式与鼠标焦点区分。加载期间保留焦点并阻止重复点击,通过 aria-disabled 呈现半透明的原变体颜色。
|
||||
|
||||
## API 参考
|
||||
|
||||
### Button
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | --------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------- |
|
||||
| `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'outline' \| 'ghost' \| 'danger' \| 'danger-soft'` | `'primary'` | 视觉样式变体 |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 按钮尺寸 |
|
||||
| `fullWidth` | `boolean` | `false` | 是否占满容器宽度 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 |
|
||||
| `isPending` | `boolean` | `false` | 是否处于加载状态 |
|
||||
| `isIconOnly` | `boolean` | `false` | 是否仅包含图标 |
|
||||
| `asChild` | `boolean` | `false` | 将属性与交互合并到默认插槽中唯一的原生 button |
|
||||
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | 原生按钮类型 |
|
||||
|
||||
### 事件与插槽
|
||||
|
||||
Vue 使用 `@click` 和默认作用域插槽。插槽提供 `isPending`、`isPressed`、`isHovered`、`isFocused`、`isFocusVisible`、`isDisabled`。原生属性、class、style、事件透传至 button。
|
||||
|
||||
`onPress` / PressEvent 与 `@click` 的事件模型不同,不宣称完全等价。初版 `disabled` / `loading` 继续作为兼容别名;新代码使用 `isDisabled` / `isPending`。`isPending` 不自动插入加载图标,采用上游的组合方式。`loading` 是相同加载语义的兼容别名,额外自动显示旋转图标;不会设置原生 disabled。`asChild` 下内容由调用者完整组合,默认插槽必须只包含一个原生 button。
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 描述 |
|
||||
| ---------------- | --------- | -------------------------------- |
|
||||
| `isPending` | `boolean` | 是否处于加载状态 |
|
||||
| `isPressed` | `boolean` | 是否正在按下 |
|
||||
| `isHovered` | `boolean` | 是否悬停 |
|
||||
| `isFocused` | `boolean` | 是否聚焦 |
|
||||
| `isFocusVisible` | `boolean` | 是否显示键盘焦点指示器 |
|
||||
| `isDisabled` | `boolean` | 是否由禁用属性禁用,不与加载混用 |
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Card 卡片](./card) · [Input 输入框](./input) · [Switch 开关](./switch)
|
||||
@@ -0,0 +1,121 @@
|
||||
---
|
||||
title: Card 卡片
|
||||
description: 灵活容器组件,用于分组相关内容与操作
|
||||
component: card
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="card-default" />
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle />
|
||||
<CardDescription />
|
||||
</CardHeader>
|
||||
<CardContent />
|
||||
<CardFooter />
|
||||
</Card>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
Card 提供语义变体,描述 prominence 级别而非具体视觉样式,允许主题以不同方式解读:
|
||||
|
||||
<ComponentPreview name="card-variants" />
|
||||
|
||||
- `transparent`:透明背景,无阴影,适合嵌套卡片。
|
||||
- `default`:标准卡片,使用 `--surface`。
|
||||
- `secondary`:使用 `--surface-secondary`。
|
||||
- `tertiary`:使用 `--surface-tertiary`。
|
||||
|
||||
基线中文说明中的部分表面映射与实际 CSS 不一致;这里以固定提交的 CSS 为准。
|
||||
|
||||
### 水平布局
|
||||
|
||||
<ComponentPreview name="card-horizontal" />
|
||||
|
||||
### 带头像
|
||||
|
||||
<ComponentPreview name="card-with-avatar" />
|
||||
|
||||
### 带图片
|
||||
|
||||
<ComponentPreview name="card-with-images" />
|
||||
|
||||
### 搭配表单
|
||||
|
||||
<ComponentPreview name="card-with-form" />
|
||||
|
||||
头像使用 Reka Avatar 组合;链接与表单使用原生 HTML,标签与输入显式关联。此示例不发送登录请求;图片沿用上游公开资源地址。
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="card-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-card__title {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
| 部件 | CSS 类 | data-slot | 默认元素 |
|
||||
| --------------- | ----------------------- | ------------------ | -------- |
|
||||
| Card | `.hv-card` | `card` | div |
|
||||
| CardHeader | `.hv-card__header` | `card-header` | div |
|
||||
| CardTitle | `.hv-card__title` | `card-title` | h3 |
|
||||
| CardDescription | `.hv-card__description` | `card-description` | p |
|
||||
| CardContent | `.hv-card__content` | `card-content` | div |
|
||||
| CardFooter | `.hv-card__footer` | `card-footer` | div |
|
||||
|
||||
## API 参考
|
||||
|
||||
### Card
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | --------------------------------------------------------- | ----------- | ------------------------------ |
|
||||
| `variant` | `'transparent' \| 'default' \| 'secondary' \| 'tertiary'` | `'default'` | 表示 prominence 级别的语义变体 |
|
||||
| `as` | `string` | `'div'` | 渲染的 HTML 元素 |
|
||||
| `class` | `string / object / array` | — | Vue 标准类名合并 |
|
||||
|
||||
### CardHeader / CardTitle / CardDescription / CardContent / CardFooter
|
||||
|
||||
各部件支持 `as`、默认插槽和原生属性。默认标签见上表。Vue 使用独立命名导出替代 `Card.Header` 等 React 部件访问方式。
|
||||
|
||||
## 无障碍
|
||||
|
||||
```vue
|
||||
<Card as="article" aria-labelledby="card-title">
|
||||
<CardHeader><CardTitle id="card-title">Article Title</CardTitle></CardHeader>
|
||||
</Card>
|
||||
```
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Input 输入框](./input)
|
||||
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: Input 输入框
|
||||
description: 接受标准 HTML 属性的原生单行文本输入组件
|
||||
component: input
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="input-basic" />
|
||||
|
||||
::: info 字段组合
|
||||
校验、标签与错误消息由 TextField 体系负责。TextField 尚未迁移,当前请使用原生 label、aria-describedby 和 aria-invalid 关联。
|
||||
:::
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
Input 组件支持两种视觉变体:
|
||||
|
||||
- **primary**(默认):标准样式带阴影,适用于大多数场景。
|
||||
- **secondary**:低强调变体无阴影,适用于 Surface 组件内。
|
||||
|
||||
<ComponentPreview name="input-variants" />
|
||||
|
||||
### 表面样式
|
||||
|
||||
在表面容器内使用 `variant="secondary"` 以应用适合背景的低强调变体。
|
||||
|
||||
<ComponentPreview name="input-on-surface" />
|
||||
|
||||
### 宽度充满
|
||||
|
||||
<ComponentPreview name="input-full-width" />
|
||||
|
||||
### 输入类型
|
||||
|
||||
<ComponentPreview name="input-types" />
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview name="input-controlled" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="input-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-input {
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
基础类 `.hv-input`;变体 `.hv-input--primary` / `.hv-input--secondary`;宽度修饰符 `.hv-input--full-width`。保留原生 hover / focus / disabled 和 `data-invalid` 状态。
|
||||
|
||||
## API 参考
|
||||
|
||||
### Input
|
||||
|
||||
Input 接受标准 HTML input 属性,以及以下 props:
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------------------------------------------------- | -------------------------- | ----------- | --------------------------------- |
|
||||
| `modelValue` | `string` | — | 受控值,使用 v-model |
|
||||
| `defaultValue` | `string` | `''` | 非受控初始值 |
|
||||
| `variant` | `'primary' \| 'secondary'` | `'primary'` | 视觉变体 |
|
||||
| `fullWidth` | `boolean` | `false` | 是否占满容器宽度 |
|
||||
| `type` | `string` | `'text'` | 原生输入类型 |
|
||||
| `invalid` | `boolean` | `false` | 设置 aria-invalid 和 data-invalid |
|
||||
| `disabled` / `readonly` / `required` | `boolean` | `false` | 原生表单状态 |
|
||||
| `name` / `placeholder` / `autocomplete` / `pattern` | `string` | — | 原生输入属性 |
|
||||
| `maxlength` / `minlength` | `number` | — | 长度限制 |
|
||||
| `min` / `max` / `step` | `string / number` | — | 数值与日期约束 |
|
||||
|
||||
### 事件与方法
|
||||
|
||||
`update:modelValue` 传递字符串;`@input` / `@change` 保留原生事件。`focus()` 可通过模板引用调用。原生表单 reset 还原非受控初始值;受控值由父组件管理。
|
||||
|
||||
不把 React 的 `value` + `onChange` 直接复制为 Vue 状态 API。`className` 改为 `class`。TextField 上下文的自动继承尚未实现。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Card 卡片](./card)
|
||||
@@ -0,0 +1,179 @@
|
||||
---
|
||||
title: Switch 开关
|
||||
description: 用于布尔状态的开关组件。
|
||||
component: switch
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
Description,
|
||||
Label,
|
||||
SwitchIcon,
|
||||
SwitchGroup,
|
||||
FieldError,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="switch-basic" />
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<Switch>
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
<Description>允许接收通知</Description>
|
||||
</Switch>
|
||||
```
|
||||
|
||||
请把 SwitchControl 与标签文本放入 SwitchContent;Description 作为其兄弟节点。Vue 底座使用原生 button 承载 role="switch",不是 React Aria 的 label 结构。
|
||||
|
||||
## 示例
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="switch-sizes" />
|
||||
|
||||
### 带图标
|
||||
|
||||
<ComponentPreview name="switch-with-icons" />
|
||||
|
||||
### 禁用
|
||||
|
||||
<ComponentPreview name="switch-disabled" />
|
||||
|
||||
### 无标签
|
||||
|
||||
<ComponentPreview name="switch-without-label" />
|
||||
|
||||
### 带描述
|
||||
|
||||
<ComponentPreview name="switch-with-description" />
|
||||
|
||||
### 默认选中
|
||||
|
||||
<ComponentPreview name="switch-default-selected" />
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview name="switch-controlled" />
|
||||
|
||||
### 标签位置
|
||||
|
||||
<ComponentPreview name="switch-label-position" />
|
||||
|
||||
### 分组
|
||||
|
||||
<ComponentPreview name="switch-group" />
|
||||
|
||||
### 横向分组
|
||||
|
||||
<ComponentPreview name="switch-group-horizontal" />
|
||||
|
||||
### 表单集成
|
||||
|
||||
<ComponentPreview name="switch-form" />
|
||||
|
||||
### 渲染属性
|
||||
|
||||
Vue 使用作用域插槽读取选择状态。
|
||||
|
||||
<ComponentPreview name="switch-render-props" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 使用 `asChild` 合并根容器属性,默认插槽必须只有一个自定义根元素;内部仍需放置 SwitchContent。
|
||||
|
||||
<ComponentPreview name="switch-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="switch-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-switch__control {
|
||||
border-radius: 12px;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
保留字段根容器、Content、Control、Thumb、Icon 的组合结构和 data-slot;类名前缀为 `hv-`。选中状态使用 `data-selected="true"`,禁用使用 `data-disabled="true"`。尺寸与滑块比例移植自基线 CSS。
|
||||
|
||||
## API 参考
|
||||
|
||||
### Switch
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------------------- | --------------------------------------------------------------------- | ---------- | -------------------------------- |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Switch 尺寸 |
|
||||
| `checked` | `boolean` | — | Vue 受控值,使用 v-model:checked |
|
||||
| `isSelected` | `boolean` | — | 上游同名受控属性,优先于 checked |
|
||||
| `defaultSelected` | `boolean` | `false` | 非受控初始值 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 |
|
||||
| `isReadOnly` | `boolean` | `false` | 是否只读 |
|
||||
| `isInvalid` | `boolean` | `false` | ARIA 无效状态 |
|
||||
| `isRequired` | `boolean` | `false` | 是否必须开启 |
|
||||
| `name` | `string` | — | 表单字段名称 |
|
||||
| `value` | `string` | — | 表单提交值 |
|
||||
| `asChild` | `boolean` | `false` | 合并根属性到唯一自定义容器 |
|
||||
| `validate` | `(value: boolean) => string \| string[] \| true \| null \| undefined` | — | 自定义校验 |
|
||||
| `validationBehavior` | `'native' \| 'aria'` | `'native'` | 校验与错误展示方式 |
|
||||
|
||||
### SwitchContent / SwitchControl / SwitchThumb / SwitchIcon
|
||||
|
||||
分别对应上游 Content、Control、Thumb、Icon。Content 提供可点击的开关语义,其余为可组合样式部件。空默认插槽会自动渲染轨道与滑块;使用自定义插槽时由调用者组合部件。
|
||||
|
||||
### 事件与插槽
|
||||
|
||||
`update:checked`、`update:isSelected` 与 `change` 都传递 boolean。根作用域插槽提供 isSelected、isDisabled、isReadOnly、isInvalid、isRequired。根 attrs 的 class/style/data-* 应用到字段容器,ARIA 与 DOM 事件透传到 Content 按钮。
|
||||
|
||||
### 表单与校验
|
||||
|
||||
`validate(value)` 返回错误字符串、字符串数组,或 `true` / `null` / `undefined` 表示通过。`validationBehavior="native"`(默认)通过原生 checkbox 的约束阻止无效表单提交,校验失败后展示错误并将焦点交给开关;`"aria"` 立即设置 ARIA 错误状态,提交由调用者处理。
|
||||
|
||||
```vue
|
||||
<Switch
|
||||
name="consent"
|
||||
is-required
|
||||
:validate="(value) => (value ? true : '请先开启此选项。')"
|
||||
>
|
||||
<SwitchContent><SwitchControl><SwitchThumb /></SwitchControl>同意接收通知</SwitchContent>
|
||||
<Description>可随时在设置中关闭。</Description>
|
||||
<FieldError />
|
||||
</Switch>
|
||||
```
|
||||
|
||||
Description 与 FieldError 自动生成唯一 ID,并关联到 Content 的 aria-describedby。表单 reset 恢复非受控初值;受控值由父组件管理。
|
||||
|
||||
### SwitchGroup
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------- | ---------------------------- | ------------ | ---------- |
|
||||
| `orientation` | `'horizontal' \| 'vertical'` | `'vertical'` | 组布局方向 |
|
||||
|
||||
SwitchGroup 是布局容器,每个 Switch 独立维护值;请提供 aria-label 或 aria-labelledby 标注分组。
|
||||
|
||||
### 当前差异
|
||||
|
||||
`disabled` / `required` / `defaultChecked` 作为兼容别名保留。`change` 事件传递 boolean;React Aria 的 PressEvent 仍不等价于 DOM click。根组件的 class/style/data-* 作用于字段容器,ARIA 与 DOM 事件作用于 Content 按钮;Content 上的显式属性可覆盖默认透传。`asChild` 替代 React render prop。FieldError 当前仅接入 Switch 字段,尚未提供完整 TextField / Form 体系。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Input 输入框](./input)
|
||||
@@ -0,0 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
const pressed = ref(false);
|
||||
</script>
|
||||
<template>
|
||||
<Button @click="pressed = true">{{ pressed ? "按钮已按下" : "点我" }}</Button>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Button
|
||||
variant="ghost"
|
||||
class="gradient-border relative z-0 rounded-full bg-linear-to-t from-neutral-100 to-white px-10 py-3 font-[450] text-neutral-800 shadow-none transition-all duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] [--gradient-border-width:1.5px] [--gradient-border:linear-gradient(315deg,#e5e5e5_0%,#fafafa_50%,#c4c4c4_100%)] hover:from-white hover:to-neutral-50 hover:brightness-105 active:scale-95 dark:from-neutral-900 dark:via-neutral-800 dark:to-neutral-800/80 dark:text-neutral-100 dark:[--gradient-border:linear-gradient(315deg,#404040_0%,#262626_50%,#525252_100%)] dark:hover:from-neutral-800 dark:hover:via-neutral-800 dark:hover:to-neutral-900/90 motion-reduce:transition-none"
|
||||
:style="{
|
||||
boxShadow:
|
||||
'rgba(0, 0, 0, 0.02) 0px 1px 6px, rgba(0, 0, 0, 0.02) 0px 3px 12px, rgba(0, 0, 0, 0.01) 0px 8px 24px, rgba(0, 0, 0, 0.02) 0px 18px 40px, rgba(0, 0, 0, 0.02) 0px 40px 80px',
|
||||
}"
|
||||
>
|
||||
升级
|
||||
</Button>
|
||||
</template>
|
||||
<style scoped>
|
||||
.gradient-border::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
border-radius: inherit;
|
||||
padding: var(--gradient-border-width, 1px);
|
||||
background: var(--gradient-border);
|
||||
pointer-events: none;
|
||||
-webkit-mask:
|
||||
linear-gradient(#fff 0 0) content-box,
|
||||
linear-gradient(#fff 0 0);
|
||||
-webkit-mask-composite: xor;
|
||||
mask:
|
||||
linear-gradient(#fff 0 0) content-box,
|
||||
linear-gradient(#fff 0 0);
|
||||
mask-composite: exclude;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, h, type PropType } from "vue";
|
||||
import { Button, buttonVariants, tv } from "@heroui-vue/components";
|
||||
const myButtonVariants = tv({
|
||||
extend: buttonVariants,
|
||||
base: "text-base font-semibold shadow-md text-shadow-lg data-[pending=true]:opacity-40",
|
||||
variants: {
|
||||
variant: {
|
||||
primary:
|
||||
"text-white dark:bg-white/10 dark:text-white dark:hover:bg-white/15",
|
||||
},
|
||||
radius: {
|
||||
full: "rounded-full",
|
||||
lg: "rounded-lg",
|
||||
md: "rounded-md",
|
||||
sm: "rounded-sm",
|
||||
},
|
||||
size: {
|
||||
sm: "h-10 px-4",
|
||||
md: "h-11 px-6",
|
||||
lg: "h-12 px-8",
|
||||
xl: "h-13 px-10",
|
||||
},
|
||||
},
|
||||
defaultVariants: { radius: "full", size: "md", variant: "primary" },
|
||||
});
|
||||
const CustomButton = defineComponent({
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
radius: {
|
||||
type: String as PropType<"full" | "lg" | "md" | "sm">,
|
||||
default: "full",
|
||||
},
|
||||
size: {
|
||||
type: String as PropType<"sm" | "md" | "lg" | "xl">,
|
||||
default: "md",
|
||||
},
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
return () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
...attrs,
|
||||
class: myButtonVariants({
|
||||
radius: props.radius,
|
||||
size: props.size,
|
||||
class: attrs.class as string,
|
||||
}),
|
||||
},
|
||||
slots,
|
||||
);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<CustomButton>自定义按钮</CustomButton>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="demo-row">
|
||||
<Button is-disabled variant="primary">主要</Button>
|
||||
<Button is-disabled variant="secondary">次要</Button>
|
||||
<Button is-disabled variant="tertiary">第三</Button>
|
||||
<Button is-disabled variant="outline">线框</Button>
|
||||
<Button is-disabled variant="ghost">幽灵</Button>
|
||||
<Button is-disabled variant="danger">危险</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { IconPlus } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="full-width-demo">
|
||||
<Button full-width>主要按钮</Button>
|
||||
<Button full-width>
|
||||
<IconPlus aria-hidden="true" />
|
||||
带图标
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.full-width-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 400px;
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { IconDots, IconSettings, IconTrash } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="demo-row">
|
||||
<Button is-icon-only variant="tertiary" aria-label="更多选项">
|
||||
<IconDots aria-hidden="true" />
|
||||
</Button>
|
||||
<Button is-icon-only variant="secondary" aria-label="设置">
|
||||
<IconSettings aria-hidden="true" />
|
||||
</Button>
|
||||
<Button is-icon-only variant="danger" aria-label="删除">
|
||||
<IconTrash aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { IconLoader2 } from "@tabler/icons-vue";
|
||||
import { IconPaperclip } from "@tabler/icons-vue";
|
||||
import { ref, onBeforeUnmount } from "vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
const isLoading = ref(false),
|
||||
message = ref("");
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
function upload() {
|
||||
if (isLoading.value) return;
|
||||
isLoading.value = true;
|
||||
message.value = "";
|
||||
timer = setTimeout(() => {
|
||||
isLoading.value = false;
|
||||
message.value = "上传完成,可以再次上传。";
|
||||
}, 2000);
|
||||
}
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
</script>
|
||||
<template>
|
||||
<div class="upload-demo">
|
||||
<Button :is-pending="isLoading" @click="upload">
|
||||
<span
|
||||
v-if="isLoading"
|
||||
data-slot="spinner"
|
||||
class="inline-flex size-4 shrink-0"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<IconLoader2
|
||||
class="size-full animate-spin motion-reduce:animate-none"
|
||||
/>
|
||||
</span>
|
||||
<IconPaperclip v-else aria-hidden="true" />
|
||||
{{ isLoading ? "上传中…" : "上传文件" }}
|
||||
</Button>
|
||||
<p class="upload-status" role="status">{{ message }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.upload-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.upload-status {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
min-height: 20px;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { IconLoader2 } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Button is-pending v-slot="{ isPending }">
|
||||
<span
|
||||
v-if="isPending"
|
||||
data-slot="spinner"
|
||||
class="inline-flex size-4 shrink-0"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<IconLoader2 class="size-full animate-spin motion-reduce:animate-none" />
|
||||
</span>
|
||||
上传中…
|
||||
</Button>
|
||||
</template>
|
||||
@@ -0,0 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Button as-child v-slot="{ isPressed }">
|
||||
<button :data-custom="isPressed ? 'pressed' : 'bar'">点按</button>
|
||||
</Button>
|
||||
</template>
|
||||
@@ -0,0 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
const waves = ref<{ id: number; x: number; y: number; size: number }[]>([]);
|
||||
let id = 0;
|
||||
function add(target: HTMLElement, x: number, y: number) {
|
||||
const size = Math.max(target.offsetWidth, target.offsetHeight) * 2;
|
||||
waves.value.push({ id: ++id, x: x - size / 2, y: y - size / 2, size });
|
||||
}
|
||||
function ripple(event: PointerEvent) {
|
||||
const target = event.currentTarget as HTMLElement;
|
||||
const rect = target.getBoundingClientRect();
|
||||
add(target, event.clientX - rect.left, event.clientY - rect.top);
|
||||
}
|
||||
function keyboardRipple(event: KeyboardEvent) {
|
||||
if (event.repeat || !["Enter", " "].includes(event.key)) return;
|
||||
const target = event.currentTarget as HTMLElement;
|
||||
add(target, target.offsetWidth / 2, target.offsetHeight / 2);
|
||||
}
|
||||
function remove(id: number) {
|
||||
waves.value = waves.value.filter((wave) => wave.id !== id);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Button
|
||||
variant="secondary"
|
||||
class="ripple-button"
|
||||
@pointerdown="ripple"
|
||||
@keydown="keyboardRipple"
|
||||
>
|
||||
点我
|
||||
<span
|
||||
v-for="wave in waves"
|
||||
:key="wave.id"
|
||||
class="ripple-wave"
|
||||
:style="{
|
||||
left: wave.x + 'px',
|
||||
top: wave.y + 'px',
|
||||
width: wave.size + 'px',
|
||||
height: wave.size + 'px',
|
||||
}"
|
||||
aria-hidden="true"
|
||||
@animationend="remove(wave.id)"
|
||||
/>
|
||||
</Button>
|
||||
</template>
|
||||
<style scoped>
|
||||
.ripple-button {
|
||||
overflow: hidden;
|
||||
}
|
||||
.ripple-wave {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
opacity: 0.18;
|
||||
transform: scale(0);
|
||||
animation: button-ripple 0.6s ease-out forwards;
|
||||
}
|
||||
@keyframes button-ripple {
|
||||
to {
|
||||
transform: scale(1);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ripple-wave {
|
||||
animation-duration: 1ms;
|
||||
}
|
||||
}
|
||||
:global([data-reduce-motion="true"]) .ripple-wave {
|
||||
animation-duration: 1ms;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="demo-row">
|
||||
<Button size="sm">小</Button>
|
||||
<Button size="md">中</Button>
|
||||
<Button size="lg">大</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
IconBrandGoogle,
|
||||
IconBrandGithubFilled,
|
||||
IconBrandAppleFilled,
|
||||
} from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="social-demo">
|
||||
<Button full-width variant="tertiary">
|
||||
<IconBrandGoogle aria-hidden="true" />
|
||||
使用 Google 登录
|
||||
</Button>
|
||||
<Button full-width variant="tertiary">
|
||||
<IconBrandGithubFilled aria-hidden="true" />
|
||||
使用 GitHub 登录
|
||||
</Button>
|
||||
<Button full-width variant="tertiary">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
使用 Apple 登录
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.social-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 320px;
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="demo-row">
|
||||
<Button variant="primary">主要</Button>
|
||||
<Button variant="secondary">次要</Button>
|
||||
<Button variant="tertiary">第三</Button>
|
||||
<Button variant="outline">线框</Button>
|
||||
<Button variant="ghost">幽灵</Button>
|
||||
<Button variant="danger">危险</Button>
|
||||
<Button variant="danger-soft">柔和危险</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
IconSearch,
|
||||
IconUserPlus,
|
||||
IconMail,
|
||||
IconTrash,
|
||||
} from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="demo-row">
|
||||
<Button variant="primary">
|
||||
<IconSearch aria-hidden="true" />
|
||||
搜索
|
||||
</Button>
|
||||
<Button variant="secondary">
|
||||
<IconUserPlus aria-hidden="true" />
|
||||
添加成员
|
||||
</Button>
|
||||
<Button variant="tertiary">
|
||||
<IconMail aria-hidden="true" />
|
||||
邮件
|
||||
</Button>
|
||||
<Button variant="danger">
|
||||
<IconTrash aria-hidden="true" />
|
||||
删除
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,70 @@
|
||||
<script setup lang="ts">
|
||||
import { IconStar, IconCheck } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
const features = [
|
||||
"无限项目与协作者",
|
||||
"优先支持,24 小时响应",
|
||||
"高级分析与导出",
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<Card
|
||||
class="relative w-full max-w-md overflow-hidden border border-accent/20 bg-linear-to-br from-accent/12 via-surface to-surface-secondary shadow-lg shadow-accent/10 dark:border-accent/30 dark:from-accent/20 dark:via-surface dark:to-accent/8 dark:shadow-accent/5"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute -top-12 -right-12 size-40 rounded-full bg-accent/20 blur-3xl dark:bg-accent/30"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute -bottom-8 -left-8 size-28 rounded-full bg-accent/10 blur-2xl dark:bg-accent/20"
|
||||
/>
|
||||
|
||||
<CardHeader class="relative gap-3">
|
||||
<span
|
||||
class="w-fit rounded-full bg-accent/15 px-2.5 py-0.5 text-xs font-medium tracking-wide text-accent dark:bg-accent/25 dark:text-accent-soft-foreground"
|
||||
>
|
||||
推荐
|
||||
</span>
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent/15 text-accent dark:bg-accent/20 dark:text-accent-soft-foreground"
|
||||
>
|
||||
<IconStar aria-hidden="true" class="size-5" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<CardTitle>升级到 Pro</CardTitle>
|
||||
<CardDescription>
|
||||
解锁面向成长型产品的团队工作流与洞察。
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent class="relative">
|
||||
<ul class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="feature in features"
|
||||
:key="feature"
|
||||
class="flex items-center gap-2 text-sm text-muted"
|
||||
>
|
||||
<IconCheck aria-hidden="true" class="size-4 shrink-0 text-accent" />
|
||||
{{ feature }}
|
||||
</li>
|
||||
</ul>
|
||||
</CardContent>
|
||||
|
||||
<CardFooter class="relative flex-col gap-2 sm:flex-row">
|
||||
<Button class="w-full shadow-md shadow-accent/20">立即升级</Button>
|
||||
<Button class="w-full" variant="secondary">对比方案</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import { IconArrowUpRight } from "@tabler/icons-vue";
|
||||
import { IconCoin } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Card class="w-[400px]">
|
||||
<IconCoin role="img" aria-label="美元图标" class="size-6" />
|
||||
<CardHeader>
|
||||
<CardTitle>成为 Acme 创作者!</CardTitle>
|
||||
<CardDescription>
|
||||
前往 Acme 创作者中心立即注册,开始从粉丝与支持者处获得积分奖励。
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter>
|
||||
<a
|
||||
class="demo-link inline-flex items-center gap-1"
|
||||
aria-label="前往 Acme 创作者中心(在新标签页打开)"
|
||||
href="https://heroui.com"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
创作者中心
|
||||
<IconArrowUpRight aria-hidden="true" class="size-3" />
|
||||
</a>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { closeButtonVariants } from "@heroui-vue/styles";
|
||||
import { IconX } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Card class="w-full items-stretch md:flex-row">
|
||||
<div
|
||||
class="relative h-[140px] w-full shrink-0 overflow-hidden rounded-2xl sm:h-[120px] sm:w-[120px]"
|
||||
>
|
||||
<img
|
||||
alt="樱桃"
|
||||
class="pointer-events-none absolute inset-0 h-full w-full scale-125 object-cover select-none"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/cherries.jpeg"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-1 flex-col gap-3">
|
||||
<CardHeader class="gap-1">
|
||||
<CardTitle class="pe-8">成为 ACME 创作者!</CardTitle>
|
||||
<CardDescription>
|
||||
这是一段占位说明文字,用于展示横向卡片布局、配图与右上角关闭按钮的排版效果。
|
||||
</CardDescription>
|
||||
<button
|
||||
type="button"
|
||||
:class="closeButtonVariants()"
|
||||
aria-label="关闭横幅"
|
||||
class="absolute end-3 top-3"
|
||||
>
|
||||
<IconX aria-hidden="true" />
|
||||
</button>
|
||||
</CardHeader>
|
||||
<CardFooter
|
||||
class="mt-auto flex w-full flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<span class="text-sm font-medium text-foreground">
|
||||
仅剩 10 个名额
|
||||
</span>
|
||||
<span class="text-xs text-muted">报名截止:10 月 10 日</span>
|
||||
</div>
|
||||
<Button class="w-full sm:w-auto">立即申请</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<Card class="w-[320px]" variant="transparent">
|
||||
<CardHeader>
|
||||
<CardTitle>透明</CardTitle>
|
||||
<CardDescription>背景透明,视觉层级较低(transparent)</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p>适合次要内容或嵌套在其它容器中的卡片</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card class="w-[320px]" variant="default">
|
||||
<CardHeader>
|
||||
<CardTitle>默认</CardTitle>
|
||||
<CardDescription>标准外观(bg-surface)</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p>大多数场景的默认卡片变体</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card class="w-[320px]" variant="secondary">
|
||||
<CardHeader>
|
||||
<CardTitle>次要</CardTitle>
|
||||
<CardDescription>中等强调(bg-surface-secondary)</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p>用于需要适度吸引注意力的内容</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card class="w-[320px]" variant="tertiary">
|
||||
<CardHeader>
|
||||
<CardTitle>第三</CardTitle>
|
||||
<CardDescription>更高强调(bg-surface-tertiary)</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p>适合主要内容或需要突出的展示位</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
} from "@heroui-vue/components";
|
||||
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<Card class="w-[200px] gap-2">
|
||||
<img
|
||||
alt="独立创客社区"
|
||||
class="pointer-events-none aspect-square w-14 rounded-2xl object-cover select-none"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo1.jpg"
|
||||
/>
|
||||
<CardHeader>
|
||||
<CardTitle>Indie Hackers</CardTitle>
|
||||
<CardDescription>148 位成员</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter class="flex gap-2">
|
||||
<AvatarRoot
|
||||
aria-label="玛莎的头像"
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-5"
|
||||
>
|
||||
<AvatarImage
|
||||
class="size-full object-cover"
|
||||
alt="玛莎的头像"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="flex size-full items-center justify-center bg-default text-xs"
|
||||
>
|
||||
IH
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
<span class="text-xs">创建者:玛莎</span>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
<Card class="w-[200px] gap-2">
|
||||
<img
|
||||
alt="AI 开发者社区"
|
||||
class="pointer-events-none aspect-square w-14 rounded-2xl object-cover select-none"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo2.jpg"
|
||||
/>
|
||||
<CardHeader>
|
||||
<CardTitle>AI Builders</CardTitle>
|
||||
<CardDescription>362 位成员</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter class="flex gap-2">
|
||||
<AvatarRoot
|
||||
aria-label="约翰的头像"
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-5"
|
||||
>
|
||||
<AvatarImage
|
||||
class="size-full object-cover"
|
||||
alt="约翰的头像"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="flex size-full items-center justify-center bg-default text-xs"
|
||||
>
|
||||
B
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
<span class="text-xs">创建者:约翰</span>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,71 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { Input, Label } from "@heroui-vue/components";
|
||||
import { ref, useId } from "vue";
|
||||
const id = useId();
|
||||
const submitted = ref(false);
|
||||
const message = ref("");
|
||||
</script>
|
||||
<template>
|
||||
<Card class="w-full max-w-md">
|
||||
<CardHeader>
|
||||
<CardTitle>登录</CardTitle>
|
||||
<CardDescription>输入账号信息以访问您的账户</CardDescription>
|
||||
</CardHeader>
|
||||
<form class="flex flex-col" @submit.prevent="submitted = true">
|
||||
<CardContent>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label :for="id + '-email'">邮箱</Label>
|
||||
<Input
|
||||
:id="id + '-email'"
|
||||
name="email"
|
||||
type="email"
|
||||
autocomplete="email"
|
||||
placeholder="email@example.com"
|
||||
variant="secondary"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label :for="id + '-password'">密码</Label>
|
||||
<Input
|
||||
:id="id + '-password'"
|
||||
name="password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
placeholder="••••••••"
|
||||
variant="secondary"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
<CardFooter class="mt-4 flex flex-col gap-2">
|
||||
<Button class="w-full" type="submit">登录</Button>
|
||||
<a
|
||||
class="demo-link text-center text-sm"
|
||||
href="#"
|
||||
@click.prevent="message = '请联系账户管理员重置密码。'"
|
||||
>
|
||||
忘记密码?
|
||||
</a>
|
||||
</CardFooter>
|
||||
<p
|
||||
v-if="submitted || message"
|
||||
role="status"
|
||||
class="mt-2 text-sm text-muted"
|
||||
>
|
||||
{{ message || "表单提交成功!此示例不会发送账号信息。" }}
|
||||
</p>
|
||||
</form>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,289 @@
|
||||
<script setup lang="ts">
|
||||
import { closeButtonVariants } from "@heroui-vue/styles";
|
||||
import { IconArrowUpRight, IconX } from "@tabler/icons-vue";
|
||||
import { IconCoin } from "@tabler/icons-vue";
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-full items-center justify-center">
|
||||
<div class="grid w-full max-w-2xl grid-cols-12 gap-4 p-4">
|
||||
<Card class="col-span-12 flex h-auto min-h-[152px] flex-col sm:flex-row">
|
||||
<div
|
||||
class="relative h-[140px] w-full shrink-0 overflow-hidden rounded-2xl sm:h-[120px] sm:w-[120px]"
|
||||
>
|
||||
<img
|
||||
alt="樱桃"
|
||||
class="pointer-events-none absolute inset-0 h-full w-full scale-125 object-cover select-none"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/cherries.jpeg"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-1 flex-col gap-3">
|
||||
<CardHeader class="gap-1">
|
||||
<CardTitle class="pe-8">成为 ACME 创作者!</CardTitle>
|
||||
<CardDescription>
|
||||
这是一段占位说明文字,用于展示横向卡片布局、配图与右上角关闭按钮的排版效果。
|
||||
</CardDescription>
|
||||
<button
|
||||
type="button"
|
||||
:class="closeButtonVariants()"
|
||||
aria-label="关闭横幅"
|
||||
class="absolute end-3 top-3"
|
||||
>
|
||||
<IconX aria-hidden="true" />
|
||||
</button>
|
||||
</CardHeader>
|
||||
<CardFooter
|
||||
class="mt-auto flex w-full flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<span class="text-sm font-medium text-foreground">
|
||||
仅剩 10 个名额
|
||||
</span>
|
||||
<span class="text-xs text-muted">报名截止:10 月 10 日</span>
|
||||
</div>
|
||||
<Button class="w-full sm:w-auto">立即申请</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
<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>
|
||||
</div>
|
||||
<CardHeader class="gap-3">
|
||||
<IconCoin
|
||||
role="img"
|
||||
aria-label="美元图标"
|
||||
class="size-8 shrink-0"
|
||||
/>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-xs font-medium text-muted uppercase">
|
||||
支付
|
||||
</span>
|
||||
<CardTitle class="pe-8 text-sm sm:text-base">
|
||||
现已支持加密货币提现
|
||||
</CardTitle>
|
||||
<CardDescription class="text-xs sm:text-sm">
|
||||
在设置中添加钱包即可提现
|
||||
</CardDescription>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardFooter>
|
||||
<a
|
||||
class="demo-link inline-flex items-center gap-1"
|
||||
aria-label="前往设置"
|
||||
href="#"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
前往设置
|
||||
<IconArrowUpRight aria-hidden="true" class="size-3" />
|
||||
</a>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
<Card class="col-span-12 gap-2 sm:col-span-6">
|
||||
<CardHeader>
|
||||
<AvatarRoot
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-[56px] rounded-xl"
|
||||
>
|
||||
<AvatarImage
|
||||
class="size-full object-cover"
|
||||
alt="演示图片 1"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo1.jpg"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="flex size-full items-center justify-center bg-default"
|
||||
>
|
||||
JK
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</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
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-4"
|
||||
>
|
||||
<AvatarImage
|
||||
class="size-full object-cover"
|
||||
alt="约翰"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="flex size-full items-center justify-center bg-default"
|
||||
>
|
||||
JK
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
<p class="text-xs text-muted">创建者:约翰</p>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
<Card class="col-span-12 gap-2 sm:col-span-6">
|
||||
<CardHeader>
|
||||
<AvatarRoot
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-[56px] rounded-xl"
|
||||
>
|
||||
<AvatarImage
|
||||
class="size-full object-cover"
|
||||
alt="演示图片 2"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/demo2.jpg"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="flex size-full items-center justify-center bg-default"
|
||||
>
|
||||
AB
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
</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
|
||||
class="inline-flex shrink-0 overflow-hidden rounded-full size-4"
|
||||
>
|
||||
<AvatarImage
|
||||
class="size-full object-cover"
|
||||
alt="玛莎"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="flex size-full items-center justify-center bg-default"
|
||||
>
|
||||
M
|
||||
</AvatarFallback>
|
||||
</AvatarRoot>
|
||||
<p class="text-xs text-muted">创建者:玛莎</p>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card
|
||||
class="col-span-12 min-h-[200px] overflow-hidden rounded-3xl lg:col-span-6"
|
||||
>
|
||||
<img
|
||||
alt="NEO 家用机器人"
|
||||
aria-hidden="true"
|
||||
class="absolute inset-0 h-full w-full object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/neo2.jpeg"
|
||||
/>
|
||||
|
||||
<CardHeader class="z-10 text-white">
|
||||
<CardTitle
|
||||
class="text-xs font-semibold tracking-wide text-black/70"
|
||||
>
|
||||
NEO
|
||||
</CardTitle>
|
||||
<CardDescription
|
||||
class="text-sm leading-5 font-medium text-black/50"
|
||||
>
|
||||
家用机器人
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
|
||||
<CardFooter class="z-10 mt-auto flex items-center justify-between">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-black">即将推出</div>
|
||||
<div class="text-xs text-black/60">接收上架通知</div>
|
||||
</div>
|
||||
<Button class="bg-white text-black" size="sm" variant="tertiary">
|
||||
通知我
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div class="col-span-12 grid grid-cols-12 gap-4">
|
||||
<Card
|
||||
class="relative col-span-12 h-[250px] sm:h-[300px] md:col-span-8 md:h-[350px]"
|
||||
>
|
||||
<img
|
||||
alt="NEO 家用机器人"
|
||||
aria-hidden="true"
|
||||
class="absolute inset-0 h-full w-full object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/neo1.jpeg"
|
||||
/>
|
||||
|
||||
<CardFooter class="z-10 mt-auto flex items-end justify-between">
|
||||
<div>
|
||||
<div class="text-base font-medium text-black sm:text-lg">NEO</div>
|
||||
<div class="text-xs font-medium text-black/50 sm:text-sm">
|
||||
$499/月
|
||||
</div>
|
||||
</div>
|
||||
<Button class="bg-white text-black" size="sm" variant="tertiary">
|
||||
立即购买
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
|
||||
<div
|
||||
class="col-span-12 flex flex-col gap-2 md:col-span-4 md:justify-between md:gap-0 md:py-2"
|
||||
>
|
||||
<Card class="flex flex-row gap-3 p-1" variant="transparent">
|
||||
<img
|
||||
alt="未来感机器人"
|
||||
class="aspect-square h-16 w-16 shrink-0 rounded-xl object-cover select-none sm:h-20 sm:w-20"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/robot1.jpeg"
|
||||
/>
|
||||
<div class="flex flex-1 flex-col justify-center gap-1">
|
||||
<CardTitle class="text-sm">连接未来</CardTitle>
|
||||
<CardDescription class="text-xs">今天 18:30</CardDescription>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card class="flex flex-row gap-3 p-1" variant="transparent">
|
||||
<img
|
||||
alt="牛油果"
|
||||
class="aspect-square h-16 w-16 shrink-0 rounded-xl object-cover select-none sm:h-20 sm:w-20"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/avocado.jpeg"
|
||||
/>
|
||||
<div class="flex flex-1 flex-col justify-center gap-1">
|
||||
<CardTitle class="text-sm">牛油果黑客松</CardTitle>
|
||||
<CardDescription class="text-xs">周三 16:30</CardDescription>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card class="flex flex-row gap-3 p-1" variant="transparent">
|
||||
<img
|
||||
alt="Sound Electro 活动"
|
||||
class="aspect-square h-16 w-16 shrink-0 rounded-xl object-cover select-none sm:h-20 sm:w-20"
|
||||
loading="lazy"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/oranges.jpeg"
|
||||
/>
|
||||
<div class="flex flex-1 flex-col justify-center gap-1">
|
||||
<CardTitle class="text-sm">Sound Electro|超越艺术</CardTitle>
|
||||
<CardDescription class="text-xs">周五 20:00</CardDescription>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Input aria-label="姓名" class="w-64" placeholder="输入你的姓名" />
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const value = ref("heroui.com");
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-80 flex-col gap-2">
|
||||
<Input v-model="value" aria-label="域名" placeholder="域名" />
|
||||
<span class="px-1 text-sm text-muted">
|
||||
https://{{ value || "你的域名" }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Input
|
||||
aria-label="搜索项目"
|
||||
class="w-64 rounded-xl border border-border/80 bg-default text-foreground placeholder:text-muted"
|
||||
placeholder="搜索项目…"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="w-[400px] space-y-3">
|
||||
<Input full-width aria-label="全宽输入框" placeholder="全宽输入框" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="flex h-[180px] w-[280px] items-center justify-center rounded-3xl bg-surface p-4"
|
||||
>
|
||||
<Input
|
||||
class="w-full"
|
||||
aria-label="你的姓名"
|
||||
placeholder="你的姓名"
|
||||
variant="secondary"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import { Input, Label } from "@heroui-vue/components";
|
||||
import { useId } from "vue";
|
||||
const id = useId();
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-80 flex-col gap-4">
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label :for="id + '-email'">邮箱</Label>
|
||||
<Input :id="id + '-email'" placeholder="jane@example.com" type="email" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label :for="id + '-number'">年龄</Label>
|
||||
<Input :id="id + '-number'" :min="0" placeholder="30" type="number" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label :for="id + '-password'">密码</Label>
|
||||
<Input :id="id + '-password'" placeholder="••••••••" type="password" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { Input } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex w-[240px] flex-col gap-2">
|
||||
<Input
|
||||
full-width
|
||||
aria-label="主要输入框"
|
||||
placeholder="主要输入框"
|
||||
variant="primary"
|
||||
/>
|
||||
<Input
|
||||
full-width
|
||||
aria-label="次要输入框"
|
||||
placeholder="次要输入框"
|
||||
variant="secondary"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch>
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const selected = ref(false);
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<Switch v-model:checked="selected">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<p class="text-sm text-muted">开关{{ selected ? "已打开" : "已关闭" }}</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
Label,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch>
|
||||
<SwitchContent>
|
||||
<SwitchControl
|
||||
class="[--switch-control-bg-checked-hover:var(--success)] [--switch-control-bg-checked:var(--success)]"
|
||||
>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<Label>自动保存草稿</Label>
|
||||
<Description>输入时会自动保存更改。</Description>
|
||||
</div>
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch default-selected>
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch is-disabled>
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
SwitchGroup,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
import { ref } from "vue";
|
||||
const result = ref("");
|
||||
function submit(event: Event) {
|
||||
const values = [...new FormData(event.target as HTMLFormElement).entries()];
|
||||
result.value = values.length
|
||||
? "表单提交内容:" + values.map(([k, v]) => `${k}: ${v}`).join(",")
|
||||
: "未选择任何选项";
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<form class="flex flex-col gap-4" @submit.prevent="submit">
|
||||
<SwitchGroup>
|
||||
<Switch name="notifications" value="on">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch default-selected name="newsletter" value="on">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
订阅新闻简报
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch name="marketing" value="on">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
接收营销更新
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</SwitchGroup>
|
||||
<div class="flex gap-2">
|
||||
<Button class="mt-4" size="sm" type="submit">Submit</Button>
|
||||
<Button
|
||||
class="mt-4"
|
||||
size="sm"
|
||||
type="reset"
|
||||
variant="secondary"
|
||||
@click="result = ''"
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</div>
|
||||
<output v-if="result" class="text-sm text-muted" aria-live="polite">
|
||||
{{ result }}
|
||||
</output>
|
||||
</form>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
SwitchGroup,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<SwitchGroup class="overflow-x-auto" orientation="horizontal">
|
||||
<Switch name="notifications">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch name="marketing">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
营销
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch name="social">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
社交
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</SwitchGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
SwitchGroup,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<SwitchGroup>
|
||||
<Switch name="notifications">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
允许通知
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch name="marketing">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
营销邮件
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch name="social">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
社交媒体更新
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</SwitchGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<Switch>
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
标签在后
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch>
|
||||
<SwitchContent>
|
||||
标签在前
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch as-child>
|
||||
<div data-custom="foo">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
启用通知
|
||||
</SwitchContent>
|
||||
</div>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch v-slot="{ isSelected }">
|
||||
<SwitchContent>
|
||||
<SwitchControl><SwitchThumb /></SwitchControl>
|
||||
{{ isSelected ? "已开启" : "已关闭" }}
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex gap-6">
|
||||
<Switch size="sm">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
小
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch size="md">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
中
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
<Switch size="lg">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
大
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
Description,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="max-w-sm">
|
||||
<Switch>
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
公开资料
|
||||
</SwitchContent>
|
||||
<Description>允许他人查看你的资料信息</Description>
|
||||
</Switch>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,79 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
SwitchIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconCheck,
|
||||
IconPower,
|
||||
IconSun,
|
||||
IconMoon,
|
||||
IconMicrophone,
|
||||
IconMicrophoneOff,
|
||||
IconBellFilled,
|
||||
IconBellOff,
|
||||
IconVolume,
|
||||
IconVolumeOff,
|
||||
} from "@tabler/icons-vue";
|
||||
const icons = [
|
||||
{
|
||||
key: "check",
|
||||
label: "电源",
|
||||
color: "bg-green-500/80",
|
||||
on: IconCheck,
|
||||
off: IconPower,
|
||||
},
|
||||
{ key: "darkMode", label: "深色模式", color: "", on: IconSun, off: IconMoon },
|
||||
{
|
||||
key: "microphone",
|
||||
label: "静音麦克风",
|
||||
color: "bg-red-500/80",
|
||||
on: IconMicrophoneOff,
|
||||
off: IconMicrophone,
|
||||
},
|
||||
{
|
||||
key: "notification",
|
||||
label: "通知",
|
||||
color: "bg-purple-500/80",
|
||||
on: IconBellFilled,
|
||||
off: IconBellOff,
|
||||
},
|
||||
{
|
||||
key: "volume",
|
||||
label: "静音音量",
|
||||
color: "bg-blue-500/80",
|
||||
on: IconVolumeOff,
|
||||
off: IconVolume,
|
||||
},
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<Switch
|
||||
v-for="item in icons"
|
||||
:key="item.key"
|
||||
default-selected
|
||||
size="lg"
|
||||
:aria-label="item.label"
|
||||
v-slot="{ isSelected }"
|
||||
>
|
||||
<SwitchContent>
|
||||
<SwitchControl :class="isSelected ? item.color : ''">
|
||||
<SwitchThumb>
|
||||
<SwitchIcon>
|
||||
<component
|
||||
:is="isSelected ? item.on : item.off"
|
||||
class="size-3 text-inherit"
|
||||
:class="isSelected ? 'opacity-100' : 'opacity-70'"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</SwitchIcon>
|
||||
</SwitchThumb>
|
||||
</SwitchControl>
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Switch,
|
||||
SwitchContent,
|
||||
SwitchControl,
|
||||
SwitchThumb,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Switch aria-label="启用通知">
|
||||
<SwitchContent>
|
||||
<SwitchControl>
|
||||
<SwitchThumb />
|
||||
</SwitchControl>
|
||||
</SwitchContent>
|
||||
</Switch>
|
||||
</template>
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
title: 安装
|
||||
description: 在 Vue 项目中开始使用 HeroUI Vue
|
||||
---
|
||||
|
||||
## 本地开发
|
||||
|
||||
包尚未发布,目前通过独立工作区开发和使用。
|
||||
|
||||
```sh
|
||||
pnpm install
|
||||
pnpm build
|
||||
pnpm dev:docs
|
||||
```
|
||||
|
||||
## 使用组件
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import "@heroui-vue/styles/css";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button>点我</Button>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 图标
|
||||
|
||||
文档示例统一使用 [Tabler Icons 官方 Vue 包](https://github.com/tabler/tabler-icons/tree/main/packages/icons-vue),按需导入,不需要在线请求图标。
|
||||
|
||||
```sh
|
||||
pnpm add @tabler/icons-vue
|
||||
```
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { IconSearch } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button>
|
||||
<IconSearch aria-hidden="true" />
|
||||
搜索
|
||||
</Button>
|
||||
</template>
|
||||
```
|
||||
|
||||
纯图标按钮必须提供 `aria-label`。图标库是演示应用依赖,组件库通过插槽接受任意图标,不强制消费者安装 Tabler。
|
||||
|
||||
## 样式入口
|
||||
|
||||
样式包使用 Tailwind CSS 4 编译基线 CSS,向消费者提供预编译 CSS。消费者不需要安装 Tailwind;自定义工具类需要在自己的应用中配置 Tailwind。
|
||||
|
||||
## 开发命令
|
||||
|
||||
| 命令 | 功能 |
|
||||
| -------------- | --------------- |
|
||||
| pnpm dev | 组件实验页 |
|
||||
| pnpm dev:docs | 组件文档 |
|
||||
| pnpm build | 库与样式构建 |
|
||||
| pnpm typecheck | Vue 类型检查 |
|
||||
| pnpm test | 行为与 SSR 测试 |
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
title: Button 按钮
|
||||
description: 可点击的按钮组件,支持多种变体与状态
|
||||
component: button
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="button-basic" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
<ComponentPreview name="button-variants" />
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="button-sizes" />
|
||||
|
||||
### 带图标
|
||||
|
||||
<ComponentPreview name="button-with-icons" />
|
||||
|
||||
### 仅图标
|
||||
|
||||
<ComponentPreview name="button-icon-only" />
|
||||
|
||||
### 加载中
|
||||
|
||||
此例固定展示上传中的外观;加载期间阻止重复提交,但保留键盘焦点。要体验开始、完成和再次上传,请使用下一例。
|
||||
|
||||
<ComponentPreview name="button-loading" />
|
||||
|
||||
### 加载中(点击触发)
|
||||
|
||||
点击“上传文件”后进入加载状态,2 秒后恢复,可重复操作。
|
||||
|
||||
<ComponentPreview name="button-loading-state" />
|
||||
|
||||
### 宽度充满
|
||||
|
||||
<ComponentPreview name="button-full-width" />
|
||||
|
||||
### 禁用状态
|
||||
|
||||
<ComponentPreview name="button-disabled" />
|
||||
|
||||
### 社交媒体按钮
|
||||
|
||||
<ComponentPreview name="button-social" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 使用 `asChild` 将按钮属性与交互合并到一个自定义原生 button,作用域插槽提供状态。对应上游 render 函数示例,不将 render prop 原样搬入 Vue。
|
||||
|
||||
<ComponentPreview name="button-render-function" />
|
||||
|
||||
### 添加自定义变体
|
||||
|
||||
可通过包装组件并添加自定义变体来扩展组件。下面使用与上游相同的 `tv` 扩展方式,提供额外的圆角与尺寸配置。
|
||||
|
||||
<ComponentPreview name="button-custom-variants" />
|
||||
|
||||
### 添加涟漪效果
|
||||
|
||||
通过组合添加涟漪。本示例使用 Vue 和 CSS 实现,支持指针、Enter 和空格触发;不直接依赖上游 React 的 m3-ripple,减少动态效果时缩短动画。
|
||||
|
||||
<ComponentPreview name="button-ripple-effect" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="button-custom-styles" />
|
||||
|
||||
使用标准 `class` 属性添加工具类。组件保持上游的尺寸、间距、BEM 结构与状态钩子;类名前缀改为 `hv-`。
|
||||
|
||||
```vue
|
||||
<Button class="rounded-lg">自定义圆角</Button>
|
||||
```
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-button--primary {
|
||||
--button-bg: oklch(0.6 0.2 300);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
基础类为 `.hv-button`,变体为 `.hv-button--primary` 等;尺寸为 `.hv-button--sm` / `md` / `lg`。支持 `.hv-button--icon-only` 和 `.hv-button--full-width`。
|
||||
|
||||
### 交互状态
|
||||
|
||||
保留 `data-hovered`、`data-pressed`、`data-focused`、`data-focus-visible`、`data-pending` 状态;键盘焦点样式与鼠标焦点区分。加载期间保留焦点并阻止重复点击,通过 aria-disabled 呈现半透明的原变体颜色。
|
||||
|
||||
## API 参考
|
||||
|
||||
### Button
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | --------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------- |
|
||||
| `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'outline' \| 'ghost' \| 'danger' \| 'danger-soft'` | `'primary'` | 视觉样式变体 |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 按钮尺寸 |
|
||||
| `fullWidth` | `boolean` | `false` | 是否占满容器宽度 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 |
|
||||
| `isPending` | `boolean` | `false` | 是否处于加载状态 |
|
||||
| `isIconOnly` | `boolean` | `false` | 是否仅包含图标 |
|
||||
| `asChild` | `boolean` | `false` | 将属性与交互合并到默认插槽中唯一的原生 button |
|
||||
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | 原生按钮类型 |
|
||||
|
||||
### 事件与插槽
|
||||
|
||||
Vue 使用 `@click` 和默认作用域插槽。插槽提供 `isPending`、`isPressed`、`isHovered`、`isFocused`、`isFocusVisible`、`isDisabled`。原生属性、class、style、事件透传至 button。
|
||||
|
||||
`onPress` / PressEvent 与 `@click` 的事件模型不同,不宣称完全等价。初版 `disabled` / `loading` 继续作为兼容别名;新代码使用 `isDisabled` / `isPending`。`isPending` 不自动插入加载图标,采用上游的组合方式。`loading` 是相同加载语义的兼容别名,额外自动显示旋转图标;不会设置原生 disabled。`asChild` 下内容由调用者完整组合,默认插槽必须只包含一个原生 button。
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 描述 |
|
||||
| ---------------- | --------- | -------------------------------- |
|
||||
| `isPending` | `boolean` | 是否处于加载状态 |
|
||||
| `isPressed` | `boolean` | 是否正在按下 |
|
||||
| `isHovered` | `boolean` | 是否悬停 |
|
||||
| `isFocused` | `boolean` | 是否聚焦 |
|
||||
| `isFocusVisible` | `boolean` | 是否显示键盘焦点指示器 |
|
||||
| `isDisabled` | `boolean` | 是否由禁用属性禁用,不与加载混用 |
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Card 卡片](/components/card) · [Input 输入框](/components/input) · [Switch 开关](/components/switch)
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: 介绍
|
||||
description: 美观、现代的 Vue UI 组件库
|
||||
---
|
||||
|
||||
## 设计原则
|
||||
|
||||
以固定提交的 HeroUI v3.2.6 为设计基线,保持组件的样式、布局、文案、变体、参数语义和主题高度一致。仅在框架机制要求时转换事件、插槽、响应式状态与部件导出方式。
|
||||
|
||||
## 当前范围
|
||||
|
||||
已迁移 Button、Card、Input、Switch 的主要视觉和组合结构,仍需完整视觉与交互验收。左侧导航只列出实际存在的组件,未迁移的组件不以占位演示代替。
|
||||
|
||||
## Vue 差异
|
||||
|
||||
- `className` → `class`。
|
||||
- 函数 children → 作用域插槽。
|
||||
- `Card.Header` → `CardHeader` 等独立导出。
|
||||
- Input 使用 `v-model`;Switch 使用 `v-model:checked`,保留 isSelected 等上游语义属性。
|
||||
- 框架专属的 PressEvent 与原生 click 不声明等价。
|
||||
|
||||
具体未覆盖能力在各组件 API 页说明。此项目为独立社区实现,不是官方 Vue 发行版。
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@heroui-vue/docs",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vitepress dev",
|
||||
"build": "vitepress build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.0",
|
||||
"tailwindcss": "^4.1.0",
|
||||
"vitepress": "^1.6.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@heroui-vue/components": "workspace:*",
|
||||
"@heroui-vue/styles": "workspace:*",
|
||||
"@tabler/icons-vue": "^3.49.0",
|
||||
"reka-ui": "^2.11.0",
|
||||
"vue": "^3.5.44"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: 主题
|
||||
description: 使用与 HeroUI 相同的语义变量定制组件外观
|
||||
---
|
||||
|
||||
## 默认主题
|
||||
|
||||
浅色和深色变量移植自固定基线的 default/variables.css,采用相同的 OKLCH 颜色与派生公式。按钮、表面、输入框和开关共同使用这些变量。
|
||||
|
||||
## 浅色与深色
|
||||
|
||||
文档右上角切换主题,页面与组件同步更新。应用支持 `.light`、`.dark`、`data-theme="light"` 与 `data-theme="dark"`。
|
||||
|
||||
```html
|
||||
<html class="dark"></html>
|
||||
```
|
||||
|
||||
## 语义颜色
|
||||
|
||||
| 变量 | 用途 |
|
||||
| ------------------------------------------------------------- | ------------------ |
|
||||
| --background / --foreground | 页面背景与正文 |
|
||||
| --surface / --surface-secondary / --surface-tertiary | 分层表面 |
|
||||
| --accent / --accent-foreground | 主要操作与选中状态 |
|
||||
| --default / --default-foreground | 默认控件背景与文字 |
|
||||
| --muted | 次要文本 |
|
||||
| --danger / --danger-foreground | 危险操作与无效状态 |
|
||||
| --field-background / --field-foreground / --field-placeholder | 表单输入 |
|
||||
| --border / --separator / --focus | 边界、分隔和焦点 |
|
||||
|
||||
## 自定义主题
|
||||
|
||||
```css
|
||||
[data-theme="brand"] {
|
||||
--accent: oklch(0.62 0.2 300);
|
||||
--accent-foreground: oklch(0.99 0 0);
|
||||
--radius: 0.75rem;
|
||||
}
|
||||
```
|
||||
|
||||
```html
|
||||
<section class="light" data-theme="brand">...</section>
|
||||
```
|
||||
|
||||
将上述样式放在库样式之后,覆盖容器变量。嵌套容器加上 light 或 dark,使派生颜色在该容器重新计算。浅深自定义主题应分别声明值;应用继承基线的派生颜色与阴影公式。
|
||||
|
||||
## 圆角与阴影
|
||||
|
||||
默认 `--radius: 0.5rem`,`--field-radius: calc(var(--radius) * 1.5)`。Card 使用 `min(32px, var(--radius-3xl))`,Button 使用 3xl 圆角。不要为不同页面独立设置近似圆角或品牌蓝。
|
||||
|
||||
## 动效
|
||||
|
||||
支持 prefers-reduced-motion 和 data-reduce-motion 状态。保留基线的 hover、press、focus 与过渡时间。
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>HeroUI Vue · 组件实验室</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@heroui-vue/playground",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --host 127.0.0.1",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@heroui-vue/components": "workspace:*",
|
||||
"@heroui-vue/styles": "workspace:*",
|
||||
"vue": "^3.5.44"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.0",
|
||||
"tailwindcss": "^4.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { Button, Card, Input, Switch } from "@heroui-vue/components";
|
||||
const dark = ref(false),
|
||||
notifications = ref(true),
|
||||
name = ref("设计团队"),
|
||||
saved = ref(false),
|
||||
count = ref(0);
|
||||
function save() {
|
||||
saved.value = true;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="lab" :data-theme="dark ? 'dark' : 'light'">
|
||||
<header>
|
||||
<a class="wordmark" href="#">
|
||||
hero
|
||||
<span>ui</span>
|
||||
<small>Vue</small>
|
||||
</a>
|
||||
<nav>
|
||||
<a href="#components">组件预览</a>
|
||||
<a href="#start">开始使用</a>
|
||||
</nav>
|
||||
<label class="theme">
|
||||
深色模式
|
||||
<Switch v-model:checked="dark" aria-label="深色模式" />
|
||||
</label>
|
||||
</header>
|
||||
<main>
|
||||
<section class="intro">
|
||||
<p class="release">Vue 3 组件库 · 开发预览</p>
|
||||
<h1>
|
||||
熟悉的设计,
|
||||
<br />
|
||||
自然的 Vue 体验。
|
||||
</h1>
|
||||
<p class="lead">
|
||||
从一颗按钮开始,让每一个细节都有章可循。
|
||||
<br />
|
||||
在这里试试第一批组件。
|
||||
</p>
|
||||
<a class="text-link" href="#components">探索组件 ↓</a>
|
||||
</section>
|
||||
<section id="components" class="workbench">
|
||||
<div class="section-title">
|
||||
<h2>组件实验室</h2>
|
||||
<span>4 个组件 · 起步阶段</span>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<Card class="button-demo">
|
||||
<div class="demo-title">
|
||||
<h3>Button</h3>
|
||||
<span>动作与反馈</span>
|
||||
</div>
|
||||
<div class="samples">
|
||||
<Button @click="count++">
|
||||
点击试试
|
||||
<span aria-live="polite">{{ count }}</span>
|
||||
</Button>
|
||||
<Button variant="secondary">次要操作</Button>
|
||||
<Button variant="outline">描边按钮</Button>
|
||||
<Button variant="ghost">轻量操作</Button>
|
||||
<Button variant="danger">危险操作</Button>
|
||||
<Button disabled>不可用</Button>
|
||||
</div>
|
||||
<p class="caption">圆角、尺寸、状态,保持一致的触感。</p>
|
||||
</Card>
|
||||
<Card>
|
||||
<div class="demo-title">
|
||||
<h3>工作区设置</h3>
|
||||
<span>Input + Switch</span>
|
||||
</div>
|
||||
<form @submit.prevent="save">
|
||||
<label class="field">
|
||||
工作区名称
|
||||
<Input
|
||||
v-model="name"
|
||||
name="workspace"
|
||||
required
|
||||
@input="saved = false"
|
||||
/>
|
||||
</label>
|
||||
<div class="setting">
|
||||
<div>
|
||||
<label for="notifications">活动通知</label>
|
||||
<p>接收工作区的重要更新</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="notifications"
|
||||
v-model:checked="notifications"
|
||||
name="notifications"
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" full-width>保存设置</Button>
|
||||
<p class="feedback" role="status">
|
||||
{{
|
||||
saved
|
||||
? `已保存「${name}」的设置`
|
||||
: "修改后点击保存,试试双向绑定。"
|
||||
}}
|
||||
</p>
|
||||
</form>
|
||||
</Card>
|
||||
<Card variant="secondary" class="card-demo">
|
||||
<div class="demo-title">
|
||||
<h3>Card</h3>
|
||||
<span>内容的容器</span>
|
||||
</div>
|
||||
<div class="swatches">
|
||||
<i />
|
||||
<i />
|
||||
<i />
|
||||
<i />
|
||||
</div>
|
||||
<h4>
|
||||
为你的下一次创作
|
||||
<br />
|
||||
留一块画布。
|
||||
</h4>
|
||||
<p>主题变量与组件样式独立维护,让定制从容一点。</p>
|
||||
<Button variant="outline" @click="dark = !dark">切换主题</Button>
|
||||
</Card>
|
||||
</div>
|
||||
</section>
|
||||
<section id="start" class="start">
|
||||
<div>
|
||||
<h2>从这里开始</h2>
|
||||
<p>本地开发预览,组件仍在持续完善。</p>
|
||||
</div>
|
||||
<code>
|
||||
pnpm install
|
||||
<br />
|
||||
pnpm dev
|
||||
</code>
|
||||
</section>
|
||||
<footer>
|
||||
<span>HeroUI Vue · 独立社区实现</span>
|
||||
<span>以 HeroUI v3 为设计参考</span>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createApp } from "vue";
|
||||
import App from "./App.vue";
|
||||
import "./style.css";
|
||||
createApp(App).mount("#app");
|
||||
@@ -0,0 +1,295 @@
|
||||
@import "tailwindcss";
|
||||
@import "../../../packages/styles/dist/styles.css";
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: "Avenir Next", "Segoe UI", "PingFang SC", sans-serif;
|
||||
}
|
||||
button,
|
||||
input {
|
||||
font: inherit;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
.lab {
|
||||
min-height: 100vh;
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
transition:
|
||||
background 0.2s,
|
||||
color 0.2s;
|
||||
}
|
||||
header {
|
||||
max-width: 1240px;
|
||||
margin: auto;
|
||||
padding: 28px 48px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 24px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.wordmark {
|
||||
font-weight: 800;
|
||||
font-size: 26px;
|
||||
letter-spacing: -1.4px;
|
||||
}
|
||||
.wordmark span {
|
||||
color: var(--accent);
|
||||
}
|
||||
.wordmark small {
|
||||
font-size: 12px;
|
||||
letter-spacing: 0;
|
||||
font-weight: 600;
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
background: var(--default);
|
||||
margin-left: 8px;
|
||||
}
|
||||
nav {
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.theme {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
main {
|
||||
max-width: 1240px;
|
||||
margin: auto;
|
||||
padding: 0 48px;
|
||||
}
|
||||
.intro {
|
||||
padding: 70px 0 64px;
|
||||
}
|
||||
.release {
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
margin: 0 0 22px;
|
||||
}
|
||||
h1 {
|
||||
font-size: clamp(40px, 5.4vw, 68px);
|
||||
font-weight: 650;
|
||||
line-height: 1.18;
|
||||
letter-spacing: -2.5px;
|
||||
margin: 0 0 22px;
|
||||
}
|
||||
.lead {
|
||||
font-size: 17px;
|
||||
line-height: 1.9;
|
||||
color: var(--muted);
|
||||
}
|
||||
.text-link {
|
||||
display: inline-block;
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.section-title h2,
|
||||
.start h2 {
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.6px;
|
||||
}
|
||||
.section-title span,
|
||||
.demo-title span {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1fr 0.9fr;
|
||||
gap: 18px;
|
||||
}
|
||||
.demo-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
.demo-title h3 {
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
margin: 0;
|
||||
}
|
||||
.samples {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.caption {
|
||||
font-size: 12px;
|
||||
line-height: 1.8;
|
||||
color: var(--muted);
|
||||
margin: 30px 0 0;
|
||||
}
|
||||
.field {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.setting {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin: 24px 0;
|
||||
}
|
||||
.setting label {
|
||||
font-size: 14px;
|
||||
}
|
||||
.setting p {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
.feedback {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
min-height: 32px;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.swatches {
|
||||
display: flex;
|
||||
margin: 8px 0 26px;
|
||||
}
|
||||
.swatches i {
|
||||
display: block;
|
||||
width: 45px;
|
||||
height: 45px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid var(--default);
|
||||
margin-right: -9px;
|
||||
background: #006fee;
|
||||
}
|
||||
.swatches i:nth-child(2) {
|
||||
background: #86b8ff;
|
||||
}
|
||||
.swatches i:nth-child(3) {
|
||||
background: #bba7f7;
|
||||
}
|
||||
.swatches i:nth-child(4) {
|
||||
background: #f4b0c7;
|
||||
}
|
||||
.card-demo h4 {
|
||||
font-size: 24px;
|
||||
line-height: 1.4;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.7px;
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
.card-demo p {
|
||||
font-size: 13px;
|
||||
line-height: 1.8;
|
||||
color: var(--muted);
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.start {
|
||||
margin-top: 56px;
|
||||
padding: 30px 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-top: 1px solid var(--border);
|
||||
gap: 24px;
|
||||
}
|
||||
.start h2 {
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
.start p {
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.start code {
|
||||
min-width: 280px;
|
||||
background: var(--default);
|
||||
border-radius: 12px;
|
||||
padding: 20px 26px;
|
||||
font-size: 13px;
|
||||
line-height: 2;
|
||||
}
|
||||
footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
padding: 24px 0 30px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
@media (max-width: 1000px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.card-demo {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.card-demo h4 br {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
header {
|
||||
padding: 20px 22px;
|
||||
}
|
||||
nav {
|
||||
display: none;
|
||||
}
|
||||
.theme {
|
||||
font-size: 12px;
|
||||
}
|
||||
main {
|
||||
padding: 0 22px;
|
||||
}
|
||||
.intro {
|
||||
padding: 50px 0;
|
||||
}
|
||||
h1 {
|
||||
letter-spacing: -1.5px;
|
||||
}
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.section-title span {
|
||||
font-size: 11px;
|
||||
}
|
||||
.start {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
.start code {
|
||||
min-width: 0;
|
||||
}
|
||||
footer {
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
.lab {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
export default defineConfig({
|
||||
plugins: [vue(), tailwindcss()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@heroui-vue/components": fileURLToPath(
|
||||
new URL("../../packages/vue/src/index.ts", import.meta.url),
|
||||
),
|
||||
"@heroui-vue/styles": fileURLToPath(
|
||||
new URL("../../packages/styles/src/index.ts", import.meta.url),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 52 KiB |
@@ -0,0 +1,119 @@
|
||||
# 兼容矩阵
|
||||
|
||||
基于固定上游提交的公共组件导出清单。验证中不等于完整兼容;目前没有组件完成视觉、浏览器与完整行为验收。
|
||||
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | ------------------ | ------------------------------------------------------------------------------------------------ |
|
||||
| accordion | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| badge | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| breadcrumbs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| checkbox-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| chip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-area | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 样式已移植 | Card 演示使用原生 button + closeButtonVariants + Tabler IconX;Vue CloseButton 组件尚未实现 |
|
||||
| combo-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| drawer | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| progress-bar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| progress-circle | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| time-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| disclosure | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| disclosure-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| error-message | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| kbd | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| link | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| popover | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| scroll-shadow | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| separator | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| skeleton | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| spinner | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| surface | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toast | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toggle-button | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toggle-button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toolbar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tooltip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| input | 验证中(最小实现) | primary/secondary、fullWidth、原生属性、v-model/defaultValue、表单 reset;TextField 上下文未实现 |
|
||||
| input-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| textarea | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| textfield | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| search-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| typography | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| label | 验证中(原生标签) | for 关联、required/disabled/invalid;Switch 内采用 span 避免嵌套交互 |
|
||||
| description | 验证中(描述关联) | 唯一 ID、多个描述、Switch aria-describedby 关联 |
|
||||
| empty-state | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| field-error | 验证中(Switch) | 错误消息、ARIA 关联;完整 TextField 上下文未实现 |
|
||||
| fieldset | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| form | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| header | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| radio | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| radio-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| input-otp | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| alert | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| dropdown | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| modal | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| number-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| pagination | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| select | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| meter | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| table | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| range-calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| calendar-year-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
|
||||
## 公共导出差异
|
||||
|
||||
React Aria 专属 rac 导出与 React 图标类型不移植;Vue 版 ConfigProvider、图标方案与路由适配待实现。复杂组件实施前扩展对应条目,记录子部件、变体、属性、事件、键盘、依赖、测试和验收结果。
|
||||
|
||||
## 文档与视觉基线
|
||||
|
||||
默认入口改为组件文档。Button、Card、Input、Switch 具有独立页面、43 个共享源码的可运行示例、API 参考与主题文档。页面标题、说明和基础示例文案来自固定基线中文文档;Vue 事件、插槽和导出差异单独说明。
|
||||
|
||||
基线 CSS 与主题变量已移植并保留来源声明。文档布局按基线三栏结构重建;商业横幅、AI 助手、官方版本切换、主题生成器和完整组件导航尚未复刻。未完成原 React 站运行时截图与 Vue 站的自动逐像素对比。
|
||||
|
||||
## 已实现组件的文档清单复核
|
||||
|
||||
Button 14 / 14,Card 7 / 7,Input 7 / 7,Switch 15 / 15,基线预览名称与顺序均已对齐。没有用空壳补足数量;预览与复制代码共用 SFC。
|
||||
|
||||
Card 图片、头像、横向布局、表单与自定义样式已补齐;Input 的标签、类型、宽度与自定义样式已对齐。Switch 补齐图标、位置、分组、表单、状态插槽与自定义根容器。
|
||||
|
||||
框架适配差异:Avatar 使用 Reka 组合,表单与链接采用原生 HTML;图标使用 Tabler 官方 Vue 组件;演示不提供认证、支付等业务服务。完整 React Aria 事件模型、全库字段上下文及自动视觉回归仍不在本批完成范围。
|
||||
|
||||
## 文档体验范围
|
||||
|
||||
已实现正文/参数搜索、键盘选择与章节跳转、构建时示例代码高亮、复制反馈、相邻页面导航、滚动目录指示,以及窄屏可访问目录抽屉。文档与预览样式隔离,手机宽度保留搜索入口。完整原站全文检索、自动视觉基线和真实设备回归仍未建立。
|
||||
|
||||
## Button 示例完整性复核
|
||||
|
||||
与固定基线中文 Button 页面逐项核对:14 个预览均存在,顺序一致,缺失项为 0。补齐社交按钮、自定义变体、涟漪、自定义样式,并恢复图标、仅图标、全宽、禁用示例的组合内容。
|
||||
|
||||
修复 loading 别名误设原生 disabled 的问题:它与 isPending 都保留焦点并拦截重复激活;isDisabled/disabled 才设置原生禁用。固定加载示例只展示上传中的外观,动态上传示例 2 秒后恢复且可再次触发。asChild 将交互合并到自定义原生 button;涟漪采用 Vue/CSS 实现,图标采用 Tabler 官方 Vue 组件,这些框架适配差异已在文档说明。
|
||||
|
||||
未宣称 Button 的所有 React Aria 行为已完全复刻;PressEvent、路由链接等框架专属能力仍不等价。
|
||||
@@ -0,0 +1,9 @@
|
||||
# 起步架构
|
||||
|
||||
采用 pnpm workspace、Vite 库模式、Vue 3.5+、TypeScript、Reka UI。组件与样式独立打包,依赖通过工作区包连接。演示使用源码别名以便热更新;文档消费 dist 导出,以暴露打包问题。
|
||||
|
||||
基础样式是带 hv- 前缀的原生 CSS,演示应用接入 Tailwind 4。此阶段不需要把简单 CSS 转换为 @apply,且消费者无需 Tailwind 即可使用初始组件。tailwind-variants 管理 Button 外观映射。
|
||||
|
||||
Button/Card/Input 使用原生元素;Switch 使用 Reka UI。原生 Input 的 controlled/uncontrolled 与 form reset 独立处理。复杂交互后续再补,不创建占位组件冒充完成。
|
||||
|
||||
暂未建立浏览器、视觉、Nuxt 水合和打包后独立安装验收;首轮验证仅涵盖单元行为、Node SSR、类型和构建。
|
||||
@@ -0,0 +1,11 @@
|
||||
# 高一致性复刻
|
||||
|
||||
按用户 2026-10-20 的要求,早期近似配色与默认文档主题被替换。
|
||||
|
||||
采用固定基线 CSS、语义变量和变体映射,Tailwind 4 仅用于构建样式产物,消费者仍导入预编译 CSS。BEM 类名加 hv- 前缀,data-slot 保持部件语义。
|
||||
|
||||
文档使用自定义 VitePress Theme:顶部导航、左侧组件导航、正文、右侧目录、350px 示例区、代码区和参数表。内容沿用基线中文组件说明;默认入口变更为文档站。示例渲染和复制源码来自同一 SFC 文件,避免双份维护造成偏差。
|
||||
|
||||
Button 保留 isDisabled/isPending/isIconOnly;Switch 保留 isSelected/defaultSelected 等语义并支持 Vue v-model:checked。保留旧别名以兼容起步代码。Card 补齐全部结构部件,Input 补齐两个视觉变体。框架必需差异与尚未完成能力在组件文档和兼容矩阵列出。
|
||||
|
||||
尚未完成原 React 文档站的真实截图基线与自动像素差异测试,不能声称逐像素一致。没有迁移的组件仍按计划推进,不生成占位页。
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,162 @@
|
||||
# Vue 迁移任务拆分与复核约定
|
||||
|
||||
更新日期:2026-10-21。用于把有限范围的任务交给其他 AI,再由集成人复核。本文是任务计划,不代表已执行、已派发或已通过验收;实际状态以 [兼容矩阵](./compatibility.md) 为准。
|
||||
|
||||
## 共同基线
|
||||
|
||||
- 开始前读取项目根目录 [AGENTS.md](../AGENTS.md)、[上游记录](./upstream.md)、兼容矩阵及目标组件的局部指导。
|
||||
- 上游固定为 HeroUI 3.2.6、`ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`。不能不说明就切换为官网最新设计。
|
||||
- React 参考仓库是 `../heroui/`;实现只能落在本 Vue 项目。新项目必须独立构建,不能运行 React 包装 Vue,也不能依赖相邻参考目录。
|
||||
- 本项目目前是 private 工作区,包名为 `@heroui-vue/components`、`@heroui-vue/styles`,不是官方 scope。Vue peer 范围为 `^3.5.0`;具体依赖以清单与锁文件为准。
|
||||
- 样式、布局、文案、变体、状态与公开能力对齐固定基线;框架机制改成 Vue 的模型、事件、具名导出及插槽。任何删减或差异都须记录。
|
||||
|
||||
## 当前起点
|
||||
|
||||
| 范围 | 当前事实 | 不应作出的推断 |
|
||||
| ---------------------------------------------- | ---------------------------------------------------------------- | -------------------------------------------------- |
|
||||
| Button / Card / Input / Switch | 已有实现和文档,基线演示分别为 14 / 7 / 7 / 15 个 | 不代表 React Aria 的全部行为已兼容 |
|
||||
| SwitchGroup / Label / Description / FieldError | 已有部分组合能力;FieldError 当前仅接入 Switch | 不代表完整字段、表单与分组体系已完成 |
|
||||
| CloseButton | CSS 与 closeButtonVariants 已移植,Card 演示使用原生 button 组合 | Vue CloseButton 组件尚未实现 |
|
||||
| 主题与图标 | 已有默认浅深主题;演示与文档采用 Tabler 官方 Vue 图标 | 不能自行换品牌配色或自绘 SVG |
|
||||
| 验证 | 当前有 34 项测试、SSR 冒烟及部分手动浏览器记录 | 尚无完整自动浏览器、视觉、独立安装和 Nuxt 水合验收 |
|
||||
|
||||
这些数字是本次快照。接手时先检查代码和兼容矩阵,不用旧数字作为验收目标。
|
||||
|
||||
## 实施顺序与任务包
|
||||
|
||||
下表是批次,**不是让一个 AI 一次做完整个批次**。展示组件通常每次 1–3 个;表单或集合组件每次一个组件家族;复杂组件先做一个具体能力验证,再决定实现边界。
|
||||
|
||||
| 批次 | 建议拆分范围 | 前置依赖 / 关键交付 | 建议负责人 |
|
||||
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------ |
|
||||
| 0:现有实现复核 | Button、Card、Input、Switch 的差异与回归 | 检查已有缺陷,不以当前页面直接充当视觉标准 | 集成人 |
|
||||
| 1:展示与依赖补齐 | Surface;Link;Spinner;CloseButton;Avatar/AvatarGroup;Skeleton;Typography/Kbd;Badge/Chip/Alert;Separator/Header/Breadcrumbs/EmptyState | 各自独立组件、样式、全部基线演示;先核对现有源码再复用 | 可交给其他 AI,按小包分开 |
|
||||
| 2:共享字段与表单 | TextField/Label/Description/FieldError/ErrorMessage;InputGroup/Textarea/SearchField;Fieldset/Form | 先定字段上下文、ID、错误与校验协议,再接具体控件;验证已有 Input/Switch 不回归 | 共享协议由单一负责人维护 |
|
||||
| 3:选择与切换 | Checkbox/CheckboxGroup;Radio/RadioGroup;ToggleButton/ToggleButtonGroup;ButtonGroup;Switch 差异收敛 | 受控/非受控、组值、禁用继承、required、提交/reset、键盘 | 协议稳定后可按家族分配 |
|
||||
| 4:展开与导航 | Accordion;Disclosure/DisclosureGroup;Tabs;Toolbar | 方向键、激活模式、多项展开、焦点与状态标记 | 可按家族分配 |
|
||||
| 5:弹层与菜单 | Modal/AlertDialog;Popover/Tooltip;Dropdown/Menu/MenuItem/MenuSection;Drawer | 先统一焦点、嵌套、外部点击、滚动锁、定位及退出动画边界 | 弹层基础设施集中维护 |
|
||||
| 6:集合与输入选择 | ListBox/Item/Section;Select;ComboBox/Autocomplete;Tag/TagGroup | 集合值、过滤、多选、清空、异步变化、IME 与空状态;不假设 Reka 同名组件自动覆盖全部能力 | 按依赖顺序交付单个家族 |
|
||||
| 7:数值、范围与反馈 | NumberField;Slider;ProgressBar/ProgressCircle/Meter;Pagination;ScrollShadow | 精度、本地化、未知进度、拖动/滚动与真实布局 | 可分小包,布局相关用浏览器验收 |
|
||||
| 8:日期与时间 | Calendar/RangeCalendar/CalendarYearPicker;DateField/TimeField;DatePicker/DateRangePicker | @internationalized/date,分段输入、范围、locale、时区、SSR | 能力验证后逐项实现 |
|
||||
| 9:颜色 | ColorSwatch/ColorSwatchPicker;ColorField/ColorSlider/ColorArea;ColorPicker | 先定公共颜色模型及格式转换,再做多个部件的同步 | 颜色状态模型由单一负责人维护 |
|
||||
| 10:独立复杂家族 | InputOTP;Toast;Table | OTP 粘贴/删除;Toast 队列/暂停/公告;Table 排序/选择/语义与键盘 | 一次一个家族 |
|
||||
| 11:集成与发布准备 | 配置/方向/locale、SSR/Nuxt、独立安装、按需使用、主题入口、文档与包产物 | 与实际完成的组件矩阵对应;补建缺失的检查工具 | 集成人 |
|
||||
|
||||
高风险验证不等到最后:在批次 1 开始时即可分别验证 Modal、Select、DatePicker、ColorPicker、Drawer、InputOTP 的底座缺口。验证任务必须交付可运行场景、失败用例和采用/补充/延后的结论,不能只交选型说明或空壳导出。
|
||||
|
||||
具体的下一项任务须从上游公共导出再次核对。上表用于安排依赖,不替代完整组件清单;ConfigProvider、路由适配等框架能力另外记录公共契约。
|
||||
|
||||
## 第一轮适合直接交出的任务
|
||||
|
||||
| 任务 ID | 范围 | 特别验收点 |
|
||||
| ------- | -------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| M01 | Surface | 全部表面变体及嵌套层级;替换 Input 文档里现有原生表面适配后,不改变主题效果 |
|
||||
| M02 | Link | 外部链接、图标、焦点与禁用语义;Vue Router 集成不强塞进基础包;替换 Card 演示中的原生链接适配 |
|
||||
| M03 | Spinner | 尺寸、颜色、currentColor、减少动画与读屏语义;嵌入 Button 时保持 16px,不被普通 SVG 规则覆盖 |
|
||||
| M04 | CloseButton | 复用已有专用 CSS/变体,不用 ghost Button 代替;默认 Tabler 图标的依赖边界先与集成人约定;替换 Card 的原生关闭按钮适配 |
|
||||
| M05 | Avatar / AvatarGroup | 图像加载、失败 fallback、可访问名称、尺寸与分组重叠;替换 Card 内现有 Reka 组合,不破坏图片卡片 |
|
||||
| M06 | Skeleton | 所有基线变体、浅深主题及 reduced-motion;演示数量和组合内容均核对 |
|
||||
|
||||
建议先任选 2–3 个小包试运行交付与复核流程,再扩大分配。M04 不应为了方便默认图标,就私自给组件包增加整套图标依赖或自绘 SVG;允许先提出“调用方插槽 / 可选图标入口”等具体方案,由集成人统一落地。
|
||||
|
||||
## 多 AI 协作边界
|
||||
|
||||
- 每项任务写明所属文件、前置依赖、基线及验收范围。优先使用独立分支或隔离 checkout;不要让多个 AI 同时在同一 checkout 改同一组文件。
|
||||
- 不把整个仓库的“修复所有问题”作为单个任务,也不让一个任务顺手重写现有组件、主题、文档布局或构建链路。
|
||||
- `packages/vue/src/index.ts`、`types.ts`、样式入口/变体入口、文档导航、package.json、锁文件、共享字段/弹层协议、兼容矩阵是易冲突区域。分支内可提出必要改动,合并时由集成人逐项整合;同一 checkout 协作时由单一负责人编辑这些文件。
|
||||
- 新依赖先证明现有方案的具体缺口,说明版本、体积、状态与弹层互操作影响。不能为一个组件替换整套底座,或把文档图标包变成整库强制依赖。
|
||||
- 共享协议尚未确定时,只做不依赖该协议的工作。不要先假设多个不兼容的字段/颜色/焦点上下文,最后再让集成人猜测如何合并。
|
||||
- 任务开始时记录 Vue 项目的起始 commit;若工作区尚无可用提交或包含未提交工作,记录文件快照/差异范围,不把他人的修改混入交付,也不擅自 reset、清理或提交全部工作区。
|
||||
- 每项任务提供 `docs/migrations/<任务ID>.md` 交接报告;集成人在合并复核时同步兼容矩阵、来源和验证记录。其他 AI 不能仅凭自测就把组件标为“完整验收”。
|
||||
|
||||
## 可复制给其他 AI 的任务说明
|
||||
|
||||
复制后替换尖括号中的内容;这只是任务模板,不表示现在已派发。
|
||||
|
||||
```text
|
||||
在独立 heroui-vue 项目迁移 <组件/家族>,任务 ID 为 <Mxx>。
|
||||
先读取根 AGENTS.md、docs/migration-handoff.md、docs/compatibility.md、docs/upstream.md。
|
||||
参考 HeroUI 3.2.6 / ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960。
|
||||
上游参考仓库是 ../heroui,禁止修改它,不通过 React 包装 Vue。
|
||||
|
||||
范围:<具体组件、子部件、必要适配及前置依赖>。
|
||||
负责文件:<组件目录、组件 CSS/变体、演示、文档、测试、交接报告>。
|
||||
共享文件改动方式:<分支内提供差异,由集成人合并 / 当前 checkout 由指定负责人修改>。
|
||||
不在本任务范围:<明确排除的组件、基础设施或功能>。
|
||||
|
||||
先核对上游实现、样式、API、全部中文示例的名称/次序/内容,形成迁移清单。
|
||||
保持样式、布局、文案、参数默认值、变体、主题及状态的高一致性。
|
||||
仅将框架机制适配为 Vue v-model、事件、插槽与独立命名导出;记录具体差异。
|
||||
所有演示使用同一份 Vue SFC 渲染、复制和高亮;图标用 @tabler/icons-vue,不自绘 SVG。
|
||||
禁止用近似控件、占位内容或未生效的 Tailwind 类名充数。
|
||||
新增依赖或共享协议变更先说明缺口与影响,不擅自替换全库架构。
|
||||
|
||||
交付组件/类型/导出、样式与主题状态、全部基线演示与 API 文档、适用的行为测试。
|
||||
检查实际 FormData/reset/焦点/键盘与浅深主题;布局和拖动不能只用 jsdom 验收。
|
||||
按改动运行真实存在的测试、类型和构建命令;没有执行的检查明确标为未执行。
|
||||
文档开发地址固定 127.0.0.1:5173,不擅自结束其他服务或换端口。
|
||||
|
||||
最后提交 docs/migrations/<Mxx>.md:变更范围、清单、命令结果、浏览器证据、已知差异、
|
||||
未验证项、依赖与来源、需要集成人处理的共享文件及复核步骤。
|
||||
不要声明全库完成,不以测试数量或截图相似代替完整验收。
|
||||
```
|
||||
|
||||
## 每项任务的交付报告
|
||||
|
||||
报告至少包括下列内容,集成人据此接手,避免依赖另一个聊天窗口的上下文:
|
||||
|
||||
1. 起始版本与最终差异范围;修改文件与用途;共享文件的改动。
|
||||
2. 上游组件、CSS/变体、中文文档和演示的具体路径;原始许可及本次修改。
|
||||
3. API 对照:默认值、受控/非受控、部件/插槽、事件、暴露方法和框架差异。
|
||||
4. 示例对照:基线名称、顺序、实际内容、状态和缺失项。无法完成的项说明原因及替代验证。
|
||||
5. 实际执行的命令、结果和失败项;明确区分新增测试、原有测试及手动检查。
|
||||
6. 浏览器地址、视口、主题、状态、复现步骤与截图;容易误判的颜色/尺寸附计算样式。
|
||||
7. 尚未验证的 SSR 水合、读屏、触屏、RTL、独立安装等能力;已知缺口与后续依赖。
|
||||
8. 供集成人复核的最短路径,例如“打开哪个示例,按哪些键,应该提交什么值”。
|
||||
|
||||
## 我的复核顺序
|
||||
|
||||
我会独立重现结果,不直接采信交接报告中的“已完成”。
|
||||
|
||||
| 层次 | 检查方式 | 重点拦截的问题 |
|
||||
| ----------------- | ---------------------------------------- | ------------------------------------------------------------------------- |
|
||||
| 1:范围与来源 | 检查差异、上游路径、实际导出及依赖清单 | 改到 React 仓库、越界重构、混入他人修改、许可证遗漏、发布包出现 React |
|
||||
| 2:公共契约 | 对照上游类型/文档及 Vue 类型检查 | 属性/变体/默认值遗漏,事件不透传,模型优先级不明,API 文档与代码不一致 |
|
||||
| 3:交互与原生语义 | 运行适用测试并在浏览器操作 | 假禁用、只读仍响应键盘、重复触发、焦点丢失、表单值重复或 reset 错误 |
|
||||
| 4:样式与主题 | 在固定数据/视口/主题下对比,并读计算样式 | Tailwind 类未生成、主题映射缺失、级联覆盖、近似替代、间距/图标/圆角不一致 |
|
||||
| 5:文档与演示 | 逐个运行基线示例、展开和复制源码 | 数量对上但内容缺失、代码不同源、缺图标依赖、代码无高亮、静态状态假装交互 |
|
||||
| 6:集成与产物 | 合并后重新检查构建、SSR 及相关消费场景 | 只在源码 alias 下能运行、dist/类型/样式入口损坏、依赖冲突和其他组件回归 |
|
||||
|
||||
### 必查的具体项目
|
||||
|
||||
- 状态链是否完整:公共属性 → Vue 状态 → DOM/ARIA/data-* → CSS → 真实浏览器效果;尤其 pending 不等同于原生 disabled。
|
||||
- 受控与非受控是否都可用,父级拒绝更新时 DOM 是否正确;是否存在重复事件、修改传入值或动态 attrs 不更新。
|
||||
- name/value、选中/未选中、禁用、required、原生提交、reset、被取消的 reset,以及多实例唯一 ID 与标签/描述/错误关联。
|
||||
- 键盘、焦点可见与恢复、readonly、卸载清理;弹层额外检查 Esc、外部点击、滚动锁、嵌套、定位、退出动画和真实焦点限制。
|
||||
- 集合额外检查过滤/空状态/多选/清空/异步更新/IME;日期颜色额外检查值类型、格式、locale/时区或多个部件同步。
|
||||
- Tailwind 不只比模板 class:检查 accent/surface 等语义工具类真实生成、渐变和阴影非空、深色变量正确,预览通用规则没有覆盖 max-w-md 等显式类。
|
||||
- 不用 ghost Button 代替 CloseButton 等专用视觉;不把没有加载/失败处理的 img 当成完整 Avatar。
|
||||
- 桌面与窄屏、浅色与深色、主要变体和关键状态;图标库来源、尺寸和可访问名称;原站无法运行时明确限制,不声称逐像素一致。
|
||||
- 预览、复制、高亮必须来自同一 SFC。动态示例能开始、完成、恢复并重复执行;文档表格、导航、搜索及手机目录能实际使用。
|
||||
- 模块加载/SSR 不访问 window/document;ID、水合、Teleport 等检查与 SSR 冒烟分开。生产构建必须验证包导出的 dist,不只验证开发源码。
|
||||
|
||||
### 命令与证据边界
|
||||
|
||||
按改动范围运行当前真实存在的 `pnpm test`、`pnpm typecheck`、`pnpm build:docs`、`pnpm format`;影响消费验证页时增加 `pnpm build:playground`。合并后重跑受影响检查,不能用分支合并前的结果替代。
|
||||
|
||||
`test:browser`、`test:visual`、`test:package` 等目前尚未建立。需要时先建立可运行检查,或记录手动步骤与未验证范围,不能凭命令名称假称已通过。后续增加测试文件时检查 test:unit 的显式文件列表与默认测试入口是否都覆盖。
|
||||
|
||||
涉及布局、定位、滚动、拖动与焦点管理,jsdom 测试不能替代真实浏览器。反过来,只有截图也不能证明表单、键盘、受控状态与 SSR 正确。
|
||||
|
||||
## 复核结论与返工规则
|
||||
|
||||
| 结论 | 条件 | 后续处理 |
|
||||
| ---------------- | ------------------------------------------------------ | ------------------------------------------------------- |
|
||||
| 通过本任务范围 | 约定范围、行为、视觉、文档及适用检查均有证据,差异明确 | 集成并更新对应能力状态,不扩大为整组件/全库完整兼容 |
|
||||
| 待修正 | 可复现的契约、视觉、交互、示例或集成问题 | 给出定位与复现步骤,修复后复核问题及受影响回归 |
|
||||
| 暂缓,需确定方案 | 底座缺口或共享协议尚无可验证解决路径 | 写出失败场景、可选局部方案和影响,由用户/集成人决定范围 |
|
||||
|
||||
核心状态错误、公共 API 缺失、明显视觉偏差、基线演示缺失、构建/SSR 失败均不能评为“通过”。预先写明且不影响本任务承诺的延后项,按范围单独记录;新发现的缺口不能事后静默改成“不在范围”。
|
||||
|
||||
每条问题给出严重性、文件与行号、触发条件、实际/预期、依据及修复后的验证方式。优先级顺序为:数据丢失/安全与无法使用的问题 → 公共契约、表单、焦点与关键状态 → 视觉、示例与文档偏差 → 可维护性建议。高一致性是明确要求,明显视觉或内容偏差同样可以阻止验收。
|
||||
|
||||
最后的复核报告列出:发现的问题、已复核通过的范围、执行的检查、未验证项和下一步。若没有发现问题,也明确审查边界,不能保证不存在任何缺陷。
|
||||
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,29 @@
|
||||
# 上游基线与移植来源
|
||||
|
||||
- 项目:https://github.com/heroui-inc/heroui
|
||||
- 基线版本:3.2.6
|
||||
- 提交:ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960
|
||||
- 本次更新:2026-10-20
|
||||
|
||||
## 已移植
|
||||
|
||||
- packages/styles/components/{button,close-button,card,input,switch,switch-group,label,description}.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,switch}/*.styles.ts:变体与类名映射,增加命名空间。
|
||||
- apps/docs/content/docs/cn/react/components 下相应四个组件的标题、说明、示例顺序和 API 描述;React 特有部分转换为 Vue 用法。
|
||||
- apps/docs/src/demos/cn 下Button/Card/Input/Switch 全部基线示例的文案与布局;文档由新项目 SFC 实现。
|
||||
- apps/docs/public/fonts/Inter-{Regular,Medium,Bold}.ttf:文档字体资源。
|
||||
|
||||
## 来源声明
|
||||
|
||||
上游清单标注 MIT,但本地根 LICENSE 实际为 Apache-2.0(含 Copyright 2025 NextUI Inc.)。本项目保留原始全文于 third-party/HEROUI-LICENSE,样式包也携带 LICENSE;不能继续沿用早期文档中未经核对的 MIT 结论。移植文件保留来源并标注命名空间与 Vue 适配修改。
|
||||
|
||||
构建与运行不依赖相邻 React 仓库。完整源样式移植记录以本文件及源码顶部声明为准。
|
||||
|
||||
## 本批文档适配
|
||||
|
||||
- Card 的头像使用已安装 Reka Avatar 的加载和 fallback 机制;图片沿用上游 CDN URL,不复制媒体文件。Link 使用原生 a,关闭按钮使用原生 button、closeButtonVariants 与基线 CloseButton CSS 组合;这些依赖不标记为库的已实现组件。
|
||||
- Card 表单使用原生 form/label 与 Input 组合,提交仅展示本地反馈,不实现登录与密码找回服务。
|
||||
- SwitchGroup 的方向布局 CSS 来自同一基线。Switch 的 native/ARIA 校验、表单 checkbox、reset、属性与事件透传由 Vue 状态层实现;FieldError 暂仅接入 Switch。
|
||||
- 图标统一使用 @tabler/icons-vue(MIT)的官方组件,未移植 React 图标依赖;尚未完成自动逐像素对比。
|
||||
@@ -0,0 +1,72 @@
|
||||
# 高一致性改造验证
|
||||
|
||||
验证日期:2026-10-20。
|
||||
|
||||
- 组件包、样式包 ESM 与类型声明构建通过。
|
||||
- Tailwind 4 编译移植的主题与组件 CSS,消费者无需配置 Tailwind。
|
||||
- Vue 类型检查通过;14 项行为与 SSR 测试通过。
|
||||
- 文档和独立验证应用生产构建通过,VitePress 检查无死链接。
|
||||
- 实际浏览器检查浅色/深色主题、按钮变体、开关切换、展开示例源码、页面导航。
|
||||
- 30 个示例直接渲染各自 SFC,复制代码读取同一个 SFC 的 raw 内容。
|
||||
|
||||
没有运行完整原 React 文档站,因此尚未完成原站与 Vue 站的自动逐像素对比;当前不能宣称布局、行为和文案已全面一致。移动端专项、读屏、Nuxt 水合与打包后独立安装尚未验证。
|
||||
|
||||

|
||||
|
||||
## 文档体验改进
|
||||
|
||||
- 搜索改为本地正文与章节索引,可搜索参数名;支持 Cmd/Ctrl+K、方向键、Enter 和 Esc。
|
||||
- 搜索摘要定位命中上下文,过滤 Markdown 表格分隔符;空结果提供下一步提示。
|
||||
- 示例代码采用构建时语法高亮,同时保留原始 SFC 的精确复制内容;复制反馈自动复位,失败展开代码以便手动复制。
|
||||
- 正文与预览样式隔离;收紧空白、统一按钮目标和表格滚动;960px 以下切换目录抽屉,保留搜索入口。
|
||||
- 真实浏览器检查了搜索与回车章节跳转,并通过 390px iframe 视口检查目录抽屉、导航后关闭和 Card 页面布局;这不等同于真实手机和触摸设备的完整验收。
|
||||
- 新增 5 项搜索行为测试;当前 19 项测试通过。类型检查与文档生产构建通过。
|
||||
|
||||
实际浏览器已验证示例代码复制成功,深色源码高亮与右侧阅读位置指示正常。
|
||||
|
||||

|
||||
|
||||
## Button 缺失内容与加载行为修复
|
||||
|
||||
- 本地基线 Button 文档与 Vue 文档的预览名称逐项比较:14 / 14,顺序一致,缺失为 0。
|
||||
- 新增加载状态的完整演示测试,覆盖开始、阻止重复点击、保持焦点、2 秒恢复、再次触发及卸载清理。
|
||||
- 新增 loading 别名、asChild 状态与事件合并、涟漪键盘触发和动画清理测试;当前共 24 项测试通过。
|
||||
- 实际浏览器检查上传按钮进入“上传中…”并恢复“上传文件”,显示完成反馈,焦点仍留在原按钮。
|
||||
- 自定义变体示例在文档包内编译 Tailwind 工具类,库的预编译 CSS 消费方式不变。
|
||||
|
||||

|
||||
|
||||
## 加载视觉与浅色代码高亮修复
|
||||
|
||||
- 修复 pending 缺失 aria-disabled 的状态适配:复用基线的 disabled-opacity(0.5),保留蓝色并降低透明度;不设置原生 disabled,保留焦点。
|
||||
- 加载或禁用时清理悬停、按下状态,避免恢复后残留。
|
||||
- 补齐 Shiki 浅色变量的 CSS 应用;浏览器检查源码 token 已呈现 6 种颜色。
|
||||
- 25 项测试通过,新增加载状态清理回归检查。
|
||||
|
||||
## Card / Input / Switch 按 Button 标准复核
|
||||
|
||||
- 固定提交预览清单与当前页面逐项比较:Card 7 / 7、Input 7 / 7、Switch 15 / 15,包含顺序检查。总计 43 个基线示例。
|
||||
- Card 恢复 9 张卡片的图片组合、横向樱桃卡片、头像、原生表单与定制 Pro 卡片;上游 CDN 图片在实际浏览器加载成功。
|
||||
- Input 恢复 3 个可见标签及唯一关联、受控域名反馈、自定义样式与原始尺寸。实际浏览器编辑后反馈 https://vue.example,页面无水平溢出。
|
||||
- Switch 修复组合模式的 ARIA 透传、唯一描述 ID、只读键盘行为、原生表单值和 reset;新增 native/aria 校验与 Switch FieldError、SwitchGroup 布局。浏览器确认无未命名开关,轨道尺寸为 32×16 / 40×20 / 48×24,纵向 column、横向 row,表单输出 notifications: on、newsletter: on。
|
||||
- 浅色与深色代码 token 配色正常;深色 Input 使用主题 field/foreground 变量。
|
||||
- 新增 9 项回归检查,共 34 项测试。类型检查、库和文档生产构建作为本批交付检查。真实浏览器检查为手动验证,尚未建立自动逐像素与设备矩阵;不能宣称完全兼容。
|
||||
|
||||
## 图标组件统一
|
||||
|
||||
- 文档与所有已实现组件示例统一采用 @tabler/icons-vue 3.49.0。搜索/设置/删除/品牌/开关/卡片与工具栏均使用官方组件。
|
||||
- 演示源码无内嵌 svg/path;加载图标保留独立 16px 插槽、减少动态效果支持;图标按钮保留可访问名称。
|
||||
- 文档安装页提供依赖命令与用法,组件发布包未新增图标依赖;按需导入,无在线图标服务。
|
||||
|
||||
## Card 关闭按钮样式修正
|
||||
|
||||
- 移除 Card 水平布局与图片组合中 3 处 ghost Button 代替 CloseButton 的做法。
|
||||
- 移植固定基线 CloseButton CSS 与变体映射,仅增加 hv- 前缀:24px 按钮、16px 图标、default/muted 主题色、悬停背景、按下 0.93 缩放、焦点与减少动态效果规则。
|
||||
- 演示使用原生 type=button 与 Tabler IconX,保留关闭操作的可访问名称。该修复只交付样式组合,不将 Vue CloseButton 公共组件标记为完成。
|
||||
|
||||
## Card Tailwind 示例的编译与层级修复
|
||||
|
||||
- 示例的静态 class 清单已逐项与固定提交的 card/custom-styles.tsx 核对一致;图标使用用户指定的 Tabler 替代。
|
||||
- 修复独立 utilities.css 缺少库 @theme inline 映射的问题。此前 accent/surface 等自定义颜色工具类没有生成,计算样式中渐变为 none、光晕与标签背景为透明。现在显式导入本库主题映射。
|
||||
- 把通用预览 max-width:100% 约束放入 components 层,恢复 utilities 层 max-w-md 的优先级;桌面计算宽度由 654px 恢复为 448px。
|
||||
- 实际浏览器分别验证浅色与深色:渐变、边框透明度、光晕、推荐标签背景及按钮 accent 阴影均存在,页面无水平溢出。未宣称自动逐像素对比通过。
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "heroui-vue-workspace",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@11.25.0",
|
||||
"engines": {
|
||||
"node": ">=22.12.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "pnpm build && pnpm --filter @heroui-vue/docs dev",
|
||||
"dev:docs": "pnpm dev",
|
||||
"build": "pnpm --filter @heroui-vue/styles build && pnpm --filter @heroui-vue/components build",
|
||||
"build:playground": "pnpm build && pnpm --filter @heroui-vue/playground build",
|
||||
"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",
|
||||
"test:ssr": "vitest run tests/ssr.test.ts",
|
||||
"format": "prettier --check .",
|
||||
"format:fix": "prettier --write .",
|
||||
"dev:playground": "pnpm build && pnpm --filter @heroui-vue/playground dev"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^6.0.0",
|
||||
"@vue/server-renderer": "^3.5.44",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"jsdom": "^26.1.0",
|
||||
"prettier": "^3.6.2",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "^7.1.0",
|
||||
"vite-plugin-dts": "^4.5.4",
|
||||
"vitest": "^3.2.4",
|
||||
"vue": "^3.5.44",
|
||||
"vue-tsc": "^3.1.0",
|
||||
"@types/node": "^22.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to the Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by the Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding any notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. Please also get an approval
|
||||
from the project maintainers before using the Apache License.
|
||||
|
||||
Copyright 2025 NextUI Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,161 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
|
||||
/* Button component styles */
|
||||
|
||||
/* Base button styles */
|
||||
.hv-button {
|
||||
@apply relative isolate inline-flex h-10 w-fit origin-center items-center justify-center gap-2 rounded-3xl px-4 text-sm font-medium whitespace-nowrap outline-none select-none no-highlight md:h-9;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
transform 250ms var(--ease-smooth),
|
||||
background-color 100ms var(--ease-out),
|
||||
box-shadow 100ms var(--ease-out);
|
||||
@apply transform-gpu motion-reduce:transition-none;
|
||||
|
||||
/* Cursor */
|
||||
cursor: var(--cursor-interactive);
|
||||
|
||||
/* Default tokens (fallback behavior) */
|
||||
--button-bg: transparent;
|
||||
--button-bg-hover: var(--button-bg);
|
||||
--button-bg-pressed: var(--button-bg-hover);
|
||||
--button-fg: currentColor;
|
||||
|
||||
background-color: var(--button-bg);
|
||||
color: var(--button-fg);
|
||||
|
||||
/* Focus state */
|
||||
&:focus-visible:not([data-focused]),
|
||||
&[data-focus-visible="true"] {
|
||||
@apply status-focused;
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&:disabled,
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
}
|
||||
|
||||
/* Pending state */
|
||||
&[data-pending="true"] {
|
||||
@apply status-pending;
|
||||
}
|
||||
|
||||
/* Active / pressed */
|
||||
&:active,
|
||||
&[data-pressed="true"] {
|
||||
@apply will-change-transform;
|
||||
background-color: var(--button-bg-pressed);
|
||||
transform: scale(0.97);
|
||||
}
|
||||
|
||||
/* Hover */
|
||||
@media (hover: hover) {
|
||||
&:hover,
|
||||
&[data-hovered="true"] {
|
||||
background-color: var(--button-bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
/* SVG icon styling - exclude spinner and link-icon svgs */
|
||||
& svg:not([data-slot="spinner"] svg, [data-slot="link-icon"] svg) {
|
||||
@apply pointer-events-none -mx-0.5 my-0.5 size-5 shrink-0 self-center sm:my-1 sm:size-4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Size variants */
|
||||
.hv-button--sm {
|
||||
@apply h-9 px-3 md:h-8;
|
||||
|
||||
& svg:not([data-slot="spinner"] svg, [data-slot="link-icon"] svg) {
|
||||
@apply size-4;
|
||||
}
|
||||
|
||||
&:active,
|
||||
&[data-pressed="true"] {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.hv-button--md {
|
||||
/* No styles as this is the default size */
|
||||
}
|
||||
|
||||
.hv-button--lg {
|
||||
@apply h-11 text-base md:h-10;
|
||||
|
||||
&:active,
|
||||
&[data-pressed="true"] {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
}
|
||||
|
||||
/* Color variants - only set custom property values */
|
||||
.hv-button--primary {
|
||||
--button-bg: var(--accent);
|
||||
--button-bg-hover: var(--accent-hover);
|
||||
--button-bg-pressed: var(--accent-hover);
|
||||
--button-fg: var(--accent-foreground);
|
||||
}
|
||||
|
||||
.hv-button--secondary {
|
||||
--button-bg: var(--default);
|
||||
--button-bg-hover: var(--default-hover);
|
||||
--button-bg-pressed: var(--default-hover);
|
||||
--button-fg: var(--accent-soft-foreground);
|
||||
}
|
||||
|
||||
.hv-button--tertiary {
|
||||
--button-bg: var(--default);
|
||||
--button-bg-hover: var(--default-hover);
|
||||
--button-bg-pressed: var(--default-hover);
|
||||
}
|
||||
|
||||
.hv-button--ghost,
|
||||
.hv-button--outline {
|
||||
--button-bg: transparent;
|
||||
--button-bg-hover: var(--default);
|
||||
--button-bg-pressed: var(--default);
|
||||
--button-fg: var(--default-foreground);
|
||||
}
|
||||
|
||||
.hv-button--outline {
|
||||
@apply border border-border;
|
||||
--button-bg-hover: color-mix(in srgb, var(--default) 60%, transparent);
|
||||
}
|
||||
|
||||
.hv-button--danger {
|
||||
--button-bg: var(--danger);
|
||||
--button-bg-hover: var(--danger-hover);
|
||||
--button-bg-pressed: var(--danger-hover);
|
||||
--button-fg: var(--danger-foreground);
|
||||
}
|
||||
|
||||
.hv-button--danger-soft {
|
||||
--button-bg: var(--danger-soft);
|
||||
--button-bg-hover: var(--danger-soft-hover);
|
||||
--button-bg-pressed: var(--danger-soft-hover);
|
||||
--button-fg: var(--danger-soft-foreground);
|
||||
}
|
||||
|
||||
/* Icon-only modifier */
|
||||
.hv-button--icon-only {
|
||||
@apply w-10 p-0 md:w-9;
|
||||
}
|
||||
|
||||
.hv-button--icon-only.hv-button--sm {
|
||||
@apply w-9 md:w-8;
|
||||
}
|
||||
|
||||
.hv-button--icon-only.hv-button--lg {
|
||||
@apply w-11 md:w-10;
|
||||
}
|
||||
|
||||
/* Full width modifier */
|
||||
.hv-button--full-width {
|
||||
@apply w-full;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
|
||||
/* Card component styles */
|
||||
|
||||
/* Block */
|
||||
.hv-card {
|
||||
@apply relative flex flex-col gap-3 overflow-visible p-4;
|
||||
@apply shadow-surface;
|
||||
border-radius: min(32px, var(--radius-3xl));
|
||||
}
|
||||
|
||||
/* Element - header */
|
||||
.hv-card__header {
|
||||
@apply flex flex-col;
|
||||
}
|
||||
|
||||
/* Element - title */
|
||||
.hv-card__title {
|
||||
@apply text-sm leading-6 font-medium text-foreground;
|
||||
}
|
||||
|
||||
/* Element - description */
|
||||
.hv-card__description {
|
||||
@apply text-sm leading-5 text-muted;
|
||||
}
|
||||
|
||||
/* Element - content */
|
||||
.hv-card__content {
|
||||
@apply flex flex-1 flex-col gap-1;
|
||||
}
|
||||
|
||||
/* Element - footer */
|
||||
.hv-card__footer {
|
||||
@apply flex flex-row items-center;
|
||||
}
|
||||
|
||||
/* Modifier - variant */
|
||||
|
||||
.hv-card--transparent {
|
||||
@apply border-none bg-transparent shadow-none;
|
||||
}
|
||||
|
||||
.hv-card--default {
|
||||
@apply bg-surface;
|
||||
}
|
||||
|
||||
.hv-card--secondary {
|
||||
@apply bg-surface-secondary;
|
||||
}
|
||||
|
||||
.hv-card--tertiary {
|
||||
@apply bg-surface-tertiary;
|
||||
}
|
||||