Checkpoint - Still Broken
This commit is contained in:
parent
bca97f7186
commit
58650b7d2d
31 changed files with 298 additions and 213 deletions
|
@ -3,7 +3,6 @@ use std::marker::PhantomData;
|
|||
use gpui3::img;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::theme::theme;
|
||||
|
||||
#[derive(Element, Clone)]
|
||||
pub struct Avatar<S: 'static + Send + Sync> {
|
||||
|
@ -39,7 +38,7 @@ impl<S: 'static + Send + Sync> Avatar<S> {
|
|||
|
||||
img.uri(self.src.clone())
|
||||
.size_4()
|
||||
.bg(theme.middle.warning.default.foreground)
|
||||
.bg(color.image_fallback_background)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::theme;
|
||||
|
||||
#[derive(Element, Clone)]
|
||||
pub struct Details<S: 'static + Send + Sync + Clone> {
|
||||
|
@ -33,7 +32,7 @@ impl<S: 'static + Send + Sync + Clone> Details<S> {
|
|||
.p_1()
|
||||
.gap_0p5()
|
||||
.text_xs()
|
||||
.text_color(theme.lowest.base.default.foreground)
|
||||
.text_color(color.text)
|
||||
.child(self.text)
|
||||
.children(self.meta.map(|m| m))
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpui3::{svg, Hsla};
|
||||
use strum::EnumIter;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::theme::{theme, Theme};
|
||||
use crate::theme::theme;
|
||||
|
||||
#[derive(Default, PartialEq, Copy, Clone)]
|
||||
pub enum IconSize {
|
||||
|
@ -29,7 +28,8 @@ pub enum IconColor {
|
|||
}
|
||||
|
||||
impl IconColor {
|
||||
pub fn color(self, theme: Arc<Theme>) -> Hsla {
|
||||
pub fn color(self, cx: &WindowContext) -> Hsla {
|
||||
let theme = theme(cx);
|
||||
match self {
|
||||
IconColor::Default => theme.lowest.base.default.foreground,
|
||||
IconColor::Muted => theme.lowest.variant.default.foreground,
|
||||
|
@ -178,7 +178,7 @@ impl<S: 'static + Send + Sync> IconElement<S> {
|
|||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
let color = ThemeColor::new(cx);
|
||||
let fill = self.color.color(theme);
|
||||
let fill = self.color.color(cx);
|
||||
let svg_size = match self.size {
|
||||
IconSize::Small => ui_size(12. / 14.),
|
||||
IconSize::Medium => ui_size(15. / 14.),
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::theme;
|
||||
use crate::Label;
|
||||
use crate::LabelColor;
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
pub enum InputVariant {
|
||||
|
@ -17,6 +18,8 @@ pub struct Input<S: 'static + Send + Sync> {
|
|||
value: String,
|
||||
state: InteractionState,
|
||||
variant: InputVariant,
|
||||
disabled: bool,
|
||||
is_active: bool,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Input<S> {
|
||||
|
@ -27,6 +30,8 @@ impl<S: 'static + Send + Sync> Input<S> {
|
|||
value: "".to_string(),
|
||||
state: InteractionState::default(),
|
||||
variant: InputVariant::default(),
|
||||
disabled: false,
|
||||
is_active: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,55 +50,54 @@ impl<S: 'static + Send + Sync> Input<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn is_active(mut self, is_active: bool) -> Self {
|
||||
self.is_active = is_active;
|
||||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
let color = ThemeColor::new(cx);
|
||||
let system_color = SystemColor::new();
|
||||
|
||||
let text_el;
|
||||
let text_color;
|
||||
let background_color_default;
|
||||
let background_color_active;
|
||||
|
||||
let mut border_color_default = theme.middle.base.default.border;
|
||||
let mut border_color_hover = theme.middle.base.hovered.border;
|
||||
let border_color_focus = theme.middle.base.pressed.background;
|
||||
|
||||
match self.variant {
|
||||
InputVariant::Ghost => {
|
||||
background_color_default = theme.middle.base.default.background;
|
||||
background_color_active = theme.middle.base.active.background;
|
||||
}
|
||||
InputVariant::Filled => {
|
||||
background_color_default = theme.middle.on.default.background;
|
||||
background_color_active = theme.middle.on.active.background;
|
||||
}
|
||||
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
||||
InputVariant::Ghost => (
|
||||
color.ghost_element,
|
||||
color.ghost_element_hover,
|
||||
color.ghost_element_active,
|
||||
),
|
||||
InputVariant::Filled => (
|
||||
color.filled_element,
|
||||
color.filled_element_hover,
|
||||
color.filled_element_active,
|
||||
),
|
||||
};
|
||||
|
||||
if self.state == InteractionState::Focused {
|
||||
border_color_default = theme.players[0].cursor;
|
||||
border_color_hover = theme.players[0].cursor;
|
||||
}
|
||||
|
||||
if self.state == InteractionState::Focused || self.state == InteractionState::Active {
|
||||
text_el = self.value.clone();
|
||||
text_color = theme.lowest.base.default.foreground;
|
||||
let placeholder_label = Label::new(self.placeholder).color(if self.disabled {
|
||||
LabelColor::Disabled
|
||||
} else {
|
||||
text_el = self.placeholder.to_string().clone();
|
||||
text_color = theme.lowest.base.disabled.foreground;
|
||||
}
|
||||
LabelColor::Placeholder
|
||||
});
|
||||
|
||||
let label = Label::new(self.value.clone()).color(if self.disabled {
|
||||
LabelColor::Disabled
|
||||
} else {
|
||||
LabelColor::Default
|
||||
});
|
||||
|
||||
div()
|
||||
.h_7()
|
||||
.w_full()
|
||||
.px_2()
|
||||
.border()
|
||||
.border_color(border_color_default)
|
||||
.bg(background_color_default)
|
||||
.hover(|style| {
|
||||
style
|
||||
.border_color(border_color_hover)
|
||||
.bg(background_color_active)
|
||||
})
|
||||
// .active(|a| .border_color(border_color_active))
|
||||
.border_color(system_color.transparent)
|
||||
.bg(input_bg)
|
||||
.hover(|style| style.bg(input_hover_bg))
|
||||
// .active(|style| style.bg(input_active_bg))
|
||||
.flex()
|
||||
.items_center()
|
||||
.child(
|
||||
|
@ -101,9 +105,8 @@ impl<S: 'static + Send + Sync> Input<S> {
|
|||
.flex()
|
||||
.items_center()
|
||||
.text_sm()
|
||||
.text_color(text_color)
|
||||
.child(text_el)
|
||||
.child(div().text_color(theme.players[0].cursor).child("|")),
|
||||
.when(self.value.is_empty(), |this| this.child(placeholder_label))
|
||||
.when(!self.value.is_empty(), |this| this.child(label)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,16 +23,18 @@ pub enum LabelColor {
|
|||
impl LabelColor {
|
||||
pub fn hsla(&self, cx: &WindowContext) -> Hsla {
|
||||
let color = ThemeColor::new(cx);
|
||||
// TODO: Remove
|
||||
let theme = theme(cx);
|
||||
|
||||
match self {
|
||||
Self::Default => theme.middle.base.default.foreground,
|
||||
Self::Muted => theme.middle.variant.default.foreground,
|
||||
Self::Default => color.text,
|
||||
Self::Muted => color.text_muted,
|
||||
Self::Created => theme.middle.positive.default.foreground,
|
||||
Self::Modified => theme.middle.warning.default.foreground,
|
||||
Self::Deleted => theme.middle.negative.default.foreground,
|
||||
Self::Disabled => theme.middle.base.disabled.foreground,
|
||||
Self::Disabled => color.text_disabled,
|
||||
Self::Hidden => theme.middle.variant.default.foreground,
|
||||
Self::Placeholder => theme.middle.base.disabled.foreground,
|
||||
Self::Placeholder => color.text_placeholder,
|
||||
Self::Accent => theme.middle.accent.default.foreground,
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +140,7 @@ impl<S: 'static + Send + Sync + Clone> HighlightedLabel<S> {
|
|||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
let color = ThemeColor::new(cx);
|
||||
|
||||
let highlight_color = theme.lowest.accent.default.foreground;
|
||||
let highlight_color = color.text_accent;
|
||||
|
||||
let mut highlight_indices = self.highlight_indices.iter().copied().peekable();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use gpui3::{Hsla, ViewContext};
|
||||
|
||||
use crate::theme;
|
||||
use crate::ThemeColor;
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
|
||||
pub enum PlayerStatus {
|
||||
|
@ -141,13 +141,13 @@ impl Player {
|
|||
pub fn cursor_color<S: 'static>(&self, cx: &mut ViewContext<S>) -> Hsla {
|
||||
let color = ThemeColor::new(cx);
|
||||
let index = self.index % 8;
|
||||
theme.players[self.index].cursor
|
||||
color.player[self.index].cursor
|
||||
}
|
||||
|
||||
pub fn selection_color<S: 'static>(&self, cx: &mut ViewContext<S>) -> Hsla {
|
||||
let color = ThemeColor::new(cx);
|
||||
let index = self.index % 8;
|
||||
theme.players[self.index].selection
|
||||
color.player[self.index].selection
|
||||
}
|
||||
|
||||
pub fn avatar_src(&self) -> &str {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::theme;
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct ToolDivider<S: 'static + Send + Sync> {
|
||||
|
@ -18,6 +17,6 @@ impl<S: 'static + Send + Sync> ToolDivider<S> {
|
|||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
let color = ThemeColor::new(cx);
|
||||
|
||||
div().w_px().h_3().bg(theme.lowest.base.default.border)
|
||||
div().w_px().h_3().bg(color.border)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue