yew_bs/components/
text_truncation.rs

1use yew::prelude::*;
2#[derive(Properties, PartialEq)]
3pub struct TextTruncationProps {
4    #[prop_or_default]
5    pub children: Children,
6    #[prop_or_default]
7    pub class: Option<AttrValue>,
8    #[prop_or("span".into())]
9    pub tag: AttrValue,
10}
11#[function_component(TextTruncation)]
12pub fn text_truncation(props: &TextTruncationProps) -> Html {
13    let mut classes = Classes::new();
14    classes.push("text-truncate");
15    if let Some(custom_class) = &props.class {
16        classes.push(custom_class.to_string());
17    }
18    let tag = props.tag.clone();
19    html! {
20        <@ { tag.to_string() } class = { classes } > { for props.children.iter() } </@>
21    }
22}