layoutcss_parser/components/
box.rs

1use indoc::formatdoc;
2use std::collections::HashSet;
3
4const BOX_STYLE: &str = r#"
5  box-l{
6    box-sizing: border-box;
7    display: block;
8    max-inline-size:fit-content;
9  }
10"#;
11
12const BOX_GROW_STYLE: &str = r#"
13  box-l[layout~="grow"] > *{
14    width: 100%;
15  }
16"#;
17
18fn box_max_width_style(value: &str) -> String {
19    formatdoc!(
20        r#"
21        box-l[layout~="max-width:{value}"]{{
22            max-inline-size:{value};
23        }}
24        "#,
25    )
26}
27
28pub fn box_css(max_width: Option<&str>, grow: bool, set: &mut HashSet<String>) {
29    set.insert(BOX_STYLE.to_string());
30    if let Some(value) = max_width {
31        set.insert(box_max_width_style(value));
32    }
33    if grow {
34        set.insert(BOX_GROW_STYLE.to_string());
35    }
36}