feat: add Badge and Alert components

This commit is contained in:
maoyingjie
2026-10-21 21:32:40 +08:00
parent 3515a47f5e
commit 4f43789f60
41 changed files with 2422 additions and 17 deletions
+70
View File
@@ -0,0 +1,70 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
/* Base alert styles */
.hv-alert {
@apply flex w-full flex-row items-start justify-start gap-4 bg-surface px-4 py-3 shadow-surface;
border-radius: min(32px, var(--radius-3xl));
}
/* Alert elements */
.hv-alert__content {
@apply flex h-full grow flex-col items-start;
}
.hv-alert__indicator {
@apply flex items-center justify-center p-1 select-none;
[data-slot="alert-default-icon"] {
@apply box-content size-4;
}
}
.hv-alert__title {
@apply text-sm leading-6 font-medium;
}
.hv-alert__description {
@apply text-sm text-muted;
}
/* Variant modifiers */
.hv-alert--default .hv-alert__indicator {
@apply text-foreground;
}
.hv-alert--default .hv-alert__title {
@apply text-foreground;
}
.hv-alert--accent .hv-alert__indicator {
@apply text-accent-soft-foreground;
}
.hv-alert--accent .hv-alert__title {
@apply text-accent-soft-foreground;
}
.hv-alert--success .hv-alert__indicator {
@apply text-success-soft-foreground;
}
.hv-alert--success .hv-alert__title {
@apply text-success-soft-foreground;
}
.hv-alert--warning .hv-alert__indicator {
@apply text-warning-soft-foreground;
}
.hv-alert--warning .hv-alert__title {
@apply text-warning-soft-foreground;
}
.hv-alert--danger .hv-alert__indicator {
@apply text-danger-soft-foreground;
}
.hv-alert--danger .hv-alert__title {
@apply text-danger-soft-foreground;
}
+148
View File
@@ -0,0 +1,148 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
/* Base styles */
.hv-badge {
@apply inline-flex shrink-0 items-center justify-center gap-0.5 font-medium;
/* Default size (matches --md) */
@apply min-h-7 min-w-7 rounded-3xl text-xs leading-[1.34];
/* Default tokens */
--badge-bg: var(--default);
--badge-fg: var(--default-foreground);
--badge-border: var(--background);
background-color: var(--badge-bg);
color: var(--badge-fg);
border: 1px solid var(--badge-border);
background-clip: padding-box;
}
.hv-badge__label {
@apply px-0.5;
}
.hv-badge-anchor {
@apply relative inline-flex shrink-0;
}
/* Size variants */
.hv-badge--lg {
@apply min-h-8 min-w-8 rounded-2xl text-sm leading-[1.43];
}
.hv-badge--md {
/* No styles as this is the default size */
}
.hv-badge--sm {
@apply min-h-4 min-w-4 rounded-xl text-[10px] leading-[1.34];
}
/* Color variants - set foreground color */
.hv-badge--accent {
--badge-fg: var(--accent-soft-foreground);
}
.hv-badge--default {
--badge-fg: var(--default-foreground);
}
.hv-badge--success {
--badge-fg: var(--success-soft-foreground);
}
.hv-badge--warning {
--badge-fg: var(--warning-soft-foreground);
}
.hv-badge--danger {
--badge-fg: var(--danger-soft-foreground);
}
/* Variant styles */
.hv-badge--primary {
/* Solid background - compound variants below handle bg/fg per color */
}
.hv-badge--secondary {
/* Default background with colored text - base behavior */
}
.hv-badge--soft {
/* Soft/muted background - compound variants below handle bg/fg per color */
}
/* Placement variants */
.hv-badge--top-right {
@apply absolute top-0 right-0;
transform: translate(25%, -25%);
}
.hv-badge--top-left {
@apply absolute top-0 left-0;
transform: translate(-25%, -25%);
}
.hv-badge--bottom-right {
@apply absolute right-0 bottom-0;
transform: translate(25%, 25%);
}
.hv-badge--bottom-left {
@apply absolute bottom-0 left-0;
transform: translate(-25%, 25%);
}
/* Compound variants - Primary (solid background) */
.hv-badge--primary.hv-badge--accent {
--badge-bg: var(--accent);
--badge-fg: var(--accent-foreground);
}
.hv-badge--primary.hv-badge--default {
--badge-bg: var(--default);
--badge-fg: var(--default-foreground);
}
.hv-badge--primary.hv-badge--success {
--badge-bg: var(--success);
--badge-fg: var(--success-foreground);
}
.hv-badge--primary.hv-badge--warning {
--badge-bg: var(--warning);
--badge-fg: var(--warning-foreground);
}
.hv-badge--primary.hv-badge--danger {
--badge-bg: var(--danger);
--badge-fg: var(--danger-foreground);
}
/* Compound variants - Soft (muted background) */
.hv-badge--soft.hv-badge--accent {
--badge-bg: var(--accent-soft);
--badge-fg: var(--accent-soft-foreground);
}
.hv-badge--soft.hv-badge--default {
--badge-bg: var(--default-soft);
--badge-fg: var(--default-soft-foreground);
}
.hv-badge--soft.hv-badge--success {
--badge-bg: var(--success-soft);
--badge-fg: var(--success-soft-foreground);
}
.hv-badge--soft.hv-badge--warning {
--badge-bg: var(--warning-soft);
--badge-fg: var(--warning-soft-foreground);
}
.hv-badge--soft.hv-badge--danger {
--badge-bg: var(--danger-soft);
--badge-fg: var(--danger-soft-foreground);
}