Skip to main content

things3_cloud/ui/components/
id.rs

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