1use gpui::AnyElement;
2use smallvec::SmallVec;
3
4use crate::{ListHeader, prelude::*};
5
6/// A group of settings.
7#[derive(IntoElement)]
8pub struct SettingsGroup {
9 header: SharedString,
10 children: SmallVec<[AnyElement; 2]>,
11}
12
13impl SettingsGroup {
14 pub fn new(header: impl Into<SharedString>) -> Self {
15 Self {
16 header: header.into(),
17 children: SmallVec::new(),
18 }
19 }
20}
21
22impl ParentElement for SettingsGroup {
23 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
24 self.children.extend(elements)
25 }
26}
27
28impl RenderOnce for SettingsGroup {
29 fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
30 v_flex()
31 .p_1()
32 .gap_2()
33 .child(ListHeader::new(self.header))
34 .children(self.children)
35 }
36}