list_bullet_item.rs

 1use crate::{ListItem, prelude::*};
 2use gpui::{IntoElement, ParentElement, SharedString};
 3
 4#[derive(IntoElement)]
 5pub struct ListBulletItem {
 6    label: SharedString,
 7}
 8
 9impl ListBulletItem {
10    pub fn new(label: impl Into<SharedString>) -> Self {
11        Self {
12            label: label.into(),
13        }
14    }
15}
16
17impl RenderOnce for ListBulletItem {
18    fn render(self, window: &mut Window, _cx: &mut App) -> impl IntoElement {
19        let line_height = window.line_height() * 0.85;
20
21        ListItem::new("list-item")
22            .selectable(false)
23            .child(
24                h_flex()
25                    .w_full()
26                    .min_w_0()
27                    .gap_1()
28                    .items_start()
29                    .child(
30                        h_flex().h(line_height).justify_center().child(
31                            Icon::new(IconName::Dash)
32                                .size(IconSize::XSmall)
33                                .color(Color::Hidden),
34                        ),
35                    )
36                    .child(div().w_full().min_w_0().child(Label::new(self.label))),
37            )
38            .into_any_element()
39    }
40}