diff --git a/crates/ui2/src/components/collab_panel.rs b/crates/ui2/src/components/collab_panel.rs index 991101fb13..1900b7e2ac 100644 --- a/crates/ui2/src/components/collab_panel.rs +++ b/crates/ui2/src/components/collab_panel.rs @@ -25,11 +25,11 @@ impl CollabPanel { fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx); + let color = ThemeColor::new(cx); v_stack() - .w_64() .h_full() - .fill(theme.middle.base.default.background) + .fill(color.surface) .child( v_stack() .w_full() @@ -44,7 +44,7 @@ impl CollabPanel { List::new(static_collab_panel_current_call()) .header( ListHeader::new("CRDB") - .left_icon(Icon::Hash.into()) + .set_left_icon(Icon::Hash.into()) .set_toggle(ToggleState::Toggled), ) .set_toggle(ToggleState::Toggled), diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rs index 3d9f963d97..f3ef79e920 100644 --- a/crates/ui2/src/components/context_menu.rs +++ b/crates/ui2/src/components/context_menu.rs @@ -1,7 +1,5 @@ -use crate::prelude::*; -use crate::{ - theme, v_stack, Label, List, ListEntry, ListItem, ListItemVariant, ListSeparator, ListSubHeader, -}; +use crate::{prelude::*, ListItemVariant}; +use crate::{theme, v_stack, Label, List, ListEntry, ListItem, ListSeparator, ListSubHeader}; #[derive(Clone)] pub enum ContextMenuItem { diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index e2a8497a1f..3897394a78 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -49,7 +49,7 @@ impl ListHeader { self } - pub fn left_icon(mut self, left_icon: Option) -> Self { + pub fn set_left_icon(mut self, left_icon: Option) -> Self { self.left_icon = left_icon; self } @@ -78,18 +78,6 @@ impl ListHeader { } } - fn background_color(&self, cx: &WindowContext) -> Hsla { - let theme = theme(cx); - let system_color = SystemColor::new(); - - match self.state { - InteractionState::Hovered => theme.lowest.base.hovered.background, - InteractionState::Active => theme.lowest.base.pressed.background, - InteractionState::Enabled => theme.lowest.on.default.background, - _ => system_color.transparent, - } - } - fn label_color(&self) -> LabelColor { match self.state { InteractionState::Disabled => LabelColor::Disabled, @@ -108,7 +96,7 @@ impl ListHeader { let theme = theme(cx); let token = token(); let system_color = SystemColor::new(); - let background_color = self.background_color(cx); + let color = ThemeColor::new(cx); let is_toggleable = self.toggleable != Toggleable::NotToggleable; let is_toggled = Toggleable::is_toggled(&self.toggleable); @@ -118,10 +106,9 @@ impl ListHeader { h_stack() .flex_1() .w_full() - .fill(background_color) + .fill(color.surface) .when(self.state == InteractionState::Focused, |this| { - this.border() - .border_color(theme.lowest.accent.default.border) + this.border().border_color(color.border_focused) }) .relative() .child( @@ -133,7 +120,6 @@ impl ListHeader { .w_full() .gap_1() .items_center() - .justify_between() .child( div() .flex() @@ -145,7 +131,7 @@ impl ListHeader { .size(IconSize::Small) })) .child( - Label::new(self.label.clone()) + Label::new(self.label) .color(LabelColor::Muted) .size(LabelSize::Small), ), @@ -203,7 +189,7 @@ impl ListSubHeader { .size(IconSize::Small) })) .child( - Label::new(self.label.clone()) + Label::new(self.label) .color(LabelColor::Muted) .size(LabelSize::Small), ), @@ -346,18 +332,6 @@ impl ListEntry { self } - fn background_color(&self, cx: &WindowContext) -> Hsla { - let theme = theme(cx); - let system_color = SystemColor::new(); - - match self.state { - InteractionState::Hovered => theme.lowest.base.hovered.background, - InteractionState::Active => theme.lowest.base.pressed.background, - InteractionState::Enabled => theme.lowest.on.default.background, - _ => system_color.transparent, - } - } - fn label_color(&self) -> LabelColor { match self.state { InteractionState::Disabled => LabelColor::Disabled, @@ -420,7 +394,7 @@ impl ListEntry { div() .relative() - .fill(self.background_color(cx)) + .fill(color.surface) .when(self.state == InteractionState::Focused, |this| { this.border().border_color(color.border_focused) }) diff --git a/crates/ui2/src/components/project_panel.rs b/crates/ui2/src/components/project_panel.rs index 11c99a35be..fb24dcd37e 100644 --- a/crates/ui2/src/components/project_panel.rs +++ b/crates/ui2/src/components/project_panel.rs @@ -29,7 +29,7 @@ impl ProjectPanel { .flex_col() .w_full() .h_full() - .fill(color.panel_surface) + .fill(color.surface) .child( div() .w_full() diff --git a/crates/ui2/src/elements/input.rs b/crates/ui2/src/elements/input.rs index a6cbf2576d..d63f116ca3 100644 --- a/crates/ui2/src/elements/input.rs +++ b/crates/ui2/src/elements/input.rs @@ -55,7 +55,6 @@ impl Input { let mut border_color_default = theme.middle.base.default.border; let mut border_color_hover = theme.middle.base.hovered.border; - let mut border_color_active = theme.middle.base.pressed.border; let border_color_focus = theme.middle.base.pressed.background; match self.variant { @@ -72,7 +71,6 @@ impl Input { if self.state == InteractionState::Focused { border_color_default = theme.players[0].cursor; border_color_hover = theme.players[0].cursor; - border_color_active = theme.players[0].cursor; } if self.state == InteractionState::Focused || self.state == InteractionState::Active { diff --git a/crates/ui2/src/prelude.rs b/crates/ui2/src/prelude.rs index 9c26d4889e..2d0342e765 100644 --- a/crates/ui2/src/prelude.rs +++ b/crates/ui2/src/prelude.rs @@ -60,7 +60,7 @@ pub struct ThemeColor { pub border_focused: Hsla, /// The background color of an elevated surface, like a modal, tooltip or toast. pub elevated_surface: Hsla, - pub panel_surface: Hsla, + pub surface: Hsla, } impl ThemeColor { @@ -72,7 +72,7 @@ impl ThemeColor { border_variant: theme.lowest.variant.default.border, border_focused: theme.lowest.accent.default.border, elevated_surface: theme.middle.base.default.background, - panel_surface: theme.middle.base.default.background, + surface: theme.middle.base.default.background, } } }