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