feat: add Disclosure DisclosureGroup and Accordion
This commit is contained in:
@@ -45,6 +45,7 @@ const groups = [
|
||||
{
|
||||
title: "组件",
|
||||
items: [
|
||||
{ title: "Accordion 手风琴", url: "/components/accordion" },
|
||||
{ title: "Alert 警告", url: "/components/alert" },
|
||||
{ title: "Avatar 头像", url: "/components/avatar" },
|
||||
{ title: "AvatarGroup 头像组", url: "/components/avatar-group" },
|
||||
@@ -57,6 +58,11 @@ const groups = [
|
||||
{ title: "Chip 标签", url: "/components/chip" },
|
||||
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
|
||||
{ title: "Description 描述", url: "/components/description" },
|
||||
{ title: "Disclosure 折叠面板", url: "/components/disclosure" },
|
||||
{
|
||||
title: "DisclosureGroup 折叠面板组",
|
||||
url: "/components/disclosure-group",
|
||||
},
|
||||
{ title: "EmptyState 空状态", url: "/components/empty-state" },
|
||||
{ title: "FieldError 字段错误", url: "/components/field-error" },
|
||||
{ title: "Fieldset 字段组", url: "/components/fieldset" },
|
||||
|
||||
@@ -3,6 +3,7 @@ title: 组件
|
||||
description: 已迁移组件及文档
|
||||
---
|
||||
|
||||
- [Accordion 手风琴](./components/accordion)
|
||||
- [Alert 警告](./components/alert)
|
||||
- [Avatar 头像](./components/avatar)
|
||||
- [AvatarGroup 头像组](./components/avatar-group)
|
||||
@@ -13,6 +14,8 @@ description: 已迁移组件及文档
|
||||
- [Chip 标签](./components/chip)
|
||||
- [CloseButton 关闭按钮](./components/close-button)
|
||||
- [Description 描述](./components/description)
|
||||
- [Disclosure 折叠面板](./components/disclosure)
|
||||
- [DisclosureGroup 折叠面板组](./components/disclosure-group)
|
||||
- [EmptyState 空状态](./components/empty-state)
|
||||
- [FieldError 字段错误](./components/field-error)
|
||||
- [Input 输入框](./components/input)
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
---
|
||||
title: Accordion 手风琴
|
||||
description: 用于在紧凑空间中组织信息的可折叠内容面板
|
||||
component: accordion
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion>
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
标题
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>内容</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
```
|
||||
|
||||
<ComponentPreview name="accordion-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion>
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody />
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
```
|
||||
|
||||
Accordion 复用 DisclosureGroup 的展开键协议(数组、字符串/数字 key),部件与布局按手风琴基线独立。
|
||||
|
||||
## 示例
|
||||
|
||||
### 表面样式
|
||||
|
||||
<ComponentPreview name="accordion-surface" />
|
||||
|
||||
### 无分隔线
|
||||
|
||||
<ComponentPreview name="accordion-without-separator" />
|
||||
|
||||
### 多项展开
|
||||
|
||||
<ComponentPreview name="accordion-multiple" />
|
||||
|
||||
### 禁用状态
|
||||
|
||||
<ComponentPreview name="accordion-disabled" />
|
||||
|
||||
### 受控组件
|
||||
|
||||
<ComponentPreview name="accordion-controlled" />
|
||||
|
||||
### 自定义指示器
|
||||
|
||||
<ComponentPreview name="accordion-custom-indicator" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
上游 `render` 映射为 `as` 与透传属性。
|
||||
|
||||
<ComponentPreview name="accordion-render-function" />
|
||||
|
||||
### 常见问题布局
|
||||
|
||||
<ComponentPreview name="accordion-faq" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="accordion-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-accordion {
|
||||
@apply rounded-xl bg-gray-50;
|
||||
}
|
||||
|
||||
.hv-accordion__trigger {
|
||||
@apply font-semibold text-lg;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
- `.hv-accordion` - 根容器
|
||||
- `.hv-accordion__item` - 单项与分隔线
|
||||
- `.hv-accordion__heading` / `.hv-accordion__trigger` / `.hv-accordion__indicator`
|
||||
- `.hv-accordion__panel` / `.hv-accordion__body` / `.hv-accordion__body-inner`
|
||||
- `.hv-accordion--surface` - 表面变体
|
||||
|
||||
## API 参考
|
||||
|
||||
### Accordion
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------ | --------------------------- | ----------- | -------------------- |
|
||||
| `expandedKeys` | `Array<string \| number>` | - | 受控展开 key |
|
||||
| `defaultExpandedKeys` | `Array<string \| number>` | `[]` | 初始展开 key |
|
||||
| `allowsMultipleExpanded` | `boolean` | `false` | 是否允许多项同时展开 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用整个 Accordion |
|
||||
| `variant` | `"default" \| "surface"` | `"default"` | 视觉变体 |
|
||||
| `hideSeparator` | `boolean` | `false` | 隐藏项之间的分隔线 |
|
||||
| `as` | `string` | `"div"` | 根元素 |
|
||||
| `class` | `string \| Array \| Object` | - | 额外的 CSS 类 |
|
||||
|
||||
### AccordionItem
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ----------------- | ------------------ | ------- | -------------------- |
|
||||
| `id` | `string \| number` | - | 该项唯一标识(组键) |
|
||||
| `expanded` | `boolean` | - | 受控展开状态 |
|
||||
| `defaultExpanded` | `boolean` | `false` | 初始展开 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用该项 |
|
||||
| `as` | `string` | `"div"` | 项根元素 |
|
||||
|
||||
### AccordionHeading / Trigger / Panel / Body / Indicator
|
||||
|
||||
与 Disclosure 对应部件语义一致,使用 `hv-accordion__*` 样式;Trigger 为 `type="button"`,Panel 负责高度动画,Indicator 支持自定义图标插槽。
|
||||
|
||||
## 相关组件
|
||||
|
||||
- [Disclosure 折叠面板](./disclosure)
|
||||
- [DisclosureGroup 折叠面板组](./disclosure-group)
|
||||
@@ -0,0 +1,115 @@
|
||||
---
|
||||
title: DisclosureGroup 折叠面板组
|
||||
description: 管理多个 Disclosure 项展开状态的容器
|
||||
component: disclosure-group
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Disclosure,
|
||||
DisclosureGroup,
|
||||
DisclosureContent,
|
||||
DisclosureHeading,
|
||||
DisclosureTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DisclosureGroup>
|
||||
<Disclosure id="item1">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger>
|
||||
标题
|
||||
<span>▼</span>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>内容</DisclosureContent>
|
||||
</Disclosure>
|
||||
</DisclosureGroup>
|
||||
</template>
|
||||
```
|
||||
|
||||
<ComponentPreview name="disclosure-group-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Disclosure, DisclosureGroup } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DisclosureGroup>
|
||||
<Disclosure id="item1">…</Disclosure>
|
||||
</DisclosureGroup>
|
||||
</template>
|
||||
```
|
||||
|
||||
`DisclosureGroup` 用数组管理展开键(空集合为 `[]`),支持字符串或数字 key(`1` 与 `"1"` 不会碰撞)。
|
||||
|
||||
## 示例
|
||||
|
||||
### 受控组件
|
||||
|
||||
可使用 `expandedKeys` 与 `update:expandedKeys` 配合 `useDisclosureGroupNavigation` 外部导航。
|
||||
|
||||
<ComponentPreview name="disclosure-group-controlled" />
|
||||
|
||||
`useDisclosureGroupNavigation` 为公开 composable:提供 `currentIndex`、`isPrevDisabled`、`isNextDisabled`、`onPrevious`、`onNext`。单选替换集合,多选增量添加;不修改传入集合。
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="disclosure-group-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-disclosure-group {
|
||||
@apply w-full;
|
||||
contain: layout style;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
- `.hv-disclosure-group` - 基础容器样式,含布局 containment
|
||||
|
||||
## API 参考
|
||||
|
||||
### DisclosureGroup
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------ | ------------------------------ | ------- | ------------------------------------- |
|
||||
| `expandedKeys` | `Array<string \| number>` | - | 受控展开项(`v-model:expanded-keys`) |
|
||||
| `defaultExpandedKeys` | `Array<string \| number>` | `[]` | 初始展开项 |
|
||||
| `allowsMultipleExpanded` | `boolean` | `false` | 是否允许多项同时展开 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用组内所有 Disclosure |
|
||||
| `as` | `string` | `"div"` | 根元素 |
|
||||
| `class` | `string \| Array \| Object` | - | 合并到根元素 |
|
||||
| 默认插槽 | `{ expandedKeys, isDisabled }` | - | Disclosure 项 |
|
||||
|
||||
事件:`update:expandedKeys`、`expandedChange`。
|
||||
|
||||
### useDisclosureGroupNavigation
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------ | ----------------------------------------- | ------- | ------------- |
|
||||
| `expandedKeys` | `Array<string \| number>` 或 getter | - | 当前展开键 |
|
||||
| `itemIds` | `Array<string \| number>` 或 getter | `[]` | 成员 key 列表 |
|
||||
| `onExpandedChange` | `(keys: Array<string \| number>) => void` | - | 提交新集合 |
|
||||
| `allowsMultipleExpanded` | `boolean` | `false` | 多选增量 |
|
||||
|
||||
返回:`currentIndex`、`isPrevDisabled`、`isNextDisabled`、`onPrevious`、`onNext`。
|
||||
|
||||
## 相关组件
|
||||
|
||||
- [Disclosure 折叠面板](./disclosure)
|
||||
- [Accordion 手风琴](./accordion)
|
||||
@@ -0,0 +1,174 @@
|
||||
---
|
||||
title: Disclosure 折叠面板
|
||||
description: 可折叠区块,包含标题、触发按钮与内容面板
|
||||
component: disclosure
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Disclosure,
|
||||
DisclosureContent,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Disclosure>
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger>
|
||||
标题
|
||||
<DisclosureIndicator />
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<p>内容</p>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</template>
|
||||
```
|
||||
|
||||
<ComponentPreview name="disclosure-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Disclosure,
|
||||
DisclosureContent,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Disclosure>
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger>
|
||||
<DisclosureIndicator />
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent />
|
||||
</Disclosure>
|
||||
</template>
|
||||
```
|
||||
|
||||
`Disclosure` 渲染为带 `data-slot="disclosure"` 的容器。`DisclosureTrigger` 默认是 `type="button"` 的按钮,点击/Enter/Space 切换展开;`as-child` 可把触发语义合并到 `Button` 等单个子元素。
|
||||
|
||||
## 示例
|
||||
|
||||
### 渲染函数
|
||||
|
||||
上游 `render` 用于替换根元素;Vue 版通过 `as` 更换元素类型,`data-*` 等属性直接透传。
|
||||
|
||||
<ComponentPreview name="disclosure-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="disclosure-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 Disclosure 组件类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-disclosure {
|
||||
@apply relative;
|
||||
}
|
||||
|
||||
.hv-disclosure__trigger {
|
||||
@apply cursor-pointer;
|
||||
}
|
||||
|
||||
.hv-disclosure__indicator {
|
||||
@apply transition-transform duration-300;
|
||||
}
|
||||
|
||||
.hv-disclosure__content {
|
||||
@apply overflow-hidden transition-all;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论。类名前缀为 `hv-`。
|
||||
|
||||
### CSS 类
|
||||
|
||||
- `.hv-disclosure` - 基础容器样式
|
||||
- `.hv-disclosure__heading` - 标题包裹层
|
||||
- `.hv-disclosure__trigger` - 触发按钮样式
|
||||
- `.hv-disclosure__indicator` - 箭头指示器样式
|
||||
- `.hv-disclosure__content` - 带动画的内容容器
|
||||
- `.hv-disclosure__body` / `.hv-disclosure__body-inner` - 正文与内层
|
||||
|
||||
### 交互状态
|
||||
|
||||
- **Expanded**:指示器上 `[data-expanded="true"]` 用于旋转;内容上 `[data-expanded="true"]`
|
||||
- **Focus**:触发器上 `:focus-visible`
|
||||
- **Disabled**:触发器上 `:disabled` 或 `[aria-disabled="true"]`
|
||||
- 内容高度使用测量变量驱动展开动画,并支持 `prefers-reduced-motion`
|
||||
|
||||
## API 参考
|
||||
|
||||
### Disclosure
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ----------------- | ---------------------------- | ------- | ------------------------------------- |
|
||||
| `id` | `string \| number` | - | 组键与 DOM id |
|
||||
| `expanded` | `boolean` | - | 受控展开状态;配合 `v-model:expanded` |
|
||||
| `defaultExpanded` | `boolean` | `false` | 非受控初始展开 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 |
|
||||
| `as` | `string` | `"div"` | 根元素类型 |
|
||||
| `class` | `string \| Array \| Object` | - | 合并到根元素 |
|
||||
| 默认插槽 | `{ isExpanded, isDisabled }` | - | 内容或作用域插槽 |
|
||||
|
||||
事件:`update:expanded`、`expandedChange`。
|
||||
|
||||
### DisclosureHeading
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------- | --------------------------- | ------ | -------------- |
|
||||
| `as` | `string` | `"h3"` | 标题元素 |
|
||||
| `level` | `1`–`6` | `3` | 标题级别 |
|
||||
| `class` | `string \| Array \| Object` | - | 合并到标题元素 |
|
||||
|
||||
### DisclosureTrigger
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------ | ---------------------------- | ---------- | -------------------------- |
|
||||
| `as` | `string` | `"button"` | 元素类型 |
|
||||
| `asChild` | `boolean` | `false` | 合并到默认插槽的单个子元素 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用触发 |
|
||||
| `class` | `string \| Array \| Object` | - | 合并到触发器 |
|
||||
| 默认插槽 | `{ isExpanded, isDisabled }` | - | 触发器内容 |
|
||||
|
||||
事件:`click`(可在处理函数中 `preventDefault` 取消切换)。
|
||||
|
||||
### DisclosureContent
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| -------- | ---------------------------- | ------- | ---------- |
|
||||
| `as` | `string` | `"div"` | 面板元素 |
|
||||
| `class` | `string \| Array \| Object` | - | 合并到面板 |
|
||||
| 默认插槽 | `{ isExpanded, isDisabled }` | - | 面板内容 |
|
||||
|
||||
### DisclosureBody / DisclosureIndicator
|
||||
|
||||
Body 提供基线内边距与内层包装。Indicator 默认为基线 Chevron 图标,可传入自定义图标作为默认插槽;展开时附加 `data-expanded="true"` 并旋转。
|
||||
|
||||
## 相关组件
|
||||
|
||||
- [DisclosureGroup 折叠面板组](./disclosure-group)
|
||||
- [Accordion 手风琴](./accordion)
|
||||
@@ -0,0 +1,94 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconArrowsLeftRight,
|
||||
IconBox,
|
||||
IconChevronDown,
|
||||
IconCreditCard,
|
||||
IconReceipt,
|
||||
IconShoppingBag,
|
||||
IconWorld,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const iconMap = {
|
||||
box: IconBox,
|
||||
card: IconCreditCard,
|
||||
cart: IconShoppingBag,
|
||||
earth: IconWorld,
|
||||
receipt: IconReceipt,
|
||||
rotate: IconArrowsLeftRight,
|
||||
} as const;
|
||||
|
||||
function iconFor(key: keyof typeof iconMap) {
|
||||
return iconMap[key];
|
||||
}
|
||||
|
||||
const items = [
|
||||
{
|
||||
content:
|
||||
"浏览我们的商品,将商品加入购物车并前往结账。完成购买需要提供收货与支付信息。",
|
||||
icon: "cart",
|
||||
title: "如何下单?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"可以,在订单发货前你可以修改或取消。订单一旦进入处理流程,将无法再更改。",
|
||||
icon: "receipt",
|
||||
title: "可以修改或取消订单吗?",
|
||||
},
|
||||
{
|
||||
content: "我们接受主流信用卡,包括 Visa、Mastercard 和 American Express。",
|
||||
icon: "card",
|
||||
title: "支持哪些支付方式?",
|
||||
},
|
||||
{
|
||||
content: "运费因收货地址与订单体积而异。订单满 50 美元可享受免运费。",
|
||||
icon: "box",
|
||||
title: "运费如何计算?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"是的,我们可向多数国家/地区发货。请查看运费说明与政策了解更多信息。",
|
||||
icon: "earth",
|
||||
title: "是否提供国际配送?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"若对购买不满意,可在购买后 30 天内申请退款。请联系客服团队协助处理。",
|
||||
icon: "rotate",
|
||||
title: "如何申请退款?",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion class="w-full max-w-md">
|
||||
<AccordionItem v-for="(item, index) in items" :key="index">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
<span class="me-3 size-4 shrink-0 text-muted">
|
||||
<component
|
||||
:is="iconFor(item.icon as keyof typeof iconMap)"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator>
|
||||
<IconChevronDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,94 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
Button,
|
||||
useDisclosureGroupNavigation,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconChevronUp, IconChevronDown } from "@tabler/icons-vue";
|
||||
|
||||
const items = [
|
||||
{
|
||||
content:
|
||||
"了解 HeroUI 的基础知识,以及如何将其集成到你的 React 项目中。本节涵盖安装、配置和你的第一个组件。",
|
||||
id: "getting-started",
|
||||
title: "快速开始",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"理解 HeroUI 背后的核心概念,包括复合组件模式、使用 Tailwind CSS 进行样式设计,以及无障碍特性。",
|
||||
id: "core-concepts",
|
||||
title: "核心概念",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"探索高级特性,例如自定义变体、主题定制,以及与 React 生态中其他库的集成。",
|
||||
id: "advanced-usage",
|
||||
title: "高级用法",
|
||||
},
|
||||
];
|
||||
|
||||
const expandedKeys = ref<Array<string | number>>(["getting-started"]);
|
||||
const itemIds = items.map((item) => item.id);
|
||||
|
||||
const { isNextDisabled, isPrevDisabled, onNext, onPrevious } =
|
||||
useDisclosureGroupNavigation({
|
||||
expandedKeys,
|
||||
itemIds,
|
||||
onExpandedChange: (keys) => {
|
||||
expandedKeys.value = keys;
|
||||
},
|
||||
});
|
||||
|
||||
const expandedText = computed(() => expandedKeys.value.join("、") || "无");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-md">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<p class="text-sm text-muted">
|
||||
已展开:
|
||||
<strong>{{ expandedText }}</strong>
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<Button
|
||||
aria-label="上一项"
|
||||
:is-disabled="isPrevDisabled"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="onPrevious"
|
||||
>
|
||||
<IconChevronUp class="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
<Button
|
||||
aria-label="下一项"
|
||||
:is-disabled="isNextDisabled"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="onNext"
|
||||
>
|
||||
<IconChevronDown class="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Accordion v-model:expanded-keys="expandedKeys">
|
||||
<AccordionItem v-for="item in items" :key="item.id" :id="item.id">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,77 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconChevronsDown,
|
||||
IconCircleChevronDown,
|
||||
IconMinus,
|
||||
IconPlus,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const expandedKeys = ref<Array<string | number>>([]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion
|
||||
v-model:expanded-keys="expandedKeys"
|
||||
class="w-full max-w-md"
|
||||
variant="surface"
|
||||
>
|
||||
<AccordionItem id="1">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
使用加号/减号图标
|
||||
<AccordionIndicator>
|
||||
<IconMinus v-if="expandedKeys.includes('1')" />
|
||||
<IconPlus v-else />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>
|
||||
折叠时显示加号图标,展开时切换为减号图标。
|
||||
</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem id="2">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
使用圆形箭头图标
|
||||
<AccordionIndicator>
|
||||
<IconCircleChevronDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>
|
||||
此项使用圆形内的箭头作为指示器,旋转动画会自动应用。
|
||||
</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem id="3">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
使用双箭头图标
|
||||
<AccordionIndicator>
|
||||
<IconChevronsDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>
|
||||
此项使用双箭头图标。传入任意图标后,在条目展开时都会获得旋转动画。
|
||||
</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion class="w-full max-w-md rounded-xl bg-gray-50 dark:bg-neutral-900">
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger class="text-lg font-semibold">
|
||||
自定义标题字号
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody class="text-base text-foreground">
|
||||
通过覆盖 trigger 与 body 的 class,可以快速调整字号与颜色。
|
||||
</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger class="text-lg font-semibold">
|
||||
描边容器
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody class="rounded-lg border-2 border-border p-4 shadow-lg">
|
||||
给根容器加边框与阴影,得到描边变体的观感。
|
||||
</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-full flex-col items-center gap-8">
|
||||
<div class="w-full max-w-md space-y-2">
|
||||
<h3 class="text-sm font-medium text-muted">整个手风琴禁用</h3>
|
||||
<Accordion is-disabled class="w-full max-w-md">
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
禁用项 1
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>手风琴禁用时无法查看此内容。</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
禁用项 2
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>手风琴禁用时无法查看此内容。</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
|
||||
<div class="w-full max-w-md space-y-2">
|
||||
<h3 class="text-sm font-medium text-muted">单独禁用条目</h3>
|
||||
<Accordion class="w-full max-w-md">
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
可用项
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>此项可用,可正常展开与折叠。</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem is-disabled>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
禁用项
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>条目禁用时无法查看此内容。</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
|
||||
<AccordionItem>
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
另一可用项
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>此项同样可用,可正常切换。</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,83 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconChevronDown } from "@tabler/icons-vue";
|
||||
|
||||
const categories = [
|
||||
{
|
||||
items: [
|
||||
{
|
||||
content:
|
||||
"浏览我们的商品,将商品加入购物车并前往结账。完成购买需要提供收货与支付信息。",
|
||||
title: "如何下单?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"可以,在订单发货前你可以修改或取消。订单一旦进入处理流程,将无法再更改。",
|
||||
title: "可以修改或取消订单吗?",
|
||||
},
|
||||
],
|
||||
title: "常规",
|
||||
},
|
||||
{
|
||||
items: [
|
||||
{
|
||||
content:
|
||||
"你可以直接在官网购买许可证,选择适合的许可证类型后前往结账即可。",
|
||||
title: "如何购买许可证?",
|
||||
},
|
||||
{
|
||||
content: "标准版适用于个人或小项目;专业版包含商业使用授权与优先支持。",
|
||||
title: "标准版与专业版有什么区别?",
|
||||
},
|
||||
],
|
||||
title: "许可",
|
||||
},
|
||||
{
|
||||
items: [
|
||||
{
|
||||
content:
|
||||
"可通过网站上的联系表单联系支持团队,或直接发送邮件至 support@example.com。",
|
||||
title: "如何获取支持?",
|
||||
},
|
||||
],
|
||||
title: "支持",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-full flex-col gap-6">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h2 class="text-2xl font-bold">常见问题</h2>
|
||||
<p class="mb-4 text-lg font-medium text-muted">
|
||||
关于许可与使用,你需要了解的内容都在这里。
|
||||
</p>
|
||||
</div>
|
||||
<div v-for="category in categories" :key="category.title">
|
||||
<p class="text-md mb-2 font-medium text-muted">{{ category.title }}</p>
|
||||
<Accordion class="w-full" variant="surface">
|
||||
<AccordionItem v-for="(item, index) in category.items" :key="index">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator>
|
||||
<IconChevronDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,50 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const items = [
|
||||
{
|
||||
content:
|
||||
"了解 HeroUI 的基础知识,以及如何将其集成到你的 React 项目中。本节涵盖安装、配置和你的第一个组件。",
|
||||
title: "快速开始",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"理解 HeroUI 背后的核心概念,包括复合组件模式、使用 Tailwind CSS 进行样式设计,以及无障碍特性。",
|
||||
title: "核心概念",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"探索高级特性,例如自定义变体、主题定制,以及与 React 生态中其他库的集成。",
|
||||
title: "高级用法",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"遵循我们建议的最佳实践,使用 HeroUI 构建高性能、无障碍且易于维护的应用。",
|
||||
title: "最佳实践",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion allows-multiple-expanded class="w-full max-w-md">
|
||||
<AccordionItem v-for="(item, index) in items" :key="index">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator />
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,83 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconArrowsLeftRight,
|
||||
IconBox,
|
||||
IconChevronDown,
|
||||
IconCreditCard,
|
||||
IconReceipt,
|
||||
IconShoppingBag,
|
||||
IconWorld,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const items = [
|
||||
{
|
||||
content:
|
||||
"浏览我们的商品,将商品加入购物车并前往结账。完成购买需要提供收货与支付信息。",
|
||||
icon: IconShoppingBag,
|
||||
title: "如何下单?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"可以,在订单发货前你可以修改或取消。订单一旦进入处理流程,将无法再更改。",
|
||||
icon: IconReceipt,
|
||||
title: "可以修改或取消订单吗?",
|
||||
},
|
||||
{
|
||||
content: "我们接受主流信用卡,包括 Visa、Mastercard 和 American Express。",
|
||||
icon: IconCreditCard,
|
||||
title: "支持哪些支付方式?",
|
||||
},
|
||||
{
|
||||
content: "运费因收货地址与订单体积而异。订单满 50 美元可享受免运费。",
|
||||
icon: IconBox,
|
||||
title: "运费如何计算?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"是的,我们可向多数国家/地区发货。请查看运费说明与政策了解更多信息。",
|
||||
icon: IconWorld,
|
||||
title: "是否提供国际配送?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"若对购买不满意,可在购买后 30 天内申请退款。请联系客服团队协助处理。",
|
||||
icon: IconArrowsLeftRight,
|
||||
title: "如何申请退款?",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion class="w-full max-w-md" as="div" data-custom="accordion">
|
||||
<AccordionItem
|
||||
v-for="(item, index) in items"
|
||||
:key="index"
|
||||
as="div"
|
||||
data-custom="item"
|
||||
>
|
||||
<AccordionHeading as="div" data-custom="heading">
|
||||
<AccordionTrigger as="button" data-custom="trigger">
|
||||
<span class="me-3 size-4 shrink-0 text-muted">
|
||||
<component :is="item.icon" aria-hidden="true" />
|
||||
</span>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator>
|
||||
<IconChevronDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel as="div" data-custom="panel">
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,94 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconArrowsLeftRight,
|
||||
IconBox,
|
||||
IconChevronDown,
|
||||
IconCreditCard,
|
||||
IconReceipt,
|
||||
IconShoppingBag,
|
||||
IconWorld,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const iconMap = {
|
||||
box: IconBox,
|
||||
card: IconCreditCard,
|
||||
cart: IconShoppingBag,
|
||||
earth: IconWorld,
|
||||
receipt: IconReceipt,
|
||||
rotate: IconArrowsLeftRight,
|
||||
} as const;
|
||||
|
||||
function iconFor(key: keyof typeof iconMap) {
|
||||
return iconMap[key];
|
||||
}
|
||||
|
||||
const items = [
|
||||
{
|
||||
content:
|
||||
"浏览我们的商品,将商品加入购物车并前往结账。完成购买需要提供收货与支付信息。",
|
||||
icon: "cart",
|
||||
title: "如何下单?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"可以,在订单发货前你可以修改或取消。订单一旦进入处理流程,将无法再更改。",
|
||||
icon: "receipt",
|
||||
title: "可以修改或取消订单吗?",
|
||||
},
|
||||
{
|
||||
content: "我们接受主流信用卡,包括 Visa、Mastercard 和 American Express。",
|
||||
icon: "card",
|
||||
title: "支持哪些支付方式?",
|
||||
},
|
||||
{
|
||||
content: "运费因收货地址与订单体积而异。订单满 50 美元可享受免运费。",
|
||||
icon: "box",
|
||||
title: "运费如何计算?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"是的,我们可向多数国家/地区发货。请查看运费说明与政策了解更多信息。",
|
||||
icon: "earth",
|
||||
title: "是否提供国际配送?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"若对购买不满意,可在购买后 30 天内申请退款。请联系客服团队协助处理。",
|
||||
icon: "rotate",
|
||||
title: "如何申请退款?",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion class="w-full max-w-md" variant="surface">
|
||||
<AccordionItem v-for="(item, index) in items" :key="index">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
<span class="me-3 size-4 shrink-0 text-muted">
|
||||
<component
|
||||
:is="iconFor(item.icon as keyof typeof iconMap)"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator>
|
||||
<IconChevronDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Accordion,
|
||||
AccordionBody,
|
||||
AccordionHeading,
|
||||
AccordionIndicator,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
AccordionTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconBox,
|
||||
IconChevronDown,
|
||||
IconCreditCard,
|
||||
IconShoppingBag,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const items = [
|
||||
{
|
||||
content:
|
||||
"浏览我们的商品,将商品加入购物车并前往结账。完成购买需要提供收货与支付信息。",
|
||||
icon: IconShoppingBag,
|
||||
title: "如何下单?",
|
||||
},
|
||||
{
|
||||
content:
|
||||
"可以,在订单发货前你可以修改或取消。订单一旦进入处理流程,将无法再更改。",
|
||||
icon: IconCreditCard,
|
||||
title: "可以修改或取消订单吗?",
|
||||
},
|
||||
{
|
||||
content: "我们接受主流信用卡,包括 Visa、Mastercard 和 American Express。",
|
||||
icon: IconBox,
|
||||
title: "支持哪些支付方式?",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion hide-separator class="w-full max-w-md">
|
||||
<AccordionItem v-for="(item, index) in items" :key="index">
|
||||
<AccordionHeading>
|
||||
<AccordionTrigger>
|
||||
<span class="me-3 size-4 shrink-0 text-muted">
|
||||
<component :is="item.icon" aria-hidden="true" />
|
||||
</span>
|
||||
{{ item.title }}
|
||||
<AccordionIndicator>
|
||||
<IconChevronDown />
|
||||
</AccordionIndicator>
|
||||
</AccordionTrigger>
|
||||
</AccordionHeading>
|
||||
<AccordionPanel>
|
||||
<AccordionBody>{{ item.content }}</AccordionBody>
|
||||
</AccordionPanel>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</template>
|
||||
@@ -0,0 +1,50 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Disclosure,
|
||||
DisclosureBody,
|
||||
DisclosureContent,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconQrcode, IconBrandAppleFilled } from "@tabler/icons-vue";
|
||||
|
||||
const isExpanded = ref(true);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-md text-center">
|
||||
<Disclosure v-model:expanded="isExpanded">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button variant="secondary">
|
||||
<IconQrcode aria-hidden="true" />
|
||||
预览 HeroUI Native
|
||||
<DisclosureIndicator />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody
|
||||
class="shadow-panel flex flex-col items-center rounded-3xl bg-surface p-4 text-center"
|
||||
>
|
||||
<p class="text-sm text-muted">
|
||||
使用手机相机扫描此二维码,即可预览 HeroUI Native 组件。
|
||||
</p>
|
||||
<img
|
||||
alt="Expo Go 二维码"
|
||||
class="aspect-square w-full max-w-54 object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/images/qr-code-native.png"
|
||||
/>
|
||||
<p class="text-sm text-muted">设备需已安装 Expo。</p>
|
||||
<Button class="mt-4" variant="primary">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
在 App Store 下载
|
||||
</Button>
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Disclosure,
|
||||
DisclosureBody,
|
||||
DisclosureContent,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconShoppingBag } from "@tabler/icons-vue";
|
||||
|
||||
const isExpanded = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-sm">
|
||||
<Disclosure v-model:expanded="isExpanded">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button
|
||||
class="w-full justify-between rounded-xl border border-border/70 bg-linear-to-b from-neutral-50/90 to-white px-4 py-3 font-medium text-foreground shadow-sm ring-1 ring-black/5 hover:bg-muted/30 dark:from-neutral-900/80 dark:to-neutral-900 dark:ring-white/10"
|
||||
variant="ghost"
|
||||
>
|
||||
<span class="flex items-center gap-2">
|
||||
<IconShoppingBag class="size-4 text-muted" aria-hidden="true" />
|
||||
配送详情
|
||||
</span>
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody
|
||||
class="mt-2 rounded-xl border border-border/70 bg-surface/50 p-4 text-sm leading-relaxed text-muted dark:bg-neutral-900/50"
|
||||
>
|
||||
订单将在 2 个工作日内发货。标准配送需 3–5 天;结账时可选择加急配送。
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,109 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Disclosure,
|
||||
DisclosureBody,
|
||||
DisclosureContent,
|
||||
DisclosureGroup,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
Separator,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconQrcode,
|
||||
IconBrandAppleFilled,
|
||||
IconDeviceMobile,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const expandedKeys = ref<Array<string | number>>(["preview"]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-md">
|
||||
<div class="flex flex-col gap-4 bg-transparent p-4">
|
||||
<DisclosureGroup v-model:expanded-keys="expandedKeys">
|
||||
<Disclosure id="preview" aria-label="预览 HeroUI Native">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button
|
||||
class="w-full border-none"
|
||||
:variant="
|
||||
expandedKeys.includes('preview') ? 'secondary' : 'tertiary'
|
||||
"
|
||||
:class="{ 'bg-transparent': !expandedKeys.includes('preview') }"
|
||||
>
|
||||
<div class="flex w-full items-center justify-start gap-2">
|
||||
<IconQrcode aria-hidden="true" />
|
||||
预览 HeroUI Native
|
||||
</div>
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody
|
||||
class="mx-2 flex flex-col items-center gap-2 p-4 text-center"
|
||||
>
|
||||
<p class="text-sm text-muted">
|
||||
使用手机相机扫描此二维码,即可预览 HeroUI Native 组件。
|
||||
</p>
|
||||
<img
|
||||
alt="Expo Go 二维码"
|
||||
class="aspect-square w-full max-w-54 object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/images/qr-code-native.png"
|
||||
/>
|
||||
<p class="text-sm text-muted">设备需已安装 Expo。</p>
|
||||
<Button class="mt-4" variant="primary">
|
||||
<IconDeviceMobile aria-hidden="true" />
|
||||
在 Expo Go 预览
|
||||
</Button>
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
<Separator class="my-2" />
|
||||
<Disclosure id="download">
|
||||
<DisclosureHeading aria-label="下载 HeroUI Native">
|
||||
<DisclosureTrigger as-child>
|
||||
<Button
|
||||
class="w-full border-none"
|
||||
:variant="
|
||||
expandedKeys.includes('download') ? 'secondary' : 'tertiary'
|
||||
"
|
||||
:class="{
|
||||
'bg-transparent': !expandedKeys.includes('download'),
|
||||
}"
|
||||
>
|
||||
<div class="flex w-full items-center justify-start gap-2">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
下载应用
|
||||
</div>
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody
|
||||
class="mx-2 flex flex-col items-center gap-2 p-4 text-center"
|
||||
>
|
||||
<p class="text-sm text-muted">
|
||||
下载 HeroUI Native 应用,即可在设备上直接体验我们的移动端组件。
|
||||
</p>
|
||||
<img
|
||||
alt="App Store 二维码"
|
||||
class="aspect-square w-full max-w-54 object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/images/qr-code-native.png"
|
||||
/>
|
||||
<p class="text-sm text-muted">支持 iOS 和 Android 设备。</p>
|
||||
<Button class="mt-4" variant="primary">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
在 App Store 下载
|
||||
</Button>
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</DisclosureGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,145 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Disclosure,
|
||||
DisclosureBody,
|
||||
DisclosureContent,
|
||||
DisclosureGroup,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
Separator,
|
||||
useDisclosureGroupNavigation,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconChevronUp,
|
||||
IconChevronDown,
|
||||
IconQrcode,
|
||||
IconBrandAppleFilled,
|
||||
IconDeviceMobile,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const expandedKeys = ref<Array<string | number>>(["preview"]);
|
||||
const itemIds: Array<string | number> = ["preview", "download"];
|
||||
|
||||
const { isNextDisabled, isPrevDisabled, onNext, onPrevious } =
|
||||
useDisclosureGroupNavigation({
|
||||
expandedKeys,
|
||||
itemIds,
|
||||
onExpandedChange: (keys) => {
|
||||
expandedKeys.value = keys;
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-md">
|
||||
<div class="flex flex-col gap-4 rounded-3xl p-4">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h3 class="text-lg font-semibold">HeroUI Native</h3>
|
||||
<div class="flex gap-2">
|
||||
<Button
|
||||
aria-label="上一个折叠项"
|
||||
:is-disabled="isPrevDisabled"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="onPrevious"
|
||||
>
|
||||
<IconChevronUp class="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
<Button
|
||||
aria-label="下一个折叠项"
|
||||
:is-disabled="isNextDisabled"
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="onNext"
|
||||
>
|
||||
<IconChevronDown class="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<DisclosureGroup v-model:expanded-keys="expandedKeys">
|
||||
<Disclosure id="preview" aria-label="预览 HeroUI Native">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button
|
||||
class="w-full border-none"
|
||||
:variant="
|
||||
expandedKeys.includes('preview') ? 'secondary' : 'tertiary'
|
||||
"
|
||||
:class="{ 'bg-transparent': !expandedKeys.includes('preview') }"
|
||||
>
|
||||
<div class="flex w-full items-center justify-start gap-2">
|
||||
<IconQrcode aria-hidden="true" />
|
||||
预览 HeroUI Native
|
||||
</div>
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody
|
||||
class="mx-2 flex flex-col items-center gap-2 p-4 text-center"
|
||||
>
|
||||
<p class="text-sm text-muted">
|
||||
使用手机相机扫描此二维码,即可预览 HeroUI Native 组件。
|
||||
</p>
|
||||
<img
|
||||
alt="Expo Go 二维码"
|
||||
class="aspect-square w-full max-w-54 object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/images/qr-code-native.png"
|
||||
/>
|
||||
<p class="text-sm text-muted">设备需已安装 Expo。</p>
|
||||
<Button class="mt-4" variant="primary">
|
||||
<IconDeviceMobile aria-hidden="true" />
|
||||
在 Expo Go 预览
|
||||
</Button>
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
<Separator class="my-2" />
|
||||
<Disclosure id="download">
|
||||
<DisclosureHeading aria-label="下载 HeroUI Native">
|
||||
<DisclosureTrigger as-child>
|
||||
<Button
|
||||
class="w-full border-none"
|
||||
:variant="
|
||||
expandedKeys.includes('download') ? 'secondary' : 'tertiary'
|
||||
"
|
||||
:class="{
|
||||
'bg-transparent': !expandedKeys.includes('download'),
|
||||
}"
|
||||
>
|
||||
<div class="flex w-full items-center justify-start gap-2">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
下载应用
|
||||
</div>
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody
|
||||
class="mx-2 flex flex-col items-center gap-2 p-4 text-center"
|
||||
>
|
||||
<p class="text-sm text-muted">
|
||||
使用手机相机扫描此二维码,即可预览 HeroUI Native 组件。
|
||||
</p>
|
||||
<img
|
||||
alt="App Store 二维码"
|
||||
class="aspect-square w-full max-w-54 object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/images/qr-code-native.png"
|
||||
/>
|
||||
<p class="text-sm text-muted">支持 iOS 和 Android 设备。</p>
|
||||
<Button class="mt-4" variant="primary">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
在 App Store 下载
|
||||
</Button>
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</DisclosureGroup>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Disclosure,
|
||||
DisclosureBody,
|
||||
DisclosureContent,
|
||||
DisclosureGroup,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
Separator,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DisclosureGroup class="w-full max-w-sm rounded-xl bg-default-soft p-2">
|
||||
<Disclosure id="billing">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button class="w-full justify-between" variant="ghost">
|
||||
账单
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody class="text-sm text-muted">
|
||||
发票将于每月 1 日开具。
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
<Separator class="my-1" />
|
||||
<Disclosure id="support">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button class="w-full justify-between" variant="ghost">
|
||||
支持
|
||||
<DisclosureIndicator class="text-muted" />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent>
|
||||
<DisclosureBody class="text-sm text-muted">
|
||||
请通过 help@heroui.com 联系我们。通常会在一个工作日内回复。
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</DisclosureGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,50 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Disclosure,
|
||||
DisclosureBody,
|
||||
DisclosureContent,
|
||||
DisclosureHeading,
|
||||
DisclosureIndicator,
|
||||
DisclosureTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconQrcode, IconBrandAppleFilled } from "@tabler/icons-vue";
|
||||
|
||||
const isExpanded = ref(true);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-md text-center">
|
||||
<Disclosure v-model:expanded="isExpanded" as="div" data-custom="foo">
|
||||
<DisclosureHeading>
|
||||
<DisclosureTrigger as-child>
|
||||
<Button variant="secondary">
|
||||
<IconQrcode aria-hidden="true" />
|
||||
预览 HeroUI Native
|
||||
<DisclosureIndicator />
|
||||
</Button>
|
||||
</DisclosureTrigger>
|
||||
</DisclosureHeading>
|
||||
<DisclosureContent as="div" data-custom="bar">
|
||||
<DisclosureBody
|
||||
class="shadow-panel flex flex-col items-center rounded-3xl bg-surface p-4 text-center"
|
||||
>
|
||||
<p class="text-sm text-muted">
|
||||
使用手机相机扫描此二维码,即可预览 HeroUI Native 组件。
|
||||
</p>
|
||||
<img
|
||||
alt="Expo Go 二维码"
|
||||
class="aspect-square w-full max-w-54 object-cover"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/images/qr-code-native.png"
|
||||
/>
|
||||
<p class="text-sm text-muted">设备需已安装 Expo。</p>
|
||||
<Button class="mt-4" variant="primary">
|
||||
<IconBrandAppleFilled aria-hidden="true" />
|
||||
在 App Store 下载
|
||||
</Button>
|
||||
</DisclosureBody>
|
||||
</DisclosureContent>
|
||||
</Disclosure>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user