use gpui::{div, prelude::*, AnyElement, SharedString, StyleRefinement};
use crate::{
component, styles,
styles::ApplyStyleOverrides,
sx::{Sx, SxStyled},
};
styles! {
pub CARD = {
root: {
display: flex,
direction: column,
gap: 6,
padding_y: 6,
radius: xl,
border: 1,
border_color: border,
background: card,
color: card_foreground,
shadow: xs,
},
header: { display: flex, direction: column, gap: 1.5, padding_x: 6 },
title: { text: base, font: semibold, line_height: 5 },
description: { text: sm, color: muted_foreground },
content: { display: flex, direction: column, gap: 4, padding_x: 6 },
footer: { display: flex, align: center, gap: 2, padding_x: 6 },
}
}
#[component]
pub fn Card(
#[children] children: Vec<AnyElement>,
#[style] style_overrides: StyleRefinement,
#[sx] sx: Sx,
) -> impl IntoElement {
div()
.sx((&CARD.root, &sx))
.children(children)
.apply_style_overrides(&style_overrides)
}
#[component]
pub fn CardHeader(
#[children] children: Vec<AnyElement>,
#[style] style_overrides: StyleRefinement,
#[sx] sx: Sx,
) -> impl IntoElement {
div()
.sx((&CARD.header, &sx))
.children(children)
.apply_style_overrides(&style_overrides)
}
#[component]
pub fn CardTitle(text: SharedString, #[sx] sx: Sx) -> impl IntoElement {
div()
.sx((&CARD.title, &sx))
.child(crate::components::bidi_text::text(text))
}
#[component]
pub fn CardDescription(text: SharedString, #[sx] sx: Sx) -> impl IntoElement {
div()
.sx((&CARD.description, &sx))
.child(crate::components::bidi_text::text(text))
}
#[component]
pub fn CardContent(
#[children] children: Vec<AnyElement>,
#[style] style_overrides: StyleRefinement,
#[sx] sx: Sx,
) -> impl IntoElement {
div()
.sx((&CARD.content, &sx))
.children(children)
.apply_style_overrides(&style_overrides)
}
#[component]
pub fn CardFooter(
#[children] children: Vec<AnyElement>,
#[style] style_overrides: StyleRefinement,
#[sx] sx: Sx,
) -> impl IntoElement {
div()
.sx((&CARD.footer, &sx))
.children(children)
.apply_style_overrides(&style_overrides)
}