feat: add Badge and Alert components
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -23,6 +23,8 @@
|
||||
@import "./components/separator.css" layer(components);
|
||||
@import "./components/kbd.css" layer(components);
|
||||
@import "./components/chip.css" layer(components);
|
||||
@import "./components/badge.css" layer(components);
|
||||
@import "./components/alert.css" layer(components);
|
||||
/* The Vue Switch uses Reka's native button for its clickable content. */
|
||||
@layer components {
|
||||
.hv-switch:has(.hv-switch__content:focus-visible) .hv-switch__control {
|
||||
|
||||
@@ -393,3 +393,108 @@ export const chipVariants = tv({
|
||||
});
|
||||
|
||||
export type ChipVariants = VariantProps<typeof chipVariants>;
|
||||
|
||||
export const badgeVariants = tv({
|
||||
defaultVariants: {
|
||||
color: "default",
|
||||
placement: "top-right",
|
||||
size: "md",
|
||||
variant: "primary",
|
||||
},
|
||||
slots: {
|
||||
anchor: "hv-badge-anchor",
|
||||
base: "hv-badge",
|
||||
label: "hv-badge__label",
|
||||
},
|
||||
variants: {
|
||||
color: {
|
||||
accent: {
|
||||
base: "hv-badge--accent",
|
||||
},
|
||||
danger: {
|
||||
base: "hv-badge--danger",
|
||||
},
|
||||
default: {
|
||||
base: "hv-badge--default",
|
||||
},
|
||||
success: {
|
||||
base: "hv-badge--success",
|
||||
},
|
||||
warning: {
|
||||
base: "hv-badge--warning",
|
||||
},
|
||||
},
|
||||
placement: {
|
||||
"bottom-left": {
|
||||
base: "hv-badge--bottom-left",
|
||||
},
|
||||
"bottom-right": {
|
||||
base: "hv-badge--bottom-right",
|
||||
},
|
||||
"top-left": {
|
||||
base: "hv-badge--top-left",
|
||||
},
|
||||
"top-right": {
|
||||
base: "hv-badge--top-right",
|
||||
},
|
||||
},
|
||||
size: {
|
||||
lg: {
|
||||
base: "hv-badge--lg",
|
||||
},
|
||||
md: {
|
||||
base: "hv-badge--md",
|
||||
},
|
||||
sm: {
|
||||
base: "hv-badge--sm",
|
||||
},
|
||||
},
|
||||
variant: {
|
||||
primary: {
|
||||
base: "hv-badge--primary",
|
||||
},
|
||||
secondary: {
|
||||
base: "hv-badge--secondary",
|
||||
},
|
||||
soft: {
|
||||
base: "hv-badge--soft",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type BadgeVariants = VariantProps<typeof badgeVariants>;
|
||||
|
||||
export const alertVariants = tv({
|
||||
defaultVariants: {
|
||||
status: "default",
|
||||
},
|
||||
slots: {
|
||||
base: "hv-alert",
|
||||
content: "hv-alert__content",
|
||||
description: "hv-alert__description",
|
||||
indicator: "hv-alert__indicator",
|
||||
title: "hv-alert__title",
|
||||
},
|
||||
variants: {
|
||||
status: {
|
||||
accent: {
|
||||
base: "hv-alert--accent",
|
||||
},
|
||||
danger: {
|
||||
base: "hv-alert--danger",
|
||||
},
|
||||
default: {
|
||||
base: "hv-alert--default",
|
||||
},
|
||||
success: {
|
||||
base: "hv-alert--success",
|
||||
},
|
||||
warning: {
|
||||
base: "hv-alert--warning",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type AlertVariants = VariantProps<typeof alertVariants>;
|
||||
|
||||
Reference in New Issue
Block a user