Refine default colors
This commit is contained in:
parent
e0cb95b334
commit
0efd69c60f
3 changed files with 131 additions and 92 deletions
|
@ -1,4 +1,4 @@
|
||||||
use gpui2::{hsla, Rgba};
|
use gpui2::{hsla, Hsla, Rgba};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
colors::{GitStatusColors, PlayerColor, PlayerColors, StatusColors, SystemColors, ThemeColors},
|
colors::{GitStatusColors, PlayerColor, PlayerColors, StatusColors, SystemColors, ThemeColors},
|
||||||
|
@ -6,6 +6,10 @@ use crate::{
|
||||||
syntax::SyntaxTheme,
|
syntax::SyntaxTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn neutral() -> DefaultColorScaleSet {
|
||||||
|
slate()
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for SystemColors {
|
impl Default for SystemColors {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -20,17 +24,17 @@ impl Default for SystemColors {
|
||||||
impl Default for StatusColors {
|
impl Default for StatusColors {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
conflict: gpui2::black(),
|
conflict: red().dark(11).into(),
|
||||||
created: gpui2::black(),
|
created: green().dark(11).into(),
|
||||||
deleted: gpui2::black(),
|
deleted: red().dark(11).into(),
|
||||||
error: gpui2::black(),
|
error: red().dark(11).into(),
|
||||||
hidden: gpui2::black(),
|
hidden: neutral().dark(11).into(),
|
||||||
ignored: gpui2::black(),
|
ignored: neutral().dark(11).into(),
|
||||||
info: gpui2::black(),
|
info: blue().dark(11).into(),
|
||||||
modified: gpui2::black(),
|
modified: yellow().dark(11).into(),
|
||||||
renamed: gpui2::black(),
|
renamed: blue().dark(11).into(),
|
||||||
success: gpui2::black(),
|
success: green().dark(11).into(),
|
||||||
warning: gpui2::black(),
|
warning: yellow().dark(11).into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,12 +42,12 @@ impl Default for StatusColors {
|
||||||
impl Default for GitStatusColors {
|
impl Default for GitStatusColors {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
conflict: gpui2::rgba(0xdec184ff).into(),
|
conflict: orange().dark(11),
|
||||||
created: gpui2::rgba(0xa1c181ff).into(),
|
created: green().dark(11),
|
||||||
deleted: gpui2::rgba(0xd07277ff).into(),
|
deleted: red().dark(11),
|
||||||
ignored: gpui2::rgba(0x555a63ff).into(),
|
ignored: green().dark(11),
|
||||||
modified: gpui2::rgba(0x74ade8ff).into(),
|
modified: yellow().dark(11),
|
||||||
renamed: gpui2::rgba(0xdec184ff).into(),
|
renamed: blue().dark(11),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,82 +193,86 @@ impl SyntaxTheme {
|
||||||
|
|
||||||
impl ThemeColors {
|
impl ThemeColors {
|
||||||
pub fn default_light() -> Self {
|
pub fn default_light() -> Self {
|
||||||
|
let system = SystemColors::default();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
border: gpui2::white(),
|
border: neutral().light(6).into(),
|
||||||
border_variant: gpui2::white(),
|
border_variant: neutral().light(5).into(),
|
||||||
border_focused: gpui2::white(),
|
border_focused: blue().light(5).into(),
|
||||||
border_transparent: gpui2::white(),
|
border_transparent: system.transparent,
|
||||||
elevated_surface: gpui2::white(),
|
elevated_surface: neutral().light(2).into(),
|
||||||
surface: gpui2::white(),
|
surface: neutral().light(2).into(),
|
||||||
background: gpui2::white(),
|
background: neutral().light(1).into(),
|
||||||
element: gpui2::white(),
|
element: neutral().light(3).into(),
|
||||||
element_hover: gpui2::white(),
|
element_hover: neutral().light(4).into(),
|
||||||
element_active: gpui2::white(),
|
element_active: neutral().light(5).into(),
|
||||||
element_selected: gpui2::white(),
|
element_selected: neutral().light(5).into(),
|
||||||
element_disabled: gpui2::white(),
|
element_disabled: neutral().light_alpha(3).into(),
|
||||||
element_placeholder: gpui2::white(),
|
element_placeholder: neutral().light(11).into(),
|
||||||
ghost_element: gpui2::white(),
|
ghost_element: system.transparent,
|
||||||
ghost_element_hover: gpui2::white(),
|
ghost_element_hover: neutral().light(4).into(),
|
||||||
ghost_element_active: gpui2::white(),
|
ghost_element_active: neutral().light(5).into(),
|
||||||
ghost_element_selected: gpui2::white(),
|
ghost_element_selected: neutral().light(5).into(),
|
||||||
ghost_element_disabled: gpui2::white(),
|
ghost_element_disabled: neutral().light_alpha(3).into(),
|
||||||
text: gpui2::white(),
|
text: neutral().light(12).into(),
|
||||||
text_muted: gpui2::white(),
|
text_muted: neutral().light(11).into(),
|
||||||
text_placeholder: gpui2::white(),
|
text_placeholder: neutral().light(11).into(),
|
||||||
text_disabled: gpui2::white(),
|
text_disabled: neutral().light(10).into(),
|
||||||
text_accent: gpui2::white(),
|
text_accent: blue().light(12).into(),
|
||||||
icon: gpui2::white(),
|
icon: neutral().light(12).into(),
|
||||||
icon_muted: gpui2::white(),
|
icon_muted: neutral().light(11).into(),
|
||||||
icon_disabled: gpui2::white(),
|
icon_disabled: neutral().light(10).into(),
|
||||||
icon_placeholder: gpui2::white(),
|
icon_placeholder: neutral().light(11).into(),
|
||||||
icon_accent: gpui2::white(),
|
icon_accent: blue().light(12).into(),
|
||||||
status_bar: gpui2::white(),
|
status_bar: neutral().light(2).into(),
|
||||||
title_bar: gpui2::white(),
|
title_bar: neutral().light(2).into(),
|
||||||
toolbar: gpui2::white(),
|
toolbar: neutral().light(2).into(),
|
||||||
tab_bar: gpui2::white(),
|
tab_bar: neutral().light(2).into(),
|
||||||
editor: gpui2::white(),
|
editor: neutral().light(1).into(),
|
||||||
editor_subheader: gpui2::white(),
|
editor_subheader: neutral().light(2).into(),
|
||||||
editor_active_line: gpui2::white(),
|
editor_active_line: neutral().light_alpha(3).into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_dark() -> Self {
|
pub fn default_dark() -> Self {
|
||||||
|
let system = SystemColors::default();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
border: gpui2::rgba(0x464b57ff).into(),
|
border: neutral().dark(6).into(),
|
||||||
border_variant: gpui2::rgba(0x464b57ff).into(),
|
border_variant: neutral().dark(5).into(),
|
||||||
border_focused: gpui2::rgba(0x293b5bff).into(),
|
border_focused: blue().dark(5).into(),
|
||||||
border_transparent: gpui2::rgba(0x00000000).into(),
|
border_transparent: system.transparent,
|
||||||
elevated_surface: gpui2::rgba(0x3b414dff).into(),
|
elevated_surface: neutral().dark(2).into(),
|
||||||
surface: gpui2::rgba(0x2f343eff).into(),
|
surface: neutral().dark(2).into(),
|
||||||
background: gpui2::rgba(0x3b414dff).into(),
|
background: neutral().dark(1).into(),
|
||||||
element: gpui2::rgba(0x3b414dff).into(),
|
element: neutral().dark(3).into(),
|
||||||
element_hover: gpui2::rgba(0xffffff1e).into(),
|
element_hover: neutral().dark(4).into(),
|
||||||
element_active: gpui2::rgba(0xffffff28).into(),
|
element_active: neutral().dark(5).into(),
|
||||||
element_selected: gpui2::rgba(0x18243dff).into(),
|
element_selected: neutral().dark(5).into(),
|
||||||
element_disabled: gpui2::rgba(0x00000000).into(),
|
element_disabled: neutral().dark_alpha(3).into(),
|
||||||
element_placeholder: gpui2::black(),
|
element_placeholder: neutral().dark(11).into(),
|
||||||
ghost_element: gpui2::rgba(0x00000000).into(),
|
ghost_element: system.transparent,
|
||||||
ghost_element_hover: gpui2::rgba(0xffffff14).into(),
|
ghost_element_hover: neutral().dark(4).into(),
|
||||||
ghost_element_active: gpui2::rgba(0xffffff1e).into(),
|
ghost_element_active: neutral().dark(5).into(),
|
||||||
ghost_element_selected: gpui2::rgba(0x18243dff).into(),
|
ghost_element_selected: neutral().dark(5).into(),
|
||||||
ghost_element_disabled: gpui2::rgba(0x00000000).into(),
|
ghost_element_disabled: neutral().dark_alpha(3).into(),
|
||||||
text: gpui2::rgba(0xc8ccd4ff).into(),
|
text: neutral().dark(12).into(),
|
||||||
text_muted: gpui2::rgba(0x838994ff).into(),
|
text_muted: neutral().dark(11).into(),
|
||||||
text_placeholder: gpui2::rgba(0xd07277ff).into(),
|
text_placeholder: neutral().dark(11).into(),
|
||||||
text_disabled: gpui2::rgba(0x555a63ff).into(),
|
text_disabled: neutral().dark(10).into(),
|
||||||
text_accent: gpui2::rgba(0x74ade8ff).into(),
|
text_accent: blue().dark(12).into(),
|
||||||
icon: gpui2::black(),
|
icon: neutral().dark(12).into(),
|
||||||
icon_muted: gpui2::rgba(0x838994ff).into(),
|
icon_muted: neutral().dark(11).into(),
|
||||||
icon_disabled: gpui2::black(),
|
icon_disabled: neutral().dark(10).into(),
|
||||||
icon_placeholder: gpui2::black(),
|
icon_placeholder: neutral().dark(11).into(),
|
||||||
icon_accent: gpui2::black(),
|
icon_accent: blue().dark(12).into(),
|
||||||
status_bar: gpui2::rgba(0x3b414dff).into(),
|
status_bar: neutral().dark(2).into(),
|
||||||
title_bar: gpui2::rgba(0x3b414dff).into(),
|
title_bar: neutral().dark(2).into(),
|
||||||
toolbar: gpui2::rgba(0x282c33ff).into(),
|
toolbar: neutral().dark(2).into(),
|
||||||
tab_bar: gpui2::rgba(0x2f343eff).into(),
|
tab_bar: neutral().dark(2).into(),
|
||||||
editor: gpui2::rgba(0x282c33ff).into(),
|
editor: neutral().dark(1).into(),
|
||||||
editor_subheader: gpui2::rgba(0x2f343eff).into(),
|
editor_subheader: neutral().dark(2).into(),
|
||||||
editor_active_line: gpui2::rgba(0x2f343eff).into(),
|
editor_active_line: neutral().dark_alpha(3).into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,6 +285,25 @@ struct DefaultColorScaleSet {
|
||||||
dark_alpha: [&'static str; 12],
|
dark_alpha: [&'static str; 12],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See [ColorScaleSet] for why we use index-1.
|
||||||
|
impl DefaultColorScaleSet {
|
||||||
|
pub fn light(&self, index: usize) -> Hsla {
|
||||||
|
self.light[index - 1].into()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn light_alpha(&self, index: usize) -> Hsla {
|
||||||
|
self.light_alpha[index - 1].into()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dark(&self, index: usize) -> Hsla {
|
||||||
|
self.dark[index - 1].into()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dark_alpha(&self, index: usize) -> Hsla {
|
||||||
|
self.dark_alpha[index - 1].into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<DefaultColorScaleSet> for ColorScaleSet {
|
impl From<DefaultColorScaleSet> for ColorScaleSet {
|
||||||
fn from(default: DefaultColorScaleSet) -> Self {
|
fn from(default: DefaultColorScaleSet) -> Self {
|
||||||
Self::new(
|
Self::new(
|
||||||
|
|
|
@ -70,6 +70,18 @@ impl ThemeVariant {
|
||||||
&self.styles.syntax
|
&self.styles.syntax
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the [`StatusColors`] for the theme.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn status(&self) -> &StatusColors {
|
||||||
|
&self.styles.status
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the [`GitStatusColors`] for the theme.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn git(&self) -> &GitStatusColors {
|
||||||
|
&self.styles.git
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the color for the syntax node with the given name.
|
/// Returns the color for the syntax node with the given name.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn syntax_color(&self, name: &str) -> Hsla {
|
pub fn syntax_color(&self, name: &str) -> Hsla {
|
||||||
|
|
|
@ -21,11 +21,11 @@ impl LabelColor {
|
||||||
match self {
|
match self {
|
||||||
Self::Default => cx.theme().colors().text,
|
Self::Default => cx.theme().colors().text,
|
||||||
Self::Muted => cx.theme().colors().text_muted,
|
Self::Muted => cx.theme().colors().text_muted,
|
||||||
Self::Created => gpui2::red(),
|
Self::Created => cx.theme().status().created,
|
||||||
Self::Modified => gpui2::red(),
|
Self::Modified => cx.theme().status().modified,
|
||||||
Self::Deleted => gpui2::red(),
|
Self::Deleted => cx.theme().status().deleted,
|
||||||
Self::Disabled => cx.theme().colors().text_disabled,
|
Self::Disabled => cx.theme().colors().text_disabled,
|
||||||
Self::Hidden => gpui2::red(),
|
Self::Hidden => cx.theme().status().hidden,
|
||||||
Self::Placeholder => cx.theme().colors().text_placeholder,
|
Self::Placeholder => cx.theme().colors().text_placeholder,
|
||||||
Self::Accent => cx.theme().colors().text_accent,
|
Self::Accent => cx.theme().colors().text_accent,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue