git_ui.rs

 1use ::settings::Settings;
 2use git::status::FileStatus;
 3use git_panel_settings::GitPanelSettings;
 4use gpui::{AppContext, Hsla};
 5use ui::{Color, Icon, IconName, IntoElement};
 6
 7pub mod git_panel;
 8mod git_panel_settings;
 9pub mod repository_selector;
10
11pub fn init(cx: &mut AppContext) {
12    GitPanelSettings::register(cx);
13}
14
15const ADDED_COLOR: Hsla = Hsla {
16    h: 142. / 360.,
17    s: 0.68,
18    l: 0.45,
19    a: 1.0,
20};
21const MODIFIED_COLOR: Hsla = Hsla {
22    h: 48. / 360.,
23    s: 0.76,
24    l: 0.47,
25    a: 1.0,
26};
27const REMOVED_COLOR: Hsla = Hsla {
28    h: 355. / 360.,
29    s: 0.65,
30    l: 0.65,
31    a: 1.0,
32};
33
34// TODO: Add updated status colors to theme
35pub fn git_status_icon(status: FileStatus) -> impl IntoElement {
36    let (icon_name, color) = if status.is_conflicted() {
37        (IconName::Warning, REMOVED_COLOR)
38    } else if status.is_deleted() {
39        (IconName::SquareMinus, REMOVED_COLOR)
40    } else if status.is_modified() {
41        (IconName::SquareDot, MODIFIED_COLOR)
42    } else {
43        (IconName::SquarePlus, ADDED_COLOR)
44    };
45    Icon::new(icon_name).color(Color::Custom(color))
46}