1use gpui::prelude::*;
4use gpui::{div, px, AnyElement, App, IntoElement, Window};
5
6#[derive(IntoElement)]
8pub struct Wrap {
9 children: Vec<AnyElement>,
10 spacing: f32,
11}
12
13impl Wrap {
14 pub fn new() -> Self {
15 Wrap {
16 children: Vec::new(),
17 spacing: 8.0,
18 }
19 }
20
21 pub fn spacing(mut self, spacing: f32) -> Self {
23 self.spacing = spacing;
24 self
25 }
26}
27
28impl Default for Wrap {
29 fn default() -> Self {
30 Wrap::new()
31 }
32}
33
34impl ParentElement for Wrap {
35 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
36 self.children.extend(elements);
37 }
38}
39
40impl RenderOnce for Wrap {
41 fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
42 div()
43 .flex()
44 .flex_row()
45 .flex_wrap()
46 .gap(px(self.spacing))
47 .children(self.children)
48 }
49}