yew_bs/components/
shadows.rs

1use yew::prelude::*;
2#[derive(Clone, Copy, PartialEq, Debug)]
3pub enum Shadow {
4    None,
5    Shadow,
6    Small,
7    Large,
8}
9impl Shadow {
10    pub fn as_str(&self) -> &'static str {
11        match self {
12            Shadow::None => "shadow-none",
13            Shadow::Shadow => "shadow",
14            Shadow::Small => "shadow-sm",
15            Shadow::Large => "shadow-lg",
16        }
17    }
18}
19/// Props for the Shadows component
20#[derive(Properties, PartialEq)]
21pub struct ShadowsProps {
22    /// Shadow style
23    pub shadow: Shadow,
24    /// The child elements to be wrapped
25    #[prop_or_default]
26    pub children: Children,
27    /// Additional CSS classes to apply
28    #[prop_or_default]
29    pub class: Option<AttrValue>,
30}
31/// A utility component for applying Bootstrap shadow utilities
32///
33/// The Shadows component provides easy access to Bootstrap's shadow
34#[function_component(Shadows)]
35pub fn shadows(props: &ShadowsProps) -> Html {
36    let mut classes = Classes::new();
37    classes.push(props.shadow.as_str());
38    if let Some(custom_class) = &props.class {
39        classes.push(custom_class.to_string());
40    }
41    html! {
42        < div class = { classes } > { for props.children.iter() } </ div >
43    }
44}