1use ui::prelude::*;
2
3#[derive(IntoElement)]
4pub struct ProfileModalHeader {
5 label: SharedString,
6 icon: Option<IconName>,
7}
8
9impl ProfileModalHeader {
10 pub fn new(label: impl Into<SharedString>, icon: Option<IconName>) -> Self {
11 Self {
12 label: label.into(),
13 icon,
14 }
15 }
16}
17
18impl RenderOnce for ProfileModalHeader {
19 fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
20 let mut container = h_flex()
21 .w_full()
22 .px(DynamicSpacing::Base12.rems(cx))
23 .pt(DynamicSpacing::Base08.rems(cx))
24 .pb(DynamicSpacing::Base04.rems(cx))
25 .rounded_t_sm()
26 .gap_1p5();
27
28 if let Some(icon) = self.icon {
29 container = container.child(Icon::new(icon).size(IconSize::XSmall).color(Color::Muted));
30 }
31
32 container.child(
33 h_flex().gap_1().overflow_x_hidden().child(
34 div()
35 .max_w_96()
36 .overflow_x_hidden()
37 .text_ellipsis()
38 .child(Headline::new(self.label).size(HeadlineSize::XSmall)),
39 ),
40 )
41 }
42}