Revert "Touch up git in project panel and scroll bar styling"

This commit is contained in:
Mikayla Maki 2023-05-22 15:31:14 -07:00 committed by GitHub
parent dcf4791182
commit 2d1c4a1971
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 90 deletions

View file

@ -7253,6 +7253,7 @@ impl View for Editor {
} }
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) { fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
dbg!("Editor Focus in");
if cx.is_self_focused() { if cx.is_self_focused() {
let focused_event = EditorFocused(cx.handle()); let focused_event = EditorFocused(cx.handle());
cx.emit(Event::Focused); cx.emit(Event::Focused);

View file

@ -6,7 +6,7 @@ use gpui::{
actions, actions,
anyhow::{anyhow, Result}, anyhow::{anyhow, Result},
elements::{ elements::{
AnchorCorner, ChildView, ContainerStyle, Empty, Flex, Label, MouseEventHandler, AnchorCorner, ChildView, ComponentHost, ContainerStyle, Empty, Flex, MouseEventHandler,
ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState, ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState,
}, },
geometry::vector::Vector2F, geometry::vector::Vector2F,
@ -28,7 +28,7 @@ use std::{
path::Path, path::Path,
sync::Arc, sync::Arc,
}; };
use theme::ProjectPanelEntry; use theme::{ui::FileName, ProjectPanelEntry};
use unicase::UniCase; use unicase::UniCase;
use workspace::Workspace; use workspace::Workspace;
@ -1079,17 +1079,6 @@ impl ProjectPanel {
let kind = details.kind; let kind = details.kind;
let show_editor = details.is_editing && !details.is_processing; let show_editor = details.is_editing && !details.is_processing;
let mut filename_text_style = style.text.clone();
filename_text_style.color = details
.git_status
.as_ref()
.map(|status| match status {
GitFileStatus::Added => style.status.git.inserted,
GitFileStatus::Modified => style.status.git.modified,
GitFileStatus::Conflict => style.status.git.conflict,
})
.unwrap_or(style.text.color);
Flex::row() Flex::row()
.with_child( .with_child(
if kind == EntryKind::Dir { if kind == EntryKind::Dir {
@ -1117,7 +1106,11 @@ impl ProjectPanel {
.flex(1.0, true) .flex(1.0, true)
.into_any() .into_any()
} else { } else {
Label::new(details.filename.clone(), filename_text_style) ComponentHost::new(FileName::new(
details.filename.clone(),
details.git_status,
FileName::style(style.text.clone(), &theme::current(cx)),
))
.contained() .contained()
.with_margin_left(style.icon_spacing) .with_margin_left(style.icon_spacing)
.aligned() .aligned()

View file

@ -446,19 +446,6 @@ pub struct ProjectPanelEntry {
pub icon_color: Color, pub icon_color: Color,
pub icon_size: f32, pub icon_size: f32,
pub icon_spacing: f32, pub icon_spacing: f32,
pub status: EntryStatus,
}
#[derive(Clone, Debug, Deserialize, Default)]
pub struct EntryStatus {
pub git: GitProjectStatus,
}
#[derive(Clone, Debug, Deserialize, Default)]
pub struct GitProjectStatus {
pub modified: Color,
pub inserted: Color,
pub conflict: Color,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize, Default)]
@ -683,14 +670,6 @@ pub struct Scrollbar {
pub thumb: ContainerStyle, pub thumb: ContainerStyle,
pub width: f32, pub width: f32,
pub min_height_factor: f32, pub min_height_factor: f32,
pub git: GitDiffColors,
}
#[derive(Clone, Deserialize, Default)]
pub struct GitDiffColors {
pub inserted: Color,
pub modified: Color,
pub deleted: Color,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default)]

View file

@ -1,9 +1,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use fs::repository::GitFileStatus;
use gpui::{ use gpui::{
color::Color, color::Color,
elements::{ elements::{
ConstrainedBox, Container, ContainerStyle, Empty, Flex, KeystrokeLabel, Label, ConstrainedBox, Container, ContainerStyle, Empty, Flex, KeystrokeLabel, Label, LabelStyle,
MouseEventHandler, ParentElement, Stack, Svg, MouseEventHandler, ParentElement, Stack, Svg,
}, },
fonts::TextStyle, fonts::TextStyle,
@ -11,11 +12,11 @@ use gpui::{
platform, platform,
platform::MouseButton, platform::MouseButton,
scene::MouseClick, scene::MouseClick,
Action, Element, EventContext, MouseState, View, ViewContext, Action, AnyElement, Element, EventContext, MouseState, View, ViewContext,
}; };
use serde::Deserialize; use serde::Deserialize;
use crate::{ContainedText, Interactive}; use crate::{ContainedText, Interactive, Theme};
#[derive(Clone, Deserialize, Default)] #[derive(Clone, Deserialize, Default)]
pub struct CheckboxStyle { pub struct CheckboxStyle {
@ -252,3 +253,53 @@ where
.constrained() .constrained()
.with_height(style.dimensions().y()) .with_height(style.dimensions().y())
} }
pub struct FileName {
filename: String,
git_status: Option<GitFileStatus>,
style: FileNameStyle,
}
pub struct FileNameStyle {
template_style: LabelStyle,
git_inserted: Color,
git_modified: Color,
git_deleted: Color,
}
impl FileName {
pub fn new(filename: String, git_status: Option<GitFileStatus>, style: FileNameStyle) -> Self {
FileName {
filename,
git_status,
style,
}
}
pub fn style<I: Into<LabelStyle>>(style: I, theme: &Theme) -> FileNameStyle {
FileNameStyle {
template_style: style.into(),
git_inserted: theme.editor.diff.inserted,
git_modified: theme.editor.diff.modified,
git_deleted: theme.editor.diff.deleted,
}
}
}
impl<V: View> gpui::elements::Component<V> for FileName {
fn render(&self, _: &mut V, _: &mut ViewContext<V>) -> AnyElement<V> {
// Prepare colors for git statuses
let mut filename_text_style = self.style.template_style.text.clone();
filename_text_style.color = self
.git_status
.as_ref()
.map(|status| match status {
GitFileStatus::Added => self.style.git_inserted,
GitFileStatus::Modified => self.style.git_modified,
GitFileStatus::Conflict => self.style.git_deleted,
})
.unwrap_or(self.style.template_style.text.color);
Label::new(self.filename.clone(), filename_text_style).into_any()
}
}

View file

@ -3,10 +3,9 @@ import { ColorScheme, Layer, StyleSets } from "../themes/common/colorScheme"
import { background, border, borderColor, foreground, text } from "./components" import { background, border, borderColor, foreground, text } from "./components"
import hoverPopover from "./hoverPopover" import hoverPopover from "./hoverPopover"
import { buildSyntax } from "../themes/common/syntax" import { SyntaxHighlightStyle, buildSyntax } from "../themes/common/syntax"
export default function editor(colorScheme: ColorScheme) { export default function editor(colorScheme: ColorScheme) {
const { isLight } = colorScheme
let layer = colorScheme.highest let layer = colorScheme.highest
const autocompleteItem = { const autocompleteItem = {
@ -98,18 +97,12 @@ export default function editor(colorScheme: ColorScheme) {
foldBackground: foreground(layer, "variant"), foldBackground: foreground(layer, "variant"),
}, },
diff: { diff: {
deleted: isLight deleted: foreground(layer, "negative"),
? colorScheme.ramps.red(0.5).hex() modified: foreground(layer, "warning"),
: colorScheme.ramps.red(0.4).hex(), inserted: foreground(layer, "positive"),
modified: isLight
? colorScheme.ramps.yellow(0.3).hex()
: colorScheme.ramps.yellow(0.5).hex(),
inserted: isLight
? colorScheme.ramps.green(0.4).hex()
: colorScheme.ramps.green(0.5).hex(),
removedWidthEm: 0.275, removedWidthEm: 0.275,
widthEm: 0.15, widthEm: 0.22,
cornerRadius: 0.05, cornerRadius: 0.2,
}, },
/** Highlights matching occurences of what is under the cursor /** Highlights matching occurences of what is under the cursor
* as well as matched brackets * as well as matched brackets
@ -241,27 +234,12 @@ export default function editor(colorScheme: ColorScheme) {
border: border(layer, "variant", { left: true }), border: border(layer, "variant", { left: true }),
}, },
thumb: { thumb: {
background: withOpacity(background(layer, "inverted"), 0.3), background: withOpacity(background(layer, "inverted"), 0.4),
border: { border: {
width: 1, width: 1,
color: borderColor(layer, "variant"), color: borderColor(layer, "variant"),
top: false,
right: true,
left: true,
bottom: false,
}, },
}, },
git: {
deleted: isLight
? withOpacity(colorScheme.ramps.red(0.5).hex(), 0.8)
: withOpacity(colorScheme.ramps.red(0.4).hex(), 0.8),
modified: isLight
? withOpacity(colorScheme.ramps.yellow(0.5).hex(), 0.8)
: withOpacity(colorScheme.ramps.yellow(0.4).hex(), 0.8),
inserted: isLight
? withOpacity(colorScheme.ramps.green(0.5).hex(), 0.8)
: withOpacity(colorScheme.ramps.green(0.4).hex(), 0.8),
}
}, },
compositionMark: { compositionMark: {
underline: { underline: {

View file

@ -3,7 +3,6 @@ import { withOpacity } from "../utils/color"
import { background, border, foreground, text } from "./components" import { background, border, foreground, text } from "./components"
export default function projectPanel(colorScheme: ColorScheme) { export default function projectPanel(colorScheme: ColorScheme) {
const { isLight } = colorScheme
let layer = colorScheme.middle let layer = colorScheme.middle
let baseEntry = { let baseEntry = {
@ -13,20 +12,6 @@ export default function projectPanel(colorScheme: ColorScheme) {
iconSpacing: 8, iconSpacing: 8,
} }
let status = {
git: {
modified: isLight
? colorScheme.ramps.yellow(0.6).hex()
: colorScheme.ramps.yellow(0.5).hex(),
inserted: isLight
? colorScheme.ramps.green(0.45).hex()
: colorScheme.ramps.green(0.5).hex(),
conflict: isLight
? colorScheme.ramps.red(0.6).hex()
: colorScheme.ramps.red(0.5).hex()
}
}
let entry = { let entry = {
...baseEntry, ...baseEntry,
text: text(layer, "mono", "variant", { size: "sm" }), text: text(layer, "mono", "variant", { size: "sm" }),
@ -43,7 +28,6 @@ export default function projectPanel(colorScheme: ColorScheme) {
background: background(layer, "active"), background: background(layer, "active"),
text: text(layer, "mono", "active", { size: "sm" }), text: text(layer, "mono", "active", { size: "sm" }),
}, },
status
} }
return { return {
@ -75,7 +59,6 @@ export default function projectPanel(colorScheme: ColorScheme) {
entry, entry,
draggedEntry: { draggedEntry: {
...baseEntry, ...baseEntry,
status,
text: text(layer, "mono", "on", { size: "sm" }), text: text(layer, "mono", "on", { size: "sm" }),
background: withOpacity(background(layer, "on"), 0.9), background: withOpacity(background(layer, "on"), 0.9),
border: border(layer), border: border(layer),
@ -96,6 +79,6 @@ export default function projectPanel(colorScheme: ColorScheme) {
background: background(layer, "on"), background: background(layer, "on"),
text: text(layer, "mono", "on", { size: "sm" }), text: text(layer, "mono", "on", { size: "sm" }),
selection: colorScheme.players[0], selection: colorScheme.players[0],
} },
} }
} }