Pull git indicator colors out of theme

Co-Authored-By: Kay Simmons <kay@zed.dev>
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Julia 2022-09-19 19:25:59 -04:00
parent 632f47930f
commit 8d2de1074b
5 changed files with 23 additions and 5 deletions

View File

@ -545,10 +545,19 @@ impl EditorElement {
}
}
let (inserted_color, modified_color, deleted_color) = {
let editor = &cx.global::<Settings>().theme.editor;
(
editor.diff_background_inserted,
editor.diff_background_modified,
editor.diff_background_deleted,
)
};
for hunk in &layout.diff_hunks {
let color = match hunk.status() {
DiffHunkStatus::Added => Color::green(),
DiffHunkStatus::Modified => Color::blue(),
DiffHunkStatus::Added => inserted_color,
DiffHunkStatus::Modified => modified_color,
//TODO: This rendering is entirely a horrible hack
DiffHunkStatus::Removed => {
@ -565,7 +574,7 @@ impl EditorElement {
cx.scene.push_quad(Quad {
bounds: highlight_bounds,
background: Some(Color::red()),
background: Some(deleted_color),
border: Border::new(0., Color::transparent_black()),
corner_radius: 1. * line_height,
});

View File

@ -490,6 +490,7 @@ pub struct Editor {
pub document_highlight_write_background: Color,
pub diff_background_deleted: Color,
pub diff_background_inserted: Color,
pub diff_background_modified: Color,
pub line_number: Color,
pub line_number_active: Color,
pub guest_selections: Vec<SelectionStyle>,

View File

@ -7,6 +7,7 @@ import {
player,
popoverShadow,
text,
textColor,
TextColor,
} from "./components";
import hoverPopover from "./hoverPopover";
@ -59,8 +60,9 @@ export default function editor(theme: Theme) {
indicator: iconColor(theme, "secondary"),
verticalScale: 0.618
},
diffBackgroundDeleted: backgroundColor(theme, "error"),
diffBackgroundInserted: backgroundColor(theme, "ok"),
diffBackgroundDeleted: theme.ramps.red(0.3).hex(),
diffBackgroundInserted: theme.ramps.green(0.3).hex(),
diffBackgroundModified: theme.ramps.blue(0.3).hex(),
documentHighlightReadBackground: theme.editor.highlight.occurrence,
documentHighlightWriteBackground: theme.editor.highlight.activeOccurrence,
errorColor: theme.textColor.error,

View File

@ -113,6 +113,11 @@ export function createTheme(
hovered: sample(ramps.blue, 0.1),
active: sample(ramps.blue, 0.15),
},
on500Ok: {
base: sample(ramps.green, 0.05),
hovered: sample(ramps.green, 0.1),
active: sample(ramps.green, 0.15)
}
};
const borderColor = {

View File

@ -78,6 +78,7 @@ export default interface Theme {
// Hacks for elements on top of the editor
on500: BackgroundColorSet;
ok: BackgroundColorSet;
on500Ok: BackgroundColorSet;
error: BackgroundColorSet;
on500Error: BackgroundColorSet;
warning: BackgroundColorSet;