Skip to repository content62 lines · 1.7 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T04:36:17.764Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
section_items.rs
1use gpui::{IntoElement, ParentElement, Role, Styled};
2use ui::{Divider, DividerColor, prelude::*};
3
4#[derive(IntoElement)]
5pub struct SettingsSectionHeader {
6 icon: Option<IconName>,
7 label: SharedString,
8 no_padding: bool,
9}
10
11impl SettingsSectionHeader {
12 pub fn new(label: impl Into<SharedString>) -> Self {
13 Self {
14 label: label.into(),
15 icon: None,
16 no_padding: false,
17 }
18 }
19
20 pub fn icon(mut self, icon: IconName) -> Self {
21 self.icon = Some(icon);
22 self
23 }
24
25 pub fn no_padding(mut self, no_padding: bool) -> Self {
26 self.no_padding = no_padding;
27 self
28 }
29}
30
31impl RenderOnce for SettingsSectionHeader {
32 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
33 let label_text = self.label.clone();
34 let label = Label::new(self.label)
35 .size(LabelSize::Small)
36 .color(Color::Muted)
37 .buffer_font(cx);
38
39 v_flex()
40 .id(label_text.clone())
41 .role(Role::Heading)
42 .aria_level(2)
43 .aria_label(label_text)
44 .w_full()
45 .when(!self.no_padding, |this| this.px_8())
46 .gap_1p5()
47 .map(|this| {
48 if let Some(icon) = self.icon {
49 this.child(
50 h_flex()
51 .gap_1p5()
52 .child(Icon::new(icon).color(Color::Muted))
53 .child(label),
54 )
55 } else {
56 this.child(label)
57 }
58 })
59 .child(Divider::horizontal().color(DividerColor::BorderFaded))
60 }
61}
62