feat: add Badge and Alert components
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Alert,
|
||||
AlertContent,
|
||||
AlertDescription,
|
||||
AlertIndicator,
|
||||
AlertTitle,
|
||||
Button,
|
||||
CloseButton,
|
||||
Spinner,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid w-full max-w-xl gap-4">
|
||||
<!-- 默认 — 一般信息 -->
|
||||
<Alert>
|
||||
<AlertIndicator />
|
||||
<AlertContent>
|
||||
<AlertTitle>新功能已上线</AlertTitle>
|
||||
<AlertDescription>
|
||||
查看我们的最新更新,包括深色模式支持与改进的无障碍体验。
|
||||
</AlertDescription>
|
||||
</AlertContent>
|
||||
</Alert>
|
||||
|
||||
<!-- 强调 — 重要信息含操作 -->
|
||||
<Alert status="accent">
|
||||
<AlertIndicator />
|
||||
<AlertContent>
|
||||
<AlertTitle>有可用更新</AlertTitle>
|
||||
<AlertDescription>
|
||||
应用有新版本可用。请刷新页面以获取最新功能与问题修复。
|
||||
</AlertDescription>
|
||||
<Button class="mt-2 sm:hidden" size="sm" variant="primary">刷新</Button>
|
||||
</AlertContent>
|
||||
<Button class="hidden sm:block" size="sm" variant="primary">刷新</Button>
|
||||
</Alert>
|
||||
|
||||
<!-- 危险 — 错误与排查步骤 -->
|
||||
<Alert status="danger">
|
||||
<AlertIndicator />
|
||||
<AlertContent>
|
||||
<AlertTitle>无法连接到服务器</AlertTitle>
|
||||
<AlertDescription>
|
||||
当前遇到连接问题,请尝试以下操作:
|
||||
<ul class="mt-2 list-inside list-disc space-y-1 text-sm">
|
||||
<li>检查网络连接</li>
|
||||
<li>刷新页面</li>
|
||||
<li>清除浏览器缓存</li>
|
||||
</ul>
|
||||
</AlertDescription>
|
||||
<Button class="mt-2 sm:hidden" size="sm" variant="danger">重试</Button>
|
||||
</AlertContent>
|
||||
<Button class="hidden sm:block" size="sm" variant="danger">重试</Button>
|
||||
</Alert>
|
||||
|
||||
<!-- 无描述 -->
|
||||
<Alert status="success">
|
||||
<AlertIndicator />
|
||||
<AlertContent>
|
||||
<AlertTitle>个人资料已更新</AlertTitle>
|
||||
</AlertContent>
|
||||
<CloseButton />
|
||||
</Alert>
|
||||
|
||||
<!-- 自定义指示器 — 加载中 -->
|
||||
<Alert status="accent">
|
||||
<AlertIndicator>
|
||||
<Spinner size="sm" />
|
||||
</AlertIndicator>
|
||||
<AlertContent>
|
||||
<AlertTitle>正在处理你的请求</AlertTitle>
|
||||
<AlertDescription>
|
||||
正在同步你的数据,请稍候,这可能需要一点时间。
|
||||
</AlertDescription>
|
||||
</AlertContent>
|
||||
</Alert>
|
||||
|
||||
<!-- 无关闭按钮 -->
|
||||
<Alert status="warning">
|
||||
<AlertIndicator />
|
||||
<AlertContent>
|
||||
<AlertTitle>计划维护</AlertTitle>
|
||||
<AlertDescription>
|
||||
我们将于 UTC 时间 3 月 15 日(周日)凌晨 2:00 至上午 6:00
|
||||
进行计划维护,期间服务将暂时不可用。
|
||||
</AlertDescription>
|
||||
</AlertContent>
|
||||
</Alert>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Alert,
|
||||
AlertContent,
|
||||
AlertDescription,
|
||||
AlertIndicator,
|
||||
AlertTitle,
|
||||
Button,
|
||||
CloseButton,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full max-w-xl">
|
||||
<Alert
|
||||
class="relative overflow-hidden rounded-xl border border-warning/20 bg-linear-to-br from-warning/10 via-surface to-surface-secondary shadow-sm dark:border-warning/30 dark:from-warning/15 dark:via-surface dark:to-warning/5"
|
||||
status="warning"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute -top-8 -right-8 size-28 rounded-full bg-warning/15 blur-2xl dark:bg-warning/25"
|
||||
/>
|
||||
<AlertIndicator class="relative text-warning" />
|
||||
<AlertContent class="relative">
|
||||
<AlertTitle>支付方式即将过期</AlertTitle>
|
||||
<AlertDescription>
|
||||
您的 Visa 卡(尾号 4242)将于 3 月 28 日过期。请更新账单信息,以免影响
|
||||
Pro 订阅。
|
||||
</AlertDescription>
|
||||
<Button class="mt-3 sm:hidden" size="sm" variant="tertiary">
|
||||
更新账单
|
||||
</Button>
|
||||
</AlertContent>
|
||||
<Button
|
||||
class="relative hidden shrink-0 sm:inline-flex"
|
||||
size="sm"
|
||||
variant="tertiary"
|
||||
>
|
||||
更新账单
|
||||
</Button>
|
||||
<CloseButton class="relative" />
|
||||
</Alert>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const GREEN_AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
const ORANGE_AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg";
|
||||
const BLUE_AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="GREEN_AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="danger" size="sm">5</Badge>
|
||||
</BadgeAnchor>
|
||||
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="ORANGE_AVATAR_URL" />
|
||||
<AvatarFallback>AB</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="accent" size="sm">新</Badge>
|
||||
</BadgeAnchor>
|
||||
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="BLUE_AVATAR_URL" />
|
||||
<AvatarFallback>CD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="success" placement="bottom-right" size="sm" />
|
||||
</BadgeAnchor>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
|
||||
const colors = ["default", "accent", "success", "warning", "danger"] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<BadgeAnchor v-for="color in colors" :key="color">
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge :color="color" size="sm" />
|
||||
</BadgeAnchor>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage
|
||||
alt="凯特·威尔逊"
|
||||
src="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg"
|
||||
/>
|
||||
<AvatarFallback>KW</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge
|
||||
class="min-w-5 font-semibold tabular-nums"
|
||||
color="accent"
|
||||
size="sm"
|
||||
variant="soft"
|
||||
>
|
||||
5
|
||||
</Badge>
|
||||
</BadgeAnchor>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
|
||||
const colors = ["accent", "success", "warning", "danger"] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<BadgeAnchor v-for="color in colors" :key="color">
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge :color="color" placement="bottom-right" size="sm" />
|
||||
</BadgeAnchor>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
|
||||
const placements = [
|
||||
"top-right",
|
||||
"top-left",
|
||||
"bottom-right",
|
||||
"bottom-left",
|
||||
] as const;
|
||||
|
||||
const PLACEMENT_LABELS: Record<(typeof placements)[number], string> = {
|
||||
"bottom-left": "左下",
|
||||
"bottom-right": "右下",
|
||||
"top-left": "左上",
|
||||
"top-right": "右上",
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-8">
|
||||
<div
|
||||
v-for="placement in placements"
|
||||
:key="placement"
|
||||
class="flex flex-col items-center gap-2"
|
||||
>
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="accent" :placement="placement" size="sm" />
|
||||
</BadgeAnchor>
|
||||
<span class="text-xs text-muted">{{ PLACEMENT_LABELS[placement] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
|
||||
const sizes = ["sm", "md", "lg"] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<BadgeAnchor v-for="size in sizes" :key="size">
|
||||
<Avatar :size="size">
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="danger" :size="size">5</Badge>
|
||||
</BadgeAnchor>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
Separator,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
|
||||
const variants = ["primary", "secondary", "soft"] as const;
|
||||
|
||||
const VARIANT_LABELS: Record<(typeof variants)[number], string> = {
|
||||
primary: "主色",
|
||||
secondary: "次色",
|
||||
soft: "柔和",
|
||||
};
|
||||
|
||||
const colors = ["accent", "default", "success", "warning", "danger"] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-8">
|
||||
<template v-for="(variant, index) in variants" :key="variant">
|
||||
<div class="flex flex-col gap-4">
|
||||
<h3 class="text-sm font-semibold text-muted">
|
||||
{{ VARIANT_LABELS[variant] }}
|
||||
</h3>
|
||||
<div class="flex items-center gap-6">
|
||||
<BadgeAnchor v-for="color in colors" :key="color">
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge :color="color" size="sm" :variant="variant">5</Badge>
|
||||
</BadgeAnchor>
|
||||
</div>
|
||||
</div>
|
||||
<Separator v-if="index < variants.length - 1" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
Badge,
|
||||
BadgeAnchor,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconBell } from "@tabler/icons-vue";
|
||||
|
||||
const AVATAR_URL =
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="danger" size="sm">5</Badge>
|
||||
</BadgeAnchor>
|
||||
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="danger" size="sm">新</Badge>
|
||||
</BadgeAnchor>
|
||||
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="danger" size="sm">99+</Badge>
|
||||
</BadgeAnchor>
|
||||
|
||||
<BadgeAnchor>
|
||||
<Avatar>
|
||||
<AvatarImage alt="头像" :src="AVATAR_URL" />
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
<Badge color="accent" size="sm">
|
||||
<IconBell class="size-2.5" aria-hidden="true" />
|
||||
</Badge>
|
||||
</BadgeAnchor>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user