Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
`TextColor` -> `Color`
Nate Butler453aa5ffd73a
diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rsindex 2c08840691c..94db2f4d9f6 100644--- a/crates/collab_ui2/src/collab_titlebar_item.rs+++ b/crates/collab_ui2/src/collab_titlebar_item.rs@@ -37,7 +37,7 @@ use gpui::{};use project::Project;use theme::ActiveTheme;-use ui::{h_stack, Button, ButtonVariant, KeyBinding, Label, TextColor, Tooltip};+use ui::{h_stack, Button, ButtonVariant, Color, KeyBinding, Label, Tooltip};use workspace::Workspace;// const MAX_PROJECT_NAME_LENGTH: usize = 40;@@ -115,7 +115,7 @@ impl Render for CollabTitlebarItem {.child(Button::new("player").variant(ButtonVariant::Ghost)- .color(Some(TextColor::Player(0))),+ .color(Some(Color::Player(0))),).tooltip(move |cx| Tooltip::text("Toggle following", cx)),)@@ -133,7 +133,7 @@ impl Render for CollabTitlebarItem {.child(Button::new("branch_name").variant(ButtonVariant::Ghost)- .color(Some(TextColor::Muted)),+ .color(Some(Color::Muted)),).tooltip(move |cx| {cx.build_view(|_| {diff --git a/crates/diagnostics2/src/diagnostics.rs b/crates/diagnostics2/src/diagnostics.rsindex 9cd049597dc..7ff8cd84dbf 100644--- a/crates/diagnostics2/src/diagnostics.rs+++ b/crates/diagnostics2/src/diagnostics.rs@@ -36,7 +36,7 @@ use std::{};use theme::ActiveTheme;pub use toolbar_controls::ToolbarControls;-use ui::{h_stack, HighlightedLabel, Icon, IconElement, Label, TextColor};+use ui::{h_stack, Color, HighlightedLabel, Icon, IconElement, Label};use util::TryFutureExt;use workspace::{item::{BreadcrumbText, Item, ItemEvent, ItemHandle},@@ -778,15 +778,15 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {.bg(gpui::red()).map(|stack| {let icon = if diagnostic.severity == DiagnosticSeverity::ERROR {- IconElement::new(Icon::XCircle).color(TextColor::Error)+ IconElement::new(Icon::XCircle).color(Color::Error)} else {- IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning)+ IconElement::new(Icon::ExclamationTriangle).color(Color::Warning)};stack.child(div().pl_8().child(icon))}).when_some(diagnostic.source.as_ref(), |stack, source| {- stack.child(Label::new(format!("{source}:")).color(TextColor::Accent))+ stack.child(Label::new(format!("{source}:")).color(Color::Accent))}).child(HighlightedLabel::new(message.clone(), highlights.clone())).when_some(diagnostic.code.as_ref(), |stack, code| {diff --git a/crates/diagnostics2/src/items.rs b/crates/diagnostics2/src/items.rsindex 730927a79ea..bbcfa748d44 100644--- a/crates/diagnostics2/src/items.rs+++ b/crates/diagnostics2/src/items.rs@@ -7,7 +7,7 @@ use gpui::{use language::Diagnostic;use lsp::LanguageServerId;use theme::ActiveTheme;-use ui::{h_stack, Icon, IconElement, Label, TextColor, Tooltip};+use ui::{h_stack, Color, Icon, IconElement, Label, Tooltip};use workspace::{item::ItemHandle, StatusItemView, ToolbarItemEvent, Workspace};use crate::ProjectDiagnosticsEditor;@@ -26,20 +26,20 @@ impl Render for DiagnosticIndicator {fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {- (0, 0) => h_stack().child(IconElement::new(Icon::Check).color(TextColor::Success)),+ (0, 0) => h_stack().child(IconElement::new(Icon::Check).color(Color::Success)),(0, warning_count) => h_stack().gap_1()- .child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning))+ .child(IconElement::new(Icon::ExclamationTriangle).color(Color::Warning)).child(Label::new(warning_count.to_string())),(error_count, 0) => h_stack().gap_1()- .child(IconElement::new(Icon::XCircle).color(TextColor::Error))+ .child(IconElement::new(Icon::XCircle).color(Color::Error)).child(Label::new(error_count.to_string())),(error_count, warning_count) => h_stack().gap_1()- .child(IconElement::new(Icon::XCircle).color(TextColor::Error))+ .child(IconElement::new(Icon::XCircle).color(Color::Error)).child(Label::new(error_count.to_string()))- .child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning))+ .child(IconElement::new(Icon::ExclamationTriangle).color(Color::Warning)).child(Label::new(warning_count.to_string())),};diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rsindex a4482af6af9..fa7bfd77cc0 100644--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@ -4408,7 +4408,7 @@ impl Editor {editor.fold_at(&FoldAt { buffer_row }, cx);}}))- .color(ui::TextColor::Muted)+ .color(ui::Color::Muted)})}).flatten()diff --git a/crates/editor2/src/items.rs b/crates/editor2/src/items.rsindex cdb15329d32..eca3b99d780 100644--- a/crates/editor2/src/items.rs+++ b/crates/editor2/src/items.rs@@ -30,7 +30,7 @@ use std::{};use text::Selection;use theme::{ActiveTheme, Theme};-use ui::{Label, TextColor};+use ui::{Color, Label};use util::{paths::PathExt, ResultExt, TryFutureExt};use workspace::item::{BreadcrumbText, FollowEvent, FollowableEvents, FollowableItemHandle};use workspace::{@@ -604,7 +604,7 @@ impl Item for Editor {&description,MAX_TAB_TITLE_LEN,))- .color(TextColor::Muted),+ .color(Color::Muted),),)})),diff --git a/crates/go_to_line2/src/go_to_line.rs b/crates/go_to_line2/src/go_to_line.rsindex 4ba605c3c96..61f5742750a 100644--- a/crates/go_to_line2/src/go_to_line.rs+++ b/crates/go_to_line2/src/go_to_line.rs@@ -5,7 +5,7 @@ use gpui::{};use text::{Bias, Point};use theme::ActiveTheme;-use ui::{h_stack, v_stack, Label, StyledExt, TextColor};+use ui::{h_stack, v_stack, Color, Label, StyledExt};use util::paths::FILE_ROW_COLUMN_DELIMITER;use workspace::Workspace;@@ -176,7 +176,7 @@ impl Render for GoToLine {.justify_between().px_2().py_1()- .child(Label::new(self.current_text.clone()).color(TextColor::Muted)),+ .child(Label::new(self.current_text.clone()).color(Color::Muted)),),)}diff --git a/crates/picker2/src/picker2.rs b/crates/picker2/src/picker2.rsindex 786e641ee86..e58b7782efe 100644--- a/crates/picker2/src/picker2.rs+++ b/crates/picker2/src/picker2.rs@@ -4,7 +4,7 @@ use gpui::{MouseDownEvent, Render, Task, UniformListScrollHandle, View, ViewContext, WindowContext,};use std::{cmp, sync::Arc};-use ui::{prelude::*, v_stack, Divider, Label, TextColor};+use ui::{prelude::*, v_stack, Color, Divider, Label};pub struct Picker<D: PickerDelegate> {pub delegate: D,@@ -250,7 +250,7 @@ impl<D: PickerDelegate> Render for Picker<D> {v_stack().p_1().grow().child(div().px_1()- .child(Label::new("No matches").color(TextColor::Muted)),+ .child(Label::new("No matches").color(Color::Muted)),),)})diff --git a/crates/ui2/src/components.rs b/crates/ui2/src/components.rsindex 2b1df6dacc3..4d7e3c14b6b 100644--- a/crates/ui2/src/components.rs+++ b/crates/ui2/src/components.rs@@ -2,6 +2,7 @@ mod avatar;mod button;mod checkbox;mod context_menu;+mod disclosure;mod divider;mod icon;mod icon_button;@@ -19,6 +20,7 @@ pub use avatar::*;pub use button::*;pub use checkbox::*;pub use context_menu::*;+pub use disclosure::*;pub use divider::*;pub use icon::*;pub use icon_button::*;diff --git a/crates/ui2/src/components/button.rs b/crates/ui2/src/components/button.rsindex b2b5aebea55..a5176be52ea 100644--- a/crates/ui2/src/components/button.rs+++ b/crates/ui2/src/components/button.rs@@ -6,7 +6,7 @@ use gpui::{};use crate::prelude::*;-use crate::{h_stack, Icon, IconButton, IconElement, Label, LineHeightStyle, TextColor};+use crate::{h_stack, Color, Icon, IconButton, IconElement, Label, LineHeightStyle};/// Provides the flexibility to use either a standard/// button or an icon button in a given context.@@ -73,7 +73,7 @@ pub struct Button {label: SharedString,variant: ButtonVariant,width: Option<DefiniteLength>,- color: Option<TextColor>,+ color: Option<Color>,}impl Component for Button {@@ -81,9 +81,9 @@ impl Component for Button {fn render(self, cx: &mut WindowContext) -> Self::Rendered {let (icon_color, label_color) = match (self.disabled, self.color) {- (true, _) => (TextColor::Disabled, TextColor::Disabled),- (_, None) => (TextColor::Default, TextColor::Default),- (_, Some(color)) => (TextColor::from(color), color),+ (true, _) => (Color::Disabled, Color::Disabled),+ (_, None) => (Color::Default, Color::Default),+ (_, Some(color)) => (Color::from(color), color),};let mut button = h_stack()@@ -181,14 +181,14 @@ impl Button {self}- pub fn color(mut self, color: Option<TextColor>) -> Self {+ pub fn color(mut self, color: Option<Color>) -> Self {self.color = color;self}- pub fn label_color(&self, color: Option<TextColor>) -> TextColor {+ pub fn label_color(&self, color: Option<Color>) -> Color {if self.disabled {- TextColor::Disabled+ Color::Disabled} else if let Some(color) = color {color} else {@@ -196,13 +196,13 @@ impl Button {}}- fn render_label(&self, color: TextColor) -> Label {+ fn render_label(&self, color: Color) -> Label {Label::new(self.label.clone()).color(color).line_height_style(LineHeightStyle::UILabel)}- fn render_icon(&self, icon_color: TextColor) -> Option<IconElement> {+ fn render_icon(&self, icon_color: Color) -> Option<IconElement> {self.icon.map(|i| IconElement::new(i).color(icon_color))}}diff --git a/crates/ui2/src/components/checkbox.rs b/crates/ui2/src/components/checkbox.rsindex e94c0c863d2..497b40bda72 100644--- a/crates/ui2/src/components/checkbox.rs+++ b/crates/ui2/src/components/checkbox.rs@@ -2,7 +2,7 @@ use gpui::{div, prelude::*, Div, Element, ElementId, RenderOnce, Styled, WindowCuse theme2::ActiveTheme;-use crate::{Icon, IconElement, Selection, TextColor};+use crate::{Color, Icon, IconElement, Selection};pub type CheckHandler = Box<dyn Fn(&Selection, &mut WindowContext) + 'static>;@@ -34,9 +34,9 @@ impl Component for Checkbox {.color(// If the checkbox is disabled we change the color of the icon.if self.disabled {- TextColor::Disabled+ Color::Disabled} else {- TextColor::Selected+ Color::Selected},),)@@ -49,9 +49,9 @@ impl Component for Checkbox {.color(// If the checkbox is disabled we change the color of the icon.if self.disabled {- TextColor::Disabled+ Color::Disabled} else {- TextColor::Selected+ Color::Selected},),)@@ -176,9 +176,9 @@ impl Checkbox {.color(// If the checkbox is disabled we change the color of the icon.if self.disabled {- TextColor::Disabled+ Color::Disabled} else {- TextColor::Selected+ Color::Selected},),)@@ -191,9 +191,9 @@ impl Checkbox {.color(// If the checkbox is disabled we change the color of the icon.if self.disabled {- TextColor::Disabled+ Color::Disabled} else {- TextColor::Selected+ Color::Selected},),)diff --git a/crates/ui2/src/components/disclosure.rs b/crates/ui2/src/components/disclosure.rsnew file mode 100644index 00000000000..3ec8c1953e2--- /dev/null+++ b/crates/ui2/src/components/disclosure.rs@@ -0,0 +1,19 @@+use gpui::{div, Element, ParentElement};++use crate::{Color, Icon, IconElement, IconSize, Toggle};++pub fn disclosure_control(toggle: Toggle) -> impl Element {+ match (toggle.is_toggleable(), toggle.is_toggled()) {+ (false, _) => div(),+ (_, true) => div().child(+ IconElement::new(Icon::ChevronDown)+ .color(Color::Muted)+ .size(IconSize::Small),+ ),+ (_, false) => div().child(+ IconElement::new(Icon::ChevronRight)+ .color(Color::Muted)+ .size(IconSize::Small),+ ),+ }+}diff --git a/crates/ui2/src/components/icon.rs b/crates/ui2/src/components/icon.rsindex d3f6e5d905e..67a4f0aac68 100644--- a/crates/ui2/src/components/icon.rs+++ b/crates/ui2/src/components/icon.rs@@ -23,6 +23,7 @@ pub enum Icon {BellOff,BellRing,Bolt,+ CaseSensitive,Check,ChevronDown,ChevronLeft,@@ -65,9 +66,8 @@ pub enum Icon {Split,SplitMessage,Terminal,- XCircle,WholeWord,- CaseSensitive,+ XCircle,}impl Icon {@@ -84,6 +84,7 @@ impl Icon {Icon::BellOff => "icons/bell-off.svg",Icon::BellRing => "icons/bell-ring.svg",Icon::Bolt => "icons/bolt.svg",+ Icon::CaseSensitive => "icons/case_insensitive.svg",Icon::Check => "icons/check.svg",Icon::ChevronDown => "icons/chevron_down.svg",Icon::ChevronLeft => "icons/chevron_left.svg",@@ -126,9 +127,8 @@ impl Icon {Icon::Split => "icons/split.svg",Icon::SplitMessage => "icons/split_message.svg",Icon::Terminal => "icons/terminal.svg",- Icon::XCircle => "icons/error.svg",Icon::WholeWord => "icons/word_search.svg",- Icon::CaseSensitive => "icons/case_insensitive.svg",+ Icon::XCircle => "icons/error.svg",}}}@@ -136,7 +136,7 @@ impl Icon {#[derive(RenderOnce)]pub struct IconElement {path: SharedString,- color: TextColor,+ color: Color,size: IconSize,}@@ -161,7 +161,7 @@ impl IconElement {pub fn new(icon: Icon) -> Self {Self {path: icon.path().into(),- color: TextColor::default(),+ color: Color::default(),size: IconSize::default(),}}@@ -169,12 +169,12 @@ impl IconElement {pub fn from_path(path: impl Into<SharedString>) -> Self {Self {path: path.into(),- color: TextColor::default(),+ color: Color::default(),size: IconSize::default(),}}- pub fn color(mut self, color: TextColor) -> Self {+ pub fn color(mut self, color: Color) -> Self {self.color = color;self}diff --git a/crates/ui2/src/components/icon_button.rs b/crates/ui2/src/components/icon_button.rsindex d2b816eb6d4..32848264c59 100644--- a/crates/ui2/src/components/icon_button.rs+++ b/crates/ui2/src/components/icon_button.rs@@ -5,7 +5,7 @@ use gpui::{prelude::*, Action, AnyView, Div, MouseButton, MouseDownEvent, Statefpub struct IconButton {id: ElementId,icon: Icon,- color: TextColor,+ color: Color,variant: ButtonVariant,state: InteractionState,selected: bool,@@ -18,8 +18,8 @@ impl Component for IconButton {fn render(self, cx: &mut WindowContext) -> Self::Rendered {let icon_color = match (self.state, self.color) {- (InteractionState::Disabled, _) => TextColor::Disabled,- (InteractionState::Active, _) => TextColor::Selected,+ (InteractionState::Disabled, _) => Color::Disabled,+ (InteractionState::Active, _) => Color::Selected,_ => self.color,};@@ -76,7 +76,7 @@ impl IconButton {Self {id: id.into(),icon,- color: TextColor::default(),+ color: Color::default(),variant: ButtonVariant::default(),state: InteractionState::default(),selected: false,@@ -90,7 +90,7 @@ impl IconButton {self}- pub fn color(mut self, color: TextColor) -> Self {+ pub fn color(mut self, color: Color) -> Self {self.color = color;self}diff --git a/crates/ui2/src/components/input.rs b/crates/ui2/src/components/input.rsindex f04186ff794..524e7a266e8 100644--- a/crates/ui2/src/components/input.rs+++ b/crates/ui2/src/components/input.rs@@ -36,15 +36,15 @@ impl Component for Input {};let placeholder_label = Label::new(self.placeholder.clone()).color(if self.disabled {- TextColor::Disabled+ Color::Disabled} else {- TextColor::Placeholder+ Color::Placeholder});let label = Label::new(self.value.clone()).color(if self.disabled {- TextColor::Disabled+ Color::Disabled} else {- TextColor::Default+ Color::Default});div()diff --git a/crates/ui2/src/components/label.rs b/crates/ui2/src/components/label.rsindex 6647d5d658d..ca301134f4d 100644--- a/crates/ui2/src/components/label.rs+++ b/crates/ui2/src/components/label.rs@@ -9,48 +9,6 @@ pub enum LabelSize {Small,}-#[derive(Default, PartialEq, Copy, Clone)]-pub enum TextColor {- #[default]- Default,- Accent,- Created,- Deleted,- Disabled,- Error,- Hidden,- Info,- Modified,- Muted,- Placeholder,- Player(u32),- Selected,- Success,- Warning,-}--impl TextColor {- pub fn color(&self, cx: &WindowContext) -> Hsla {- match self {- TextColor::Default => cx.theme().colors().text,- TextColor::Muted => cx.theme().colors().text_muted,- TextColor::Created => cx.theme().status().created,- TextColor::Modified => cx.theme().status().modified,- TextColor::Deleted => cx.theme().status().deleted,- TextColor::Disabled => cx.theme().colors().text_disabled,- TextColor::Hidden => cx.theme().status().hidden,- TextColor::Info => cx.theme().status().info,- TextColor::Placeholder => cx.theme().colors().text_placeholder,- TextColor::Accent => cx.theme().colors().text_accent,- TextColor::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,- TextColor::Error => cx.theme().status().error,- TextColor::Selected => cx.theme().colors().text_accent,- TextColor::Success => cx.theme().status().success,- TextColor::Warning => cx.theme().status().warning,- }- }-}-#[derive(Default, PartialEq, Copy, Clone)]pub enum LineHeightStyle {#[default]@@ -64,7 +22,7 @@ pub struct Label {label: SharedString,size: LabelSize,line_height_style: LineHeightStyle,- color: TextColor,+ color: Color,strikethrough: bool,}@@ -80,7 +38,7 @@ impl Component for Label {.top_1_2().w_full().h_px()- .bg(TextColor::Hidden.color(cx)),+ .bg(Color::Hidden.color(cx)),)}).map(|this| match self.size {@@ -101,7 +59,7 @@ impl Label {label: label.into(),size: LabelSize::Default,line_height_style: LineHeightStyle::default(),- color: TextColor::Default,+ color: Color::Default,strikethrough: false,}}@@ -111,7 +69,7 @@ impl Label {self}- pub fn color(mut self, color: TextColor) -> Self {+ pub fn color(mut self, color: Color) -> Self {self.color = color;self}@@ -131,7 +89,7 @@ impl Label {pub struct HighlightedLabel {label: SharedString,size: LabelSize,- color: TextColor,+ color: Color,highlight_indices: Vec<usize>,strikethrough: bool,}@@ -185,7 +143,7 @@ impl Component for HighlightedLabel {.my_auto().w_full().h_px()- .bg(TextColor::Hidden.color(cx)),+ .bg(Color::Hidden.color(cx)),)}).map(|this| match self.size {@@ -203,7 +161,7 @@ impl HighlightedLabel {Self {label: label.into(),size: LabelSize::Default,- color: TextColor::Default,+ color: Color::Default,highlight_indices,strikethrough: false,}@@ -214,7 +172,7 @@ impl HighlightedLabel {self}- pub fn color(mut self, color: TextColor) -> Self {+ pub fn color(mut self, color: Color) -> Self {self.color = color;self}diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rsindex 54758b38031..b054a568fcd 100644--- a/crates/ui2/src/components/list.rs+++ b/crates/ui2/src/components/list.rs@@ -47,7 +47,7 @@ impl Component for ListHeader {.items_center().children(icons.into_iter().map(|i| {IconElement::new(i)- .color(TextColor::Muted)+ .color(Color::Muted).size(IconSize::Small)})),),@@ -80,10 +80,10 @@ impl Component for ListHeader {.items_center().children(self.left_icon.map(|i| {IconElement::new(i)- .color(TextColor::Muted)+ .color(Color::Muted).size(IconSize::Small)}))- .child(Label::new(self.label.clone()).color(TextColor::Muted)),+ .child(Label::new(self.label.clone()).color(Color::Muted)),).child(disclosure_control),)@@ -222,10 +222,10 @@ impl Component for ListSubHeader {.items_center().children(self.left_icon.map(|i| {IconElement::new(i)- .color(TextColor::Muted)+ .color(Color::Muted).size(IconSize::Small)}))- .child(Label::new(self.label.clone()).color(TextColor::Muted)),+ .child(Label::new(self.label.clone()).color(Color::Muted)),),)}@@ -337,7 +337,7 @@ impl Component for ListItem {h_stack().child(IconElement::new(i).size(IconSize::Small)- .color(TextColor::Muted),+ .color(Color::Muted),),),Some(GraphicSlot::Avatar(src)) => Some(h_stack().child(Avatar::new(src))),@@ -432,9 +432,7 @@ impl Component for List {let list_content = match (self.children.is_empty(), self.toggle) {(false, _) => div().children(self.children),(true, Toggle::Toggled(false)) => div(),- (true, _) => {- div().child(Label::new(self.empty_message.clone()).color(TextColor::Muted))- }+ (true, _) => div().child(Label::new(self.empty_message.clone()).color(Color::Muted)),};v_stack()diff --git a/crates/ui2/src/components/stories/button.rs b/crates/ui2/src/components/stories/button.rsindex 819978945ee..a18f9d6b0cc 100644--- a/crates/ui2/src/components/stories/button.rs+++ b/crates/ui2/src/components/stories/button.rs@@ -4,7 +4,7 @@ pub use stories::*;#[cfg(feature = "stories")]mod stories {use super::*;- use crate::{h_stack, v_stack, Story, TextColor};+ use crate::{h_stack, v_stack, Color, Story};use gpui::{rems, Div, Render};use strum::IntoEnumIterator;diff --git a/crates/ui2/src/components/toggle.rs b/crates/ui2/src/components/toggle.rsindex fc086aea90d..2d56c06e55b 100644--- a/crates/ui2/src/components/toggle.rs+++ b/crates/ui2/src/components/toggle.rs@@ -1,7 +1,3 @@-use gpui::{div, Element, ParentElement};--use crate::{Icon, IconElement, IconSize, TextColor};-/// Whether the entry is toggleable, and if so, whether it is currently toggled.////// To make an element toggleable, simply add a `Toggle::Toggled(_)` and handle it's cases.@@ -43,19 +39,3 @@ impl From<bool> for Toggle {Toggle::Toggled(toggled)}}--pub fn disclosure_control(toggle: Toggle) -> impl Element {- match (toggle.is_toggleable(), toggle.is_toggled()) {- (false, _) => div(),- (_, true) => div().child(- IconElement::new(Icon::ChevronDown)- .color(TextColor::Muted)- .size(IconSize::Small),- ),- (_, false) => div().child(- IconElement::new(Icon::ChevronRight)- .color(TextColor::Muted)- .size(IconSize::Small),- ),- }-}diff --git a/crates/ui2/src/components/tooltip.rs b/crates/ui2/src/components/tooltip.rsindex 4a44bf81efc..10816dc7cd1 100644--- a/crates/ui2/src/components/tooltip.rs+++ b/crates/ui2/src/components/tooltip.rs@@ -3,7 +3,7 @@ use settings2::Settings;use theme2::{ActiveTheme, ThemeSettings};use crate::prelude::*;-use crate::{h_stack, v_stack, KeyBinding, Label, LabelSize, StyledExt, TextColor};+use crate::{h_stack, v_stack, Color, KeyBinding, Label, LabelSize, StyledExt};pub struct Tooltip {title: SharedString,@@ -90,11 +90,7 @@ impl Render for Tooltip {}),).when_some(self.meta.clone(), |this, meta| {- this.child(- Label::new(meta)- .size(LabelSize::Small)- .color(TextColor::Muted),- )+ this.child(Label::new(meta).size(LabelSize::Small).color(Color::Muted))}),),)diff --git a/crates/ui2/src/prelude.rs b/crates/ui2/src/prelude.rsindex fdd8af74dae..c3b52de84a0 100644--- a/crates/ui2/src/prelude.rs+++ b/crates/ui2/src/prelude.rs@@ -4,7 +4,7 @@ pub use gpui::{};pub use crate::StyledExt;-pub use crate::{ButtonVariant, TextColor};+pub use crate::{ButtonVariant, Color};pub use theme2::ActiveTheme;use strum::EnumIter;diff --git a/crates/ui2/src/styles.rs b/crates/ui2/src/styles.rsindex 210cb79b139..6caddc2cdbc 100644--- a/crates/ui2/src/styles.rs+++ b/crates/ui2/src/styles.rs@@ -1,4 +1,7 @@+mod color;mod elevation;mod typography;++pub use color::*;pub use elevation::*;pub use typography::*;diff --git a/crates/ui2/src/styles/color.rs b/crates/ui2/src/styles/color.rsnew file mode 100644index 00000000000..7d6e3290034--- /dev/null+++ b/crates/ui2/src/styles/color.rs@@ -0,0 +1,44 @@+use gpui::{Hsla, WindowContext};+use theme2::ActiveTheme;++#[derive(Default, PartialEq, Copy, Clone)]+pub enum Color {+ #[default]+ Default,+ Accent,+ Created,+ Deleted,+ Disabled,+ Error,+ Hidden,+ Info,+ Modified,+ Muted,+ Placeholder,+ Player(u32),+ Selected,+ Success,+ Warning,+}++impl Color {+ pub fn color(&self, cx: &WindowContext) -> Hsla {+ match self {+ Color::Default => cx.theme().colors().text,+ Color::Muted => cx.theme().colors().text_muted,+ Color::Created => cx.theme().status().created,+ Color::Modified => cx.theme().status().modified,+ Color::Deleted => cx.theme().status().deleted,+ Color::Disabled => cx.theme().colors().text_disabled,+ Color::Hidden => cx.theme().status().hidden,+ Color::Info => cx.theme().status().info,+ Color::Placeholder => cx.theme().colors().text_placeholder,+ Color::Accent => cx.theme().colors().text_accent,+ Color::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,+ Color::Error => cx.theme().status().error,+ Color::Selected => cx.theme().colors().text_accent,+ Color::Success => cx.theme().status().success,+ Color::Warning => cx.theme().status().warning,+ }+ }+}diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rsindex 1c558daa31b..cdc341d7dc4 100644--- a/crates/workspace2/src/pane.rs+++ b/crates/workspace2/src/pane.rs@@ -26,7 +26,7 @@ use std::{};use ui::v_stack;-use ui::{prelude::*, Icon, IconButton, IconElement, TextColor, Tooltip};+use ui::{prelude::*, Color, Icon, IconButton, IconElement, Tooltip};use util::truncate_and_remove_front;#[derive(PartialEq, Clone, Copy, Deserialize, Debug)]@@ -1425,12 +1425,12 @@ impl Pane {.then(|| {IconElement::new(Icon::ExclamationTriangle).size(ui::IconSize::Small)- .color(TextColor::Warning)+ .color(Color::Warning)}).or(item.is_dirty(cx).then(|| {IconElement::new(Icon::ExclamationTriangle).size(ui::IconSize::Small)- .color(TextColor::Info)+ .color(Color::Info)})),).children((!close_right).then(|| close_icon()))diff --git a/crates/workspace2/src/toolbar.rs b/crates/workspace2/src/toolbar.rsindex 298a7bee058..f69f096a3f3 100644--- a/crates/workspace2/src/toolbar.rs+++ b/crates/workspace2/src/toolbar.rs@@ -4,7 +4,7 @@ use gpui::{ViewContext, WindowContext,};use theme2::ActiveTheme;-use ui::{h_stack, v_stack, Button, Icon, IconButton, Label, TextColor};+use ui::{h_stack, v_stack, Button, Color, Icon, IconButton, Label};pub enum ToolbarItemEvent {ChangeLocation(ToolbarItemLocation),@@ -92,7 +92,7 @@ impl Render for Toolbar {h_stack().p_1().child(Button::new("crates"))- .child(Label::new("/").color(TextColor::Muted))+ .child(Label::new("/").color(Color::Muted)).child(Button::new("workspace2")),)// Toolbar right side