1use gpui::prelude::*;
14use gpui::{div, px, App, IntoElement, Window};
15
16use crate::devtools::Probed;
17use crate::theme::{theme, Size};
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21enum SpaceAxis {
22 Horizontal,
23 Vertical,
24}
25
26#[derive(IntoElement)]
28pub struct Space {
29 axis: SpaceAxis,
30 size: Size,
31}
32
33impl Space {
34 pub fn x(size: Size) -> Self {
36 Space {
37 axis: SpaceAxis::Horizontal,
38 size,
39 }
40 }
41
42 pub fn y(size: Size) -> Self {
44 Space {
45 axis: SpaceAxis::Vertical,
46 size,
47 }
48 }
49}
50
51impl RenderOnce for Space {
52 fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
53 let gap = theme(cx).spacing(self.size);
54 let el = div().flex_none();
55
56 let element = match self.axis {
57 SpaceAxis::Horizontal => el.w(px(gap)),
58 SpaceAxis::Vertical => el.h(px(gap)),
59 };
60
61 element.probe("Space")
62 }
63}