feat: add Typography EmptyState and Breadcrumbs

This commit is contained in:
maoyingjie
2026-10-22 13:07:13 +08:00
parent bcadbeaf8c
commit e4d817ce55
50 changed files with 3130 additions and 90 deletions
@@ -0,0 +1,68 @@
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import {
typographyVariants,
type TypographyVariants,
} from "@heroui-vue/styles";
defineOptions({ inheritAttrs: false });
type TypographyType = NonNullable<TypographyVariants["type"]>;
const props = withDefaults(
defineProps<{
type?: TypographyType;
align?: NonNullable<TypographyVariants["align"]>;
color?: NonNullable<TypographyVariants["color"]>;
weight?: TypographyVariants["weight"];
truncate?: boolean;
/** Render a different element while keeping the visual type. */
as?: string;
}>(),
{
type: "body",
align: "start",
color: "default",
truncate: false,
},
);
const defaultElementByType: Record<TypographyType, string> = {
body: "p",
"body-sm": "p",
"body-xs": "p",
code: "code",
h1: "h1",
h2: "h2",
h3: "h3",
h4: "h4",
h5: "h5",
h6: "h6",
};
const attrs = useAttrs();
const element = computed(() => props.as ?? defaultElementByType[props.type]);
const baseClass = computed(() =>
typographyVariants({
align: props.align,
color: props.color,
truncate: props.truncate,
type: props.type,
weight: props.weight,
}).base(),
);
</script>
<template>
<component
:is="element"
v-bind="attrs"
:class="baseClass"
data-slot="typography"
:data-type="type"
>
<slot />
</component>
</template>
@@ -0,0 +1,35 @@
<script setup lang="ts">
import type { TypographyVariants } from "@heroui-vue/styles";
import Typography from "./Typography.vue";
defineOptions({ inheritAttrs: false });
withDefaults(
defineProps<{
align?: NonNullable<TypographyVariants["align"]>;
color?: NonNullable<TypographyVariants["color"]>;
weight?: TypographyVariants["weight"];
truncate?: boolean;
as?: string;
}>(),
{
align: "start",
color: "default",
truncate: false,
},
);
</script>
<template>
<Typography
v-bind="$attrs"
type="code"
:align="align"
:color="color"
:weight="weight"
:truncate="truncate"
:as="as"
>
<slot />
</Typography>
</template>
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { computed } from "vue";
import type { TypographyVariants } from "@heroui-vue/styles";
import Typography from "./Typography.vue";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
level?: 1 | 2 | 3 | 4 | 5 | 6;
align?: NonNullable<TypographyVariants["align"]>;
color?: NonNullable<TypographyVariants["color"]>;
weight?: TypographyVariants["weight"];
truncate?: boolean;
as?: string;
}>(),
{
level: 1,
align: "start",
color: "default",
truncate: false,
},
);
const type = computed(
() => `h${props.level}` as NonNullable<TypographyVariants["type"]>,
);
</script>
<template>
<Typography
v-bind="$attrs"
:type="type"
:align="align"
:color="color"
:weight="weight"
:truncate="truncate"
:as="as"
>
<slot />
</Typography>
</template>
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { computed } from "vue";
import type { TypographyVariants } from "@heroui-vue/styles";
import Typography from "./Typography.vue";
defineOptions({ inheritAttrs: false });
type ParagraphSize = "base" | "sm" | "xs";
const props = withDefaults(
defineProps<{
size?: ParagraphSize;
align?: NonNullable<TypographyVariants["align"]>;
color?: NonNullable<TypographyVariants["color"]>;
weight?: TypographyVariants["weight"];
truncate?: boolean;
as?: string;
}>(),
{
size: "base",
align: "start",
color: "default",
truncate: false,
},
);
const type = computed(
() =>
(props.size === "base" ? "body" : `body-${props.size}`) as NonNullable<
TypographyVariants["type"]
>,
);
</script>
<template>
<Typography
v-bind="$attrs"
:type="type"
:align="align"
:color="color"
:weight="weight"
:truncate="truncate"
:as="as"
>
<slot />
</Typography>
</template>
@@ -0,0 +1,15 @@
<script setup lang="ts">
import { useAttrs } from "vue";
import { typographyVariants } from "@heroui-vue/styles";
defineOptions({ inheritAttrs: false });
const attrs = useAttrs();
const slots = typographyVariants();
</script>
<template>
<div v-bind="attrs" :class="slots.prose()" data-slot="prose">
<slot />
</div>
</template>