use gpui::prelude::*;
use gpui::{div, px, App, IntoElement, Window};
use crate::theme::{theme, Size};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum SpaceAxis {
Horizontal,
Vertical,
}
#[derive(IntoElement)]
pub struct Space {
axis: SpaceAxis,
size: Size,
}
impl Space {
pub fn x(size: Size) -> Self {
Space {
axis: SpaceAxis::Horizontal,
size,
}
}
pub fn y(size: Size) -> Self {
Space {
axis: SpaceAxis::Vertical,
size,
}
}
}
impl RenderOnce for Space {
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
let gap = theme(cx).spacing(self.size);
let el = div().flex_none();
match self.axis {
SpaceAxis::Horizontal => el.w(px(gap)),
SpaceAxis::Vertical => el.h(px(gap)),
}
}
}