theme: Add version control colors (#23529)

This PR adds version control-specific theme tokens to the them to allow
styling entries in the git ui and elsewhere.

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2025-01-23 07:56:49 -05:00 committed by GitHub
parent 828b5ab975
commit f9e354ee9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 222 additions and 34 deletions

View file

@ -1083,13 +1083,15 @@ impl GitPanel {
let mut label_color = cx.theme().colors().text;
if status_style == StatusStyle::LabelColor {
label_color = if status.is_conflicted() {
cx.theme().status().conflict
cx.theme().colors().version_control_conflict
} else if status.is_modified() {
cx.theme().status().modified
cx.theme().colors().version_control_modified
} else if status.is_deleted() {
// Don't use `version_control_deleted` here or all the
// deleted entries will be likely a red color.
cx.theme().colors().text_disabled
} else {
cx.theme().status().created
cx.theme().colors().version_control_added
}
}
@ -1185,7 +1187,7 @@ impl GitPanel {
}),
)
.when(status_style == StatusStyle::Icon, |this| {
this.child(git_status_icon(status))
this.child(git_status_icon(status, cx))
})
.child(
h_flex()

View file

@ -1,8 +1,8 @@
use ::settings::Settings;
use git::status::FileStatus;
use git_panel_settings::GitPanelSettings;
use gpui::{AppContext, Hsla};
use ui::{Color, Icon, IconName, IntoElement};
use gpui::AppContext;
use ui::{ActiveTheme, Color, Icon, IconName, IntoElement, WindowContext};
pub mod git_panel;
mod git_panel_settings;
@ -12,35 +12,28 @@ pub fn init(cx: &mut AppContext) {
GitPanelSettings::register(cx);
}
const ADDED_COLOR: Hsla = Hsla {
h: 142. / 360.,
s: 0.68,
l: 0.45,
a: 1.0,
};
const MODIFIED_COLOR: Hsla = Hsla {
h: 48. / 360.,
s: 0.76,
l: 0.47,
a: 1.0,
};
const REMOVED_COLOR: Hsla = Hsla {
h: 355. / 360.,
s: 0.65,
l: 0.65,
a: 1.0,
};
// TODO: Add updated status colors to theme
pub fn git_status_icon(status: FileStatus) -> impl IntoElement {
pub fn git_status_icon(status: FileStatus, cx: &WindowContext) -> impl IntoElement {
let (icon_name, color) = if status.is_conflicted() {
(IconName::Warning, REMOVED_COLOR)
(
IconName::Warning,
cx.theme().colors().version_control_conflict,
)
} else if status.is_deleted() {
(IconName::SquareMinus, REMOVED_COLOR)
(
IconName::SquareMinus,
cx.theme().colors().version_control_deleted,
)
} else if status.is_modified() {
(IconName::SquareDot, MODIFIED_COLOR)
(
IconName::SquareDot,
cx.theme().colors().version_control_modified,
)
} else {
(IconName::SquarePlus, ADDED_COLOR)
(
IconName::SquarePlus,
cx.theme().colors().version_control_added,
)
};
Icon::new(icon_name).color(Color::Custom(color))
}