ZIm/crates/git_ui/src/git_ui.rs
Marshall Bowers 9f87145af9
title_bar: Simplify git-ui feature flag check (#23475)
This PR is a follow-up to
https://github.com/zed-industries/zed/pull/23470 that simplifies the way
we check the `git-ui` feature flag in the title bar.

Release Notes:

- N/A
2025-01-22 17:28:47 +00:00

46 lines
1.1 KiB
Rust

use ::settings::Settings;
use git::status::FileStatus;
use git_panel_settings::GitPanelSettings;
use gpui::{AppContext, Hsla};
use ui::{Color, Icon, IconName, IntoElement};
pub mod git_panel;
mod git_panel_settings;
pub mod repository_selector;
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 {
let (icon_name, color) = if status.is_conflicted() {
(IconName::Warning, REMOVED_COLOR)
} else if status.is_deleted() {
(IconName::SquareMinus, REMOVED_COLOR)
} else if status.is_modified() {
(IconName::SquareDot, MODIFIED_COLOR)
} else {
(IconName::SquarePlus, ADDED_COLOR)
};
Icon::new(icon_name).color(Color::Custom(color))
}