use iocraft::prelude::*; use crate::{common::shown_title, ids::ThingsId, ui::components::id::Id}; #[derive(Default, Props)] pub struct HeaderProps<'a> { pub uuid: Option<&'a ThingsId>, pub title: Option<&'a str>, pub id_prefix_len: usize, pub icon: Option<&'a str>, } #[component] pub fn Header<'a>(props: &HeaderProps<'a>) -> impl Into> { let (Some(uuid), Some(title)) = (props.uuid, props.title) else { return element!(Fragment).into_any(); }; let text = if let Some(icon) = props.icon { format!("{} {}", icon, shown_title(title)) } else { shown_title(title) }; element! { View(flex_direction: FlexDirection::Row, gap: 1) { Id(id: uuid, length: props.id_prefix_len) Text(content: text, wrap: TextWrap::NoWrap, weight: Weight::Bold) } } .into_any() }