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.
This commit is contained in:
Jakub Čermák 2025-03-19 15:26:36 +01:00 committed by GitHub
parent 2230f3b09d
commit 584a70ca5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 28 deletions

View file

@ -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 { pub fn entry_git_aware_label_color(git_status: GitSummary, ignored: bool, selected: bool) -> Color {
let tracked = git_status.index + git_status.worktree; let tracked = git_status.index + git_status.worktree;
if ignored { if ignored {
Color::Ignored Color::VersionControlIgnored
} else if git_status.conflict > 0 { } else if git_status.conflict > 0 {
Color::Conflict Color::VersionControlConflict
} else if tracked.modified > 0 { } else if tracked.modified > 0 {
Color::Modified Color::VersionControlModified
} else if tracked.added > 0 || git_status.untracked > 0 { } else if tracked.added > 0 || git_status.untracked > 0 {
Color::Created Color::VersionControlAdded
} else { } else {
entry_label_color(selected) entry_label_color(selected)
} }

View file

@ -3532,14 +3532,14 @@ impl GitPanel {
let label_color = if status_style == StatusStyle::LabelColor { let label_color = if status_style == StatusStyle::LabelColor {
if has_conflict { if has_conflict {
Color::Conflict Color::VersionControlConflict
} else if is_modified { } else if is_modified {
Color::Modified Color::VersionControlModified
} else if is_deleted { } else if is_deleted {
// We don't want a bunch of red labels in the list // We don't want a bunch of red labels in the list
Color::Disabled Color::Disabled
} else { } else {
Color::Created Color::VersionControlAdded
} }
} else { } else {
Color::Default Color::Default
@ -3808,7 +3808,7 @@ impl Render for GitPanel {
})) }))
.size_full() .size_full()
.overflow_hidden() .overflow_hidden()
.bg(ElevationIndex::Surface.bg(cx)) .bg(cx.theme().colors().panel_background)
.child( .child(
v_flex() v_flex()
.size_full() .size_full()

View file

@ -86,15 +86,6 @@ pub struct DiagnosticColors {
pub info: Hsla, 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 { impl StatusColors {
pub fn dark() -> Self { pub fn dark() -> Self {
Self { Self {
@ -197,15 +188,4 @@ impl StatusColors {
info: self.info, 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,
}
}
} }

View file

@ -58,6 +58,16 @@ pub enum Color {
Selected, Selected,
/// A color used to indicate a successful operation or status. /// A color used to indicate a successful operation or status.
Success, 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. /// A color used to indicate a warning condition.
Warning, Warning,
} }
@ -84,6 +94,11 @@ impl Color {
Color::Error => cx.theme().status().error, Color::Error => cx.theme().status().error,
Color::Selected => cx.theme().colors().text_accent, Color::Selected => cx.theme().colors().text_accent,
Color::Success => cx.theme().status().success, 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::Warning => cx.theme().status().warning,
Color::Custom(color) => *color, Color::Custom(color) => *color,
} }