Refine project panel, list item

This commit is contained in:
Nate Butler 2023-10-11 19:15:27 -04:00
parent 5477b87774
commit 12573ed2e7
6 changed files with 15 additions and 45 deletions

View file

@ -25,11 +25,11 @@ impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> { fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
let theme = theme(cx); let theme = theme(cx);
let color = ThemeColor::new(cx);
v_stack() v_stack()
.w_64()
.h_full() .h_full()
.fill(theme.middle.base.default.background) .fill(color.surface)
.child( .child(
v_stack() v_stack()
.w_full() .w_full()
@ -44,7 +44,7 @@ impl<S: 'static + Send + Sync + Clone> CollabPanel<S> {
List::new(static_collab_panel_current_call()) List::new(static_collab_panel_current_call())
.header( .header(
ListHeader::new("CRDB") ListHeader::new("CRDB")
.left_icon(Icon::Hash.into()) .set_left_icon(Icon::Hash.into())
.set_toggle(ToggleState::Toggled), .set_toggle(ToggleState::Toggled),
) )
.set_toggle(ToggleState::Toggled), .set_toggle(ToggleState::Toggled),

View file

@ -1,7 +1,5 @@
use crate::prelude::*; use crate::{prelude::*, ListItemVariant};
use crate::{ use crate::{theme, v_stack, Label, List, ListEntry, ListItem, ListSeparator, ListSubHeader};
theme, v_stack, Label, List, ListEntry, ListItem, ListItemVariant, ListSeparator, ListSubHeader,
};
#[derive(Clone)] #[derive(Clone)]
pub enum ContextMenuItem<S: 'static + Send + Sync + Clone> { pub enum ContextMenuItem<S: 'static + Send + Sync + Clone> {

View file

@ -49,7 +49,7 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
self self
} }
pub fn left_icon(mut self, left_icon: Option<Icon>) -> Self { pub fn set_left_icon(mut self, left_icon: Option<Icon>) -> Self {
self.left_icon = left_icon; self.left_icon = left_icon;
self self
} }
@ -78,18 +78,6 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
} }
} }
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 { fn label_color(&self) -> LabelColor {
match self.state { match self.state {
InteractionState::Disabled => LabelColor::Disabled, InteractionState::Disabled => LabelColor::Disabled,
@ -108,7 +96,7 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
let theme = theme(cx); let theme = theme(cx);
let token = token(); let token = token();
let system_color = SystemColor::new(); 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_toggleable = self.toggleable != Toggleable::NotToggleable;
let is_toggled = Toggleable::is_toggled(&self.toggleable); let is_toggled = Toggleable::is_toggled(&self.toggleable);
@ -118,10 +106,9 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
h_stack() h_stack()
.flex_1() .flex_1()
.w_full() .w_full()
.fill(background_color) .fill(color.surface)
.when(self.state == InteractionState::Focused, |this| { .when(self.state == InteractionState::Focused, |this| {
this.border() this.border().border_color(color.border_focused)
.border_color(theme.lowest.accent.default.border)
}) })
.relative() .relative()
.child( .child(
@ -133,7 +120,6 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
.w_full() .w_full()
.gap_1() .gap_1()
.items_center() .items_center()
.justify_between()
.child( .child(
div() div()
.flex() .flex()
@ -145,7 +131,7 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
.size(IconSize::Small) .size(IconSize::Small)
})) }))
.child( .child(
Label::new(self.label.clone()) Label::new(self.label)
.color(LabelColor::Muted) .color(LabelColor::Muted)
.size(LabelSize::Small), .size(LabelSize::Small),
), ),
@ -203,7 +189,7 @@ impl<S: 'static + Send + Sync + Clone> ListSubHeader<S> {
.size(IconSize::Small) .size(IconSize::Small)
})) }))
.child( .child(
Label::new(self.label.clone()) Label::new(self.label)
.color(LabelColor::Muted) .color(LabelColor::Muted)
.size(LabelSize::Small), .size(LabelSize::Small),
), ),
@ -346,18 +332,6 @@ impl<S: 'static + Send + Sync + Clone> ListEntry<S> {
self 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 { fn label_color(&self) -> LabelColor {
match self.state { match self.state {
InteractionState::Disabled => LabelColor::Disabled, InteractionState::Disabled => LabelColor::Disabled,
@ -420,7 +394,7 @@ impl<S: 'static + Send + Sync + Clone> ListEntry<S> {
div() div()
.relative() .relative()
.fill(self.background_color(cx)) .fill(color.surface)
.when(self.state == InteractionState::Focused, |this| { .when(self.state == InteractionState::Focused, |this| {
this.border().border_color(color.border_focused) this.border().border_color(color.border_focused)
}) })

View file

@ -29,7 +29,7 @@ impl<S: 'static + Send + Sync + Clone> ProjectPanel<S> {
.flex_col() .flex_col()
.w_full() .w_full()
.h_full() .h_full()
.fill(color.panel_surface) .fill(color.surface)
.child( .child(
div() div()
.w_full() .w_full()

View file

@ -55,7 +55,6 @@ impl<S: 'static + Send + Sync> Input<S> {
let mut border_color_default = theme.middle.base.default.border; let mut border_color_default = theme.middle.base.default.border;
let mut border_color_hover = theme.middle.base.hovered.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; let border_color_focus = theme.middle.base.pressed.background;
match self.variant { match self.variant {
@ -72,7 +71,6 @@ impl<S: 'static + Send + Sync> Input<S> {
if self.state == InteractionState::Focused { if self.state == InteractionState::Focused {
border_color_default = theme.players[0].cursor; border_color_default = theme.players[0].cursor;
border_color_hover = 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 { if self.state == InteractionState::Focused || self.state == InteractionState::Active {

View file

@ -60,7 +60,7 @@ pub struct ThemeColor {
pub border_focused: Hsla, pub border_focused: Hsla,
/// The background color of an elevated surface, like a modal, tooltip or toast. /// The background color of an elevated surface, like a modal, tooltip or toast.
pub elevated_surface: Hsla, pub elevated_surface: Hsla,
pub panel_surface: Hsla, pub surface: Hsla,
} }
impl ThemeColor { impl ThemeColor {
@ -72,7 +72,7 @@ impl ThemeColor {
border_variant: theme.lowest.variant.default.border, border_variant: theme.lowest.variant.default.border,
border_focused: theme.lowest.accent.default.border, border_focused: theme.lowest.accent.default.border,
elevated_surface: theme.middle.base.default.background, elevated_surface: theme.middle.base.default.background,
panel_surface: theme.middle.base.default.background, surface: theme.middle.base.default.background,
} }
} }
} }