Skip to main content

things3_cloud/ui/components/
id.rs

1use crate::ids::ThingsId;
2use iocraft::prelude::*;
3
4#[derive(Default, Props)]
5pub struct IdProps<'a> {
6    pub id: Option<&'a ThingsId>,
7    pub length: usize,
8}
9
10#[component]
11pub fn Id<'a>(props: &IdProps<'a>) -> impl Into<AnyElement<'a>> {
12    let content = props.id.map_or_else(String::new, |id| {
13        id.to_string().chars().take(props.length).collect()
14    });
15
16    element! {
17        Text(content, color: Color::DarkGrey, wrap: TextWrap::NoWrap)
18    }
19    .into_any()
20}