diff --git a/src/components/icon.rs b/src/components/icon.rs index 25e5409..23068be 100644 --- a/src/components/icon.rs +++ b/src/components/icon.rs @@ -57,10 +57,7 @@ pub enum IconName {} impl IconNamed for IconName { fn path(&self) -> SharedString { match self { - // Mapear cada variante a su path SVG - // IconName::Check => "icons/check.svg".into(), - // IconName::Close => "icons/close.svg".into(), - _ => "".into(), + _ => todo!(), } } } diff --git a/src/components/label.rs b/src/components/label.rs index 2e26b6d..4cc9fd3 100644 --- a/src/components/label.rs +++ b/src/components/label.rs @@ -5,27 +5,35 @@ use crate::theme::ActiveTheme; #[derive(gpui::IntoElement)] pub struct Label { text: gpui::SharedString, + style: gpui::StyleRefinement, } impl Label { pub fn new(text: impl Into) -> Self { - Self { text: text.into() } + Self { + text: text.into(), + style: gpui::StyleRefinement::default(), + } } } -// impl gpui::Styled for Label { -// fn style(&mut self) -> &mut gpui::StyleRefinement { -// &mut self.style -// } -// } +impl gpui::Styled for Label { + fn style(&mut self) -> &mut gpui::StyleRefinement { + &mut self.style + } +} impl RenderOnce for Label { - fn render(self, _window: &mut gpui::Window, cx: &mut gpui::App) -> impl gpui::IntoElement { + fn render(mut self, _window: &mut gpui::Window, cx: &mut gpui::App) -> impl gpui::IntoElement { let theme = cx.theme(); - gpui::div() + let mut div = gpui::div() .line_height(gpui::rems(1.25)) .text_color(theme.foreground) - .child(gpui::StyledText::new(&self.text)) + .child(gpui::StyledText::new(&self.text)); + + *div.style() = self.style; + + div } } diff --git a/src/components/list.rs b/src/components/list.rs index 2daa4c1..0767116 100644 --- a/src/components/list.rs +++ b/src/components/list.rs @@ -29,6 +29,7 @@ pub struct List { items: Vec, selected_index: Option, height: Option, + style: gpui::StyleRefinement, on_click: Option) + Send + Sync>>, on_hover: Option) + Send + Sync>>, } @@ -40,6 +41,7 @@ impl List { items: Vec::new(), selected_index: None, height: None, + style: gpui::StyleRefinement::default(), on_click: None, on_hover: None, } @@ -127,6 +129,12 @@ impl List { } } +impl gpui::Styled for List { + fn style(&mut self) -> &mut gpui::StyleRefinement { + &mut self.style + } +} + impl gpui::Render for List { fn render( &mut self, @@ -193,6 +201,8 @@ impl gpui::Render for List { container = container.h(height); } + *container.style() = self.style.clone(); + container } } diff --git a/src/components/modal.rs b/src/components/modal.rs index 1aae4bc..f4942a1 100644 --- a/src/components/modal.rs +++ b/src/components/modal.rs @@ -28,6 +28,7 @@ pub struct Modal { open: bool, close_on_backdrop: bool, last_action: Option, + style: gpui::StyleRefinement, on_close: Option) + Send + Sync>>, on_save: Option) + Send + Sync>>, on_cancel: Option) + Send + Sync>>, @@ -45,6 +46,7 @@ impl Modal { open: false, close_on_backdrop: true, last_action: None, + style: gpui::StyleRefinement::default(), on_close: None, on_save: None, on_cancel: None, @@ -222,6 +224,12 @@ impl Modal { } } +impl gpui::Styled for Modal { + fn style(&mut self) -> &mut gpui::StyleRefinement { + &mut self.style + } +} + impl gpui::Render for Modal { fn render( &mut self, diff --git a/src/components/panel.rs b/src/components/panel.rs index 224e69c..a7f2a71 100644 --- a/src/components/panel.rs +++ b/src/components/panel.rs @@ -8,6 +8,7 @@ pub struct Panel { title: Option, border: f32, padding: f32, + style: gpui::StyleRefinement, } impl Panel { @@ -17,6 +18,7 @@ impl Panel { title: None, border: 1.0, padding: 8.0, + style: gpui::StyleRefinement::default(), } } @@ -50,6 +52,12 @@ impl Panel { } } +impl gpui::Styled for Panel { + fn style(&mut self) -> &mut gpui::StyleRefinement { + &mut self.style + } +} + impl gpui::RenderOnce for Panel { fn render(mut self, _window: &mut gpui::Window, cx: &mut gpui::App) -> impl IntoElement { let theme = cx.theme(); @@ -81,7 +89,7 @@ impl gpui::RenderOnce for Panel { }) .collect(); - gpui::div() + let mut div = gpui::div() .size_full() .bg(theme.panel) .border(gpui::px(self.border)) @@ -92,6 +100,10 @@ impl gpui::RenderOnce for Panel { .flex_col() .h_full() .children(header) - .children(children) + .children(children); + + *div.style() = self.style; + + div } } diff --git a/src/view/sidebar.rs b/src/view/sidebar.rs index 48b19ac..63865a2 100644 --- a/src/view/sidebar.rs +++ b/src/view/sidebar.rs @@ -1,4 +1,8 @@ -use crate::components::{divider::Divider, panel::Panel}; +use crate::components::{ + icon::{Icon, IconName, IconSize}, + label::Label, + panel::Panel, +}; use crate::models::{FilterState, ProjectTree}; use crate::theme::ActiveTheme; use gpui::{Context, Div, Entity, IntoElement, Window, div, prelude::*, px}; @@ -299,11 +303,10 @@ impl Render for Sidebar { .border_b_1() .border_color(theme.border) .child( - div() + Label::new("PROJECTS") .text_sm() .font_weight(gpui::FontWeight::BOLD) - .text_color(theme.foreground) - .child("PROJECTS"), + .text_color(theme.foreground), ), ) .child( @@ -337,11 +340,10 @@ impl Render for Sidebar { .border_b_1() .border_color(theme.border) .child( - div() + Label::new("TAGS") .text_sm() .font_weight(gpui::FontWeight::BOLD) - .text_color(theme.foreground) - .child("TAGS"), + .text_color(theme.foreground), ), ) .child(