1use hypersig::html::{El, span};
4use hypersig::style::Style;
5use hypersig::style::value::{
6 AlignItems, BorderStyle, Color, Display, FontWeight, LineHeight, WhiteSpace, px, rem,
7};
8
9use crate::token;
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13#[non_exhaustive]
14pub enum BadgeVariant {
15 Default,
17 Secondary,
19 Destructive,
21 Outline,
23}
24
25#[must_use]
43pub fn badge<S>(variant: BadgeVariant) -> El<S> {
44 let (background, text, border) = match variant {
45 BadgeVariant::Default => (
46 token::primary().var(),
47 token::primary_foreground().var(),
48 Color::TRANSPARENT,
49 ),
50 BadgeVariant::Secondary => (
51 token::secondary().var(),
52 token::secondary_foreground().var(),
53 Color::TRANSPARENT,
54 ),
55 BadgeVariant::Destructive => (
56 token::destructive().var(),
57 token::destructive_foreground().var(),
58 Color::TRANSPARENT,
59 ),
60 BadgeVariant::Outline => (
61 Color::TRANSPARENT,
62 token::foreground().var(),
63 token::border().var(),
64 ),
65 };
66 span().css(
67 Style::new()
68 .display(Display::InlineFlex)
69 .align_items(AlignItems::Center)
70 .gap(rem(0.25))
71 .padding_block(rem(0.125))
72 .padding_inline(rem(0.5))
73 .border_width(px(1))
74 .border_style(BorderStyle::Solid)
75 .border_color(border)
76 .border_radius(px(6))
77 .background_color(background)
78 .color(text)
79 .font_size(rem(0.75))
80 .line_height(LineHeight::Length(rem(1)))
81 .font_weight(FontWeight::Number(500.0))
82 .white_space(WhiteSpace::Nowrap),
83 )
84}