Skip to main content

things3_cloud/ui/components/
details_container.rs

1use iocraft::prelude::*;
2
3/// Renders a left border rail with element content to its right.
4///
5/// ```text
6/// │ line 0
7/// │ line 1
8/// └ line 2
9/// ```
10
11#[derive(Props, Default)]
12pub struct DetailsContainerProps<'a> {
13    pub children: Vec<AnyElement<'a>>,
14}
15
16#[component]
17pub fn DetailsContainer<'a>(props: &mut DetailsContainerProps<'a>) -> impl Into<AnyElement<'a>> {
18    let border = BorderCharacters {
19        top_left: ' ',
20        top_right: ' ',
21        bottom_left: '└',
22        bottom_right: ' ',
23        left: '│',
24        right: ' ',
25        top: ' ',
26        bottom: ' ',
27    };
28
29    element! {
30        View(flex_direction: FlexDirection::Row, gap: 1) {
31            View(
32                width: 1,
33                border_style: BorderStyle::Custom(border),
34                border_edges: Some(Edges::Left | Edges::Bottom),
35                border_color: Color::DarkGrey,
36            ) {}
37            View(flex_direction: FlexDirection::Column) {
38                #(props.children.iter_mut())
39            }
40        }
41    }
42}