soma-ui 0.1.1

A Leptos 0.8 component library: 160+ accessible UI components, blocks, charts, and a ChartDB-style schema diagram — with a prebuilt stylesheet.
Documentation
use leptos::prelude::*;

#[derive(Debug, Clone, PartialEq, Default)]
pub enum AlertVariant {
    #[default]
    Default,
    Destructive,
    Success,
    Warning,
    Info,
}

#[component]
pub fn Alert(
    #[prop(default = AlertVariant::Default)] variant: AlertVariant,
    #[prop(default = String::new())] class: String,
    children: Children,
) -> impl IntoView {
    let variant_class = match variant {
        AlertVariant::Default => "border-border text-foreground",
        AlertVariant::Destructive => "border-destructive/50 text-destructive",
        AlertVariant::Success => "border-success/50 text-success-foreground bg-success/10",
        AlertVariant::Warning => "border-yellow-500/50 text-yellow-500 bg-yellow-500/10",
        AlertVariant::Info => "border-blue-500/50 text-blue-500 bg-blue-500/10",
    };
    let combined = format!(
        "relative w-full rounded-lg border p-4 shadow-elev-sm {} {}",
        variant_class, class
    );
    view! { <div role="alert" class=combined>{children()}</div> }
}

#[component]
pub fn AlertTitle(
    #[prop(default = String::new())] class: String,
    children: Children,
) -> impl IntoView {
    let combined = format!("mb-1 font-medium leading-none tracking-tight {}", class);
    view! { <h5 class=combined>{children()}</h5> }
}

#[component]
pub fn AlertDescription(
    #[prop(default = String::new())] class: String,
    children: Children,
) -> impl IntoView {
    let combined = format!("text-sm text-muted-foreground {}", class);
    view! { <div class=combined>{children()}</div> }
}