Files
heroui-vue/apps/docs/demos/disclosure-group-controlled.vue
T
maoyingjie 896bac2cd7 fix(docs): restore button, toggle and nav demos to the pinned cn baseline
- button-group: restore all 9 cn demos incl. merge dropdown menu copy,
  custom-styles merge dropdown, sizes variant=secondary, orientation icon
  groups, full-width second group and the disabled child override
- toggle-button / toggle-button-group: restore cn copy, structure, button
  counts, theme custom-styles classes and aria-labels
- accordion-custom-styles: restore the 3-item collectibles scenario with the
  original 3dicons images, surface variant, selectors and hover motion
- disclosure-group-controlled: restore HeroUI Native / Expo copy and image
  semantics (Expo brand icon adapted to Tabler IconBrandReactNative)
- button-basic / button-loading-state: converge to baseline (console report,
  no added status paragraph) keeping the duplicate-trigger guard
- restore per-demo root gap/alignment/wrap classes instead of demo-row
- icon semantics per task card: search glyph kept on 搜索 buttons,
  rotate-back glyph restored (IconRefresh), person-search glyph restored
  (IconUserSearch); accordion item icons sized to the baseline 16px
2026-10-28 09:42:17 +08:00

147 lines
5.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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,
// 上游为 iconify `logos:expo-icon`;Tabler 无 Expo 品牌字形,按品牌图形约定取 React Native 品牌图标
IconBrandReactNative,
} 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">
<IconBrandReactNative 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" />
下载 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">
<IconBrandAppleFilled aria-hidden="true" />
在 App Store 下载
</Button>
</DisclosureBody>
</DisclosureContent>
</Disclosure>
</DisclosureGroup>
</div>
</div>
</template>