remove transitional scaffold roles from ResolvedColors

This commit is contained in:
2026-10-08 09:00:58 +07:00
parent 02b9cc238f
commit af20a1b150
4 changed files with 9 additions and 146 deletions
-1
View File
@@ -1,4 +1,3 @@
#![allow(dead_code)]
use std::collections::BTreeMap;
use std::sync::OnceLock;
+1 -10
View File
@@ -1,5 +1,3 @@
#![allow(dead_code)]
use std::collections::{BTreeMap, HashSet};
use std::fmt;
use std::str::FromStr;
@@ -352,14 +350,7 @@ impl AccentRoles {
},
if appearance.is_dark() { 0.28 } else { 0.18 },
);
let deep = primary.mix(
if appearance.is_dark() {
Color::BLACK
} else {
Color::BLACK
},
if appearance.is_dark() { 0.18 } else { 0.26 },
);
let deep = primary.mix(Color::BLACK, if appearance.is_dark() { 0.18 } else { 0.26 });
Self {
primary,
strong,
+6 -133
View File
@@ -1,10 +1,8 @@
#![allow(dead_code)] // transitional: scaffold fields die in Phase 5, unconsumed roles live on
use gpui::Hsla;
use crate::model::{AccentRoles, Color, ThemeColors, ThemeVariant};
use crate::model::{AccentRoles, ThemeColors, ThemeVariant};
fn hsla(color: Color) -> Hsla {
fn hsla(color: crate::model::Color) -> Hsla {
let packed = ((color.r as u32) << 24)
| ((color.g as u32) << 16)
| ((color.b as u32) << 8)
@@ -12,6 +10,9 @@ fn hsla(color: Color) -> Hsla {
Hsla::from(gpui::rgba(packed))
}
/// The accent roles a component can consume, pre-resolved to `Hsla` together
/// with the derived states (hover/active, contrast-safe text) that several
/// components need; computing them here keeps call sites free of color math.
#[derive(Debug, Clone, Copy)]
pub struct ResolvedAccentRoles {
pub primary: Hsla,
@@ -59,11 +60,6 @@ impl ResolvedAccentRoles {
/// The `Hsla` snapshot components render from, rebuilt whenever the active
/// variant, accent, or appearance changes.
///
/// The fields after `diff_hunk` are a transitional scaffold (D6): they keep the
/// removed role names alive — computed from zeron roles — so the ~51 downstream
/// files keep compiling until the Phase 3 rewrite retires them, one by one.
/// Everything below `drop_target_background` is deleted in Phase 5.
#[derive(Debug, Clone, Copy)]
pub struct ResolvedColors {
pub background: Hsla,
@@ -92,68 +88,10 @@ pub struct ResolvedColors {
pub diff_add: Hsla,
pub diff_delete: Hsla,
pub diff_hunk: Hsla,
// Transitional scaffold — delete in Phase 5.
pub surface_background: Hsla,
pub elevated_surface_background: Hsla,
pub panel_background: Hsla,
pub border_variant: Hsla,
pub border_focused: Hsla,
pub border_selected: Hsla,
pub border_transparent: Hsla,
pub ring: Hsla,
pub selection: Hsla,
pub text_placeholder: Hsla,
pub text_accent: Hsla,
pub text_danger: Hsla,
pub text_warning: Hsla,
pub icon: Hsla,
pub icon_muted: Hsla,
pub icon_accent: Hsla,
pub element_background: Hsla,
pub element_foreground: Hsla,
pub element_hover: Hsla,
pub element_active: Hsla,
pub element_selected: Hsla,
pub element_disabled: Hsla,
pub secondary_background: Hsla,
pub secondary_foreground: Hsla,
pub secondary_hover: Hsla,
pub secondary_active: Hsla,
pub secondary_selected: Hsla,
pub secondary_disabled: Hsla,
pub danger_foreground: Hsla,
pub danger_background: Hsla,
pub danger_hover: Hsla,
pub danger_active: Hsla,
pub danger_selected: Hsla,
pub danger_disabled: Hsla,
pub warning_foreground: Hsla,
pub warning_background: Hsla,
pub warning_hover: Hsla,
pub warning_active: Hsla,
pub warning_selected: Hsla,
pub warning_disabled: Hsla,
pub ghost_element_background: Hsla,
pub ghost_element_background_alt: Hsla,
pub ghost_element_hover: Hsla,
pub ghost_element_active: Hsla,
pub ghost_element_selected: Hsla,
pub ghost_element_disabled: Hsla,
pub tab_background: Hsla,
pub tab_foreground: Hsla,
pub tab_hover_background: Hsla,
pub tab_active_background: Hsla,
pub tab_active_foreground: Hsla,
pub scrollbar_thumb_background: Hsla,
pub scrollbar_thumb_hover_background: Hsla,
pub scrollbar_thumb_border: Hsla,
pub scrollbar_track_background: Hsla,
pub scrollbar_track_border: Hsla,
pub drop_target_background: Hsla,
}
impl ResolvedColors {
pub fn resolve(variant: &ThemeVariant, accent: &AccentRoles) -> Self {
pub fn resolve(variant: &ThemeVariant) -> Self {
let colors = variant.colors.clone();
let ThemeColors {
background,
@@ -184,10 +122,6 @@ impl ResolvedColors {
diff_hunk,
} = colors;
let transparent = Color::rgba(0, 0, 0, 0);
let danger_tint = danger_muted;
let warning_tint = warning_muted;
Self {
background: hsla(background),
shell: hsla(shell),
@@ -215,67 +149,6 @@ impl ResolvedColors {
diff_add: hsla(diff_add),
diff_delete: hsla(diff_delete),
diff_hunk: hsla(diff_hunk),
surface_background: hsla(shell),
elevated_surface_background: hsla(raised),
panel_background: hsla(shell),
border_variant: hsla(border),
border_focused: hsla(accent.primary),
border_selected: hsla(accent.primary),
border_transparent: hsla(transparent),
ring: hsla(accent.primary),
selection: hsla(accent.selection),
text_placeholder: hsla(text_faint),
text_accent: hsla(accent.primary),
text_danger: hsla(danger),
text_warning: hsla(warning),
icon: hsla(text_muted),
icon_muted: hsla(text_faint),
icon_accent: hsla(accent.primary),
element_background: hsla(accent.primary),
element_foreground: hsla(accent.on),
element_hover: hsla(accent.primary.mix(background, 0.12)),
element_active: hsla(accent.primary.mix(background, 0.2)),
element_selected: hsla(accent.primary.mix(background, 0.28)),
element_disabled: hsla(accent.primary.with_alpha(0.3)),
secondary_background: hsla(accent.wash),
secondary_foreground: hsla(
accent
.primary
.ensure_contrast(accent.wash.blend_over(background), 4.5),
),
secondary_hover: hsla(accent.selection),
secondary_active: hsla(accent.selection),
secondary_selected: hsla(accent.selection),
secondary_disabled: hsla(accent.wash.with_alpha(0.5)),
danger_foreground: hsla(danger.ensure_contrast(danger_tint, 4.5)),
danger_background: hsla(danger_tint),
danger_hover: hsla(danger.with_alpha(0.15)),
danger_active: hsla(danger.with_alpha(0.25)),
danger_selected: hsla(danger.with_alpha(0.25)),
danger_disabled: hsla(danger.with_alpha(0.12)),
warning_foreground: hsla(warning.ensure_contrast(warning_tint, 4.5)),
warning_background: hsla(warning_tint),
warning_hover: hsla(warning.with_alpha(0.15)),
warning_active: hsla(warning.with_alpha(0.25)),
warning_selected: hsla(warning.with_alpha(0.25)),
warning_disabled: hsla(warning.with_alpha(0.12)),
ghost_element_background: hsla(transparent),
ghost_element_background_alt: hsla(raised),
ghost_element_hover: hsla(hover),
ghost_element_active: hsla(active),
ghost_element_selected: hsla(active),
ghost_element_disabled: hsla(border.with_alpha(0.4)),
tab_background: hsla(shell),
tab_foreground: hsla(text_muted),
tab_hover_background: hsla(hover),
tab_active_background: hsla(background),
tab_active_foreground: hsla(text),
scrollbar_thumb_background: hsla(border.with_alpha(0.7)),
scrollbar_thumb_hover_background: hsla(border_strong),
scrollbar_thumb_border: hsla(transparent),
scrollbar_track_background: hsla(transparent),
scrollbar_track_border: hsla(border),
drop_target_background: hsla(accent.selection),
}
}
}
+2 -2
View File
@@ -115,7 +115,7 @@ impl Theme {
let accent = variant.accent_for(AccentSelection::default());
let surface = SurfacePreference::default().resolve(variant.recommended_surface_treatment);
let resolved_accent = ResolvedAccentRoles::resolve(&accent, &variant.colors);
let colors = ResolvedColors::resolve(&variant, &accent);
let colors = ResolvedColors::resolve(&variant);
Self {
variant: Arc::new(variant),
@@ -204,7 +204,7 @@ impl Theme {
let variant = registry.resolve(&selection, appearance).clone();
let accent = variant.accent_for(accent_selection);
let surface = surface_preference.resolve(variant.recommended_surface_treatment);
let colors = ResolvedColors::resolve(&variant, &accent);
let colors = ResolvedColors::resolve(&variant);
{
let theme = cx.global_mut::<Theme>();