Clean compile with redesigned element traits

This commit is contained in:
Nathan Sobo 2023-11-18 21:51:47 -07:00
parent 0673606de8
commit 33cd6f520a
35 changed files with 278 additions and 216 deletions

View file

@ -1,4 +1,4 @@
use gpui::RenderOnce;
use gpui::{Div, RenderOnce};
use crate::prelude::*;
@ -7,12 +7,29 @@ enum DividerDirection {
Vertical,
}
// #[derive(RenderOnce)]
#[derive(RenderOnce)]
pub struct Divider {
direction: DividerDirection,
inset: bool,
}
impl<V: 'static> Component<V> for Divider {
type Rendered = Div<V>;
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> Self::Rendered {
div()
.map(|this| match self.direction {
DividerDirection::Horizontal => {
this.h_px().w_full().when(self.inset, |this| this.mx_1p5())
}
DividerDirection::Vertical => {
this.w_px().h_full().when(self.inset, |this| this.my_1p5())
}
})
.bg(cx.theme().colors().border_variant)
}
}
impl Divider {
pub fn horizontal() -> Self {
Self {