textiler_core/components/surfaces/
sheet.rs1use yew::{Children, function_component, html, Html, Properties};
2
3use crate::{components::system::StylingBox, sx, theme::sx::SxValue};
4use crate::system::{ColorProp, VariantProp};
5use crate::theme::sx::Sx;
6
7#[derive(Default, Debug, Clone, PartialEq, Properties)]
8pub struct SheetProps {
9 #[prop_or_default]
10 pub sx: Sx,
11 #[prop_or_default]
12 pub variant: VariantProp,
13 #[prop_or_default]
14 pub color: ColorProp,
15 #[prop_or_default]
16 pub children: Children,
17}
18
19#[function_component]
20pub fn Sheet(props: &SheetProps) -> Html {
21 let sx = props.sx.clone().merge(sx! {
22 "bgcolor": SxValue::var("sheet", "background-color", None),
23 });
24 let SheetProps { color, variant, .. } = props;
25
26 html! {
27 <StylingBox {sx} class={yew::classes!("sheet")} {color} {variant}>
28 {for props.children.clone()}
29 </StylingBox>
30 }
31}
32
33#[cfg(test)]
34mod tests {
35 use yew::{html, ServerRenderer};
36
37 use super::*;
38
39 #[tokio::test]
40 async fn render_sheet() {
41 #[function_component]
42 fn Test() -> Html {
43 html! {
44 <Sheet>
45
46 </Sheet>
47 }
48 }
49
50 let rendered = ServerRenderer::<Test>::new().render().await;
51 println!("{rendered:?}")
52 }
53}