yew_bs/components/
vertical_align.rs1use 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#[derive(Properties, PartialEq)]
25pub struct VerticalAlignProps {
26 pub align: VerticalAlignType,
28 #[prop_or_default]
30 pub children: Children,
31 #[prop_or_default]
33 pub class: Option<AttrValue>,
34}
35#[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}