From 584a70ca5e290180b810e9414f1c8aee59f2067b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Cerm=C3=A1k?= Date: Wed, 19 Mar 2025 15:26:36 +0100 Subject: [PATCH] Refactor Git panel styling & status colors for consistency (#26951) Closes #26847 Release Notes: - Updated Git panel background to use panel_background instead of ElevationIndex::Surface.bg(cx) for consistency with other panels. - Removed redundant GitStatusColors struct from status.rs and refactored to use existing theme colors. - Adjusted Color enum mappings in color.rs to reference version_control_* colors instead of status() for better alignment with the theme system. - Cleaned up unused or redundant code. --- crates/editor/src/items.rs | 8 ++++---- crates/git_ui/src/git_panel.rs | 8 ++++---- crates/theme/src/styles/status.rs | 20 -------------------- crates/ui/src/styles/color.rs | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 200556b85e..39c041892f 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1673,13 +1673,13 @@ pub fn entry_diagnostic_aware_icon_decoration_and_color( pub fn entry_git_aware_label_color(git_status: GitSummary, ignored: bool, selected: bool) -> Color { let tracked = git_status.index + git_status.worktree; if ignored { - Color::Ignored + Color::VersionControlIgnored } else if git_status.conflict > 0 { - Color::Conflict + Color::VersionControlConflict } else if tracked.modified > 0 { - Color::Modified + Color::VersionControlModified } else if tracked.added > 0 || git_status.untracked > 0 { - Color::Created + Color::VersionControlAdded } else { entry_label_color(selected) } diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index c54f9d7b87..93cd4eba55 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -3532,14 +3532,14 @@ impl GitPanel { let label_color = if status_style == StatusStyle::LabelColor { if has_conflict { - Color::Conflict + Color::VersionControlConflict } else if is_modified { - Color::Modified + Color::VersionControlModified } else if is_deleted { // We don't want a bunch of red labels in the list Color::Disabled } else { - Color::Created + Color::VersionControlAdded } } else { Color::Default @@ -3808,7 +3808,7 @@ impl Render for GitPanel { })) .size_full() .overflow_hidden() - .bg(ElevationIndex::Surface.bg(cx)) + .bg(cx.theme().colors().panel_background) .child( v_flex() .size_full() diff --git a/crates/theme/src/styles/status.rs b/crates/theme/src/styles/status.rs index 9f9ec52d58..ab333ecb3e 100644 --- a/crates/theme/src/styles/status.rs +++ b/crates/theme/src/styles/status.rs @@ -86,15 +86,6 @@ pub struct DiagnosticColors { pub info: Hsla, } -pub struct GitStatusColors { - pub created: Hsla, - pub deleted: Hsla, - pub modified: Hsla, - pub renamed: Hsla, - pub conflict: Hsla, - pub ignored: Hsla, -} - impl StatusColors { pub fn dark() -> Self { Self { @@ -197,15 +188,4 @@ impl StatusColors { info: self.info, } } - - pub fn git(&self) -> GitStatusColors { - GitStatusColors { - created: self.created, - deleted: self.deleted, - modified: self.modified, - renamed: self.renamed, - conflict: self.conflict, - ignored: self.ignored, - } - } } diff --git a/crates/ui/src/styles/color.rs b/crates/ui/src/styles/color.rs index 7c632a711a..1cd32f32b0 100644 --- a/crates/ui/src/styles/color.rs +++ b/crates/ui/src/styles/color.rs @@ -58,6 +58,16 @@ pub enum Color { Selected, /// A color used to indicate a successful operation or status. Success, + /// A version control color used to indicate a newly added file or content in version control. + VersionControlAdded, + /// A version control color used to indicate conflicting changes that need resolution. + VersionControlConflict, + /// A version control color used to indicate a file or content that has been deleted in version control. + VersionControlDeleted, + /// A version control color used to indicate files or content that is being ignored by version control. + VersionControlIgnored, + /// A version control color used to indicate modified files or content in version control. + VersionControlModified, /// A color used to indicate a warning condition. Warning, } @@ -84,6 +94,11 @@ impl Color { Color::Error => cx.theme().status().error, Color::Selected => cx.theme().colors().text_accent, Color::Success => cx.theme().status().success, + Color::VersionControlAdded => cx.theme().colors().version_control_added, + Color::VersionControlConflict => cx.theme().colors().version_control_conflict, + Color::VersionControlDeleted => cx.theme().colors().version_control_deleted, + Color::VersionControlIgnored => cx.theme().colors().version_control_ignored, + Color::VersionControlModified => cx.theme().colors().version_control_modified, Color::Warning => cx.theme().status().warning, Color::Custom(color) => *color, }