Files
heroui-vue/apps/docs/demos/disclosure-group-controlled.vue
T
2026-10-22 18:25:08 +08:00

146 lines
5.0 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,
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>