tablo_ui/components/primitives/
card.rs1use topcoat::{
3 Result,
4 view::{Attributes, Child, StaticClass, View, class, component, view},
5};
6
7const CARD: StaticClass = class!(
10 "flex flex-col gap-5 rounded-xl border border-border bg-card py-6",
11 "text-card-foreground shadow-sm",
12 "has-[>[data-slot=table]:first-child]:overflow-hidden",
13 "has-[>[data-slot=table]:first-child]:pt-0",
14 "has-[>[data-slot=table]:last-child]:overflow-hidden",
15 "has-[>[data-slot=table]:last-child]:pb-0",
16);
17
18#[component]
40pub async fn card(
41 #[default] mut attrs: Attributes,
42 #[default] child: Child<'_>,
43) -> Result<impl View> {
44 Ok(view! { <div class=(class!(CARD, attrs.remove("class"))) (attrs)>(child)</div> })
45}
46
47#[component]
50pub async fn card_header(
51 #[default] mut attrs: Attributes,
52 #[default] child: Child<'_>,
53) -> Result<impl View> {
54 Ok(view! {
55 <div
56 class=(class!("flex flex-col gap-1.5 px-6", attrs.remove("class")))
57 (attrs)
58 >
59 (child)
60 </div>
61 })
62}
63
64#[component]
66pub async fn card_title(
67 #[default] mut attrs: Attributes,
68 #[default] child: Child<'_>,
69) -> Result<impl View> {
70 Ok(view! {
71 <h3
72 class=(class!("text-base leading-none font-semibold", attrs.remove("class")))
73 (attrs)
74 >
75 (child)
76 </h3>
77 })
78}
79
80#[component]
82pub async fn card_description(
83 #[default] mut attrs: Attributes,
84 #[default] child: Child<'_>,
85) -> Result<impl View> {
86 Ok(view! {
87 <p
88 class=(class!("text-sm text-muted-foreground", attrs.remove("class")))
89 (attrs)
90 >
91 (child)
92 </p>
93 })
94}
95
96#[component]
98pub async fn card_content(
99 #[default] mut attrs: Attributes,
100 #[default] child: Child<'_>,
101) -> Result<impl View> {
102 Ok(view! { <div class=(class!("px-6", attrs.remove("class"))) (attrs)>(child)</div> })
103}
104
105#[component]
107pub async fn card_footer(
108 #[default] mut attrs: Attributes,
109 #[default] child: Child<'_>,
110) -> Result<impl View> {
111 Ok(view! {
112 <div
113 class=(class!("flex items-center gap-2 px-6", attrs.remove("class")))
114 (attrs)
115 >
116 (child)
117 </div>
118 })
119}