leptos_bootstrap/v5/
col.rs

1use leptos::prelude::*;
2
3#[component]
4pub fn Col<'a>(
5    #[prop(optional, into)] xs: u8,
6    #[prop(optional, into)] sm: u8,
7    #[prop(optional, into)] md: u8,
8    #[prop(optional, into)] lg: u8,
9    #[prop(optional, into)] xl: u8,
10    #[prop(optional, into)] xxl: u8,
11    #[prop(optional, into)] class: &'a str,
12    children: Children,
13) -> impl IntoView {
14    let mut combined_class = "".to_string();
15    if xs > 0 {
16        combined_class.push_str(&format!(" col-xs-{}", sm));
17    }
18    if sm > 0 {
19        combined_class.push_str(&format!(" col-sm-{}", sm));
20    }
21    if md > 0 {
22        combined_class.push_str(&format!(" col-md-{}", md));
23    }
24    if lg > 0 {
25        combined_class.push_str(&format!(" col-lg-{}", lg));
26    }
27    if xl > 0 {
28        combined_class.push_str(&format!(" col-xl-{}", lg));
29    }
30    if xxl > 0 {
31        combined_class.push_str(&format!(" col-xxl-{}", lg));
32    }
33    if !class.is_empty() {
34        combined_class.push(' ');
35        combined_class.push_str(class.trim());
36    }
37    view! { <div class=combined_class>{children()}</div> }
38}