yew_bs/components/
vertical_align.rs

1use yew::prelude::*;
2#[derive(Clone, Copy, PartialEq, Debug)]
3pub enum VerticalAlignType {
4    Baseline,
5    Top,
6    Middle,
7    Bottom,
8    TextTop,
9    TextBottom,
10}
11impl VerticalAlignType {
12    pub fn as_str(&self) -> &'static str {
13        match self {
14            VerticalAlignType::Baseline => "align-baseline",
15            VerticalAlignType::Top => "align-top",
16            VerticalAlignType::Middle => "align-middle",
17            VerticalAlignType::Bottom => "align-bottom",
18            VerticalAlignType::TextTop => "align-text-top",
19            VerticalAlignType::TextBottom => "align-text-bottom",
20        }
21    }
22}
23/// Props for the VerticalAlign component
24#[derive(Properties, PartialEq)]
25pub struct VerticalAlignProps {
26    /// Vertical alignment to apply
27    pub align: VerticalAlignType,
28    /// The child elements to be aligned
29    #[prop_or_default]
30    pub children: Children,
31    /// Additional CSS classes to apply
32    #[prop_or_default]
33    pub class: Option<AttrValue>,
34}
35/// A utility component for applying Bootstrap vertical alignment utilities
36///
37/// The VerticalAlign component provides easy access to Bootstrap's vertical
38#[function_component(VerticalAlign)]
39pub fn vertical_align(props: &VerticalAlignProps) -> Html {
40    let mut classes = Classes::new();
41    classes.push(props.align.as_str());
42    if let Some(custom_class) = &props.class {
43        classes.push(custom_class.to_string());
44    }
45    html! {
46        < div class = { classes } > { for props.children.iter() } </ div >
47    }
48}