use crate::utils::cn;
use dioxus::prelude::*;
#[component]
pub fn Card(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([
Some("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm"),
class.as_deref(),
]);
rsx! {
div {
"data-slot": "card",
class: "{classes}",
{children}
}
}
}
#[component]
pub fn CardHeader(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([
Some("grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-[data-slot=card-action]:grid-cols-[1fr_auto] [&.border-b]:pb-6"),
class.as_deref(),
]);
rsx! {
div {
"data-slot": "card-header",
class: "{classes}",
{children}
}
}
}
#[component]
pub fn CardTitle(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([Some("leading-none font-semibold"), class.as_deref()]);
rsx! {
div {
"data-slot": "card-title",
class: "{classes}",
{children}
}
}
}
#[component]
pub fn CardDescription(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([Some("text-muted-foreground text-sm"), class.as_deref()]);
rsx! {
div {
"data-slot": "card-description",
class: "{classes}",
{children}
}
}
}
#[component]
pub fn CardAction(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([
Some("col-start-2 row-span-2 row-start-1 self-start justify-self-end"),
class.as_deref(),
]);
rsx! {
div {
"data-slot": "card-action",
class: "{classes}",
{children}
}
}
}
#[component]
pub fn CardContent(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([Some("px-6"), class.as_deref()]);
rsx! {
div {
"data-slot": "card-content",
class: "{classes}",
{children}
}
}
}
#[component]
pub fn CardFooter(
class: Option<String>,
children: Element,
) -> Element {
let classes = cn([
Some("flex items-center px-6 [&.border-t]:pt-6"),
class.as_deref(),
]);
rsx! {
div {
"data-slot": "card-footer",
class: "{classes}",
{children}
}
}
}