Theme · Editing: segments that give way, every color named

SegmentedControl's segments now give way when narrow, their labels
ending in an ellipsis, down to twice a control's height each; past
that the strip scrolls as before. The pill's border and padding moved
onto the scrolling strip, and the row inside it takes that floor as its
least width, so the strip scrolls exactly to its last segment. The
palette macro now writes each color's name from its field: Palette and
Syntax gain NAMES and token_mut for every color, the quiet fills too.
Tests press a density segment and each slider, and fit the density
strip in 280px with the text a step and a half larger.
This commit is contained in:
ZacharyZhang-NY committed 2026-09-27 16:48:07 -04:00
1 parent 9160fdc931
commit 84bc45df5f
5 files changed
+167 -121

No files matched your search

+22 -5
View File
@@ -1,6 +1,6 @@
use gpui::{TestAppContext, hsla};
use super::{ActiveTheme, Mode, Palette, Theme};
use super::{ActiveTheme, Mode, Palette, Syntax, Theme};
/// An owner's palette serves its own mode; the other keeps Ely's, and none brings Ely's back.
#[gpui::test]
@@ -19,12 +19,29 @@ fn an_owners_palette_serves_its_mode_alone(cx: &mut TestAppContext) {
assert_eq!(cx.read(|cx| cx.theme().palette()), Palette::light(false));
}
/// Every color of the palette and of code answers to its field's name, the quiet fills too.
#[test]
fn every_named_color_answers() {
fn every_color_answers_to_its_name() {
let mut palette = Palette::light(false);
*palette.token_mut("accent") = hsla(0.1, 0.2, 0.3, 1.0);
assert_eq!(palette.accent, hsla(0.1, 0.2, 0.3, 1.0));
*palette.syntax.token_mut("comment") = hsla(0.4, 0.2, 0.3, 1.0);
for (ix, name) in Palette::NAMES.iter().enumerate() {
*palette.token_mut(name) = hsla(ix as f32 / 64.0, 0.5, 0.5, 1.0);
}
assert_eq!(Palette::NAMES.len(), 35, "every color of the palette");
let at = |name: &str| {
Palette::NAMES
.iter()
.position(|each| *each == name)
.expect("a name")
};
assert_eq!(
palette.success_subtle,
hsla(at("success_subtle") as f32 / 64.0, 0.5, 0.5, 1.0)
);
assert_eq!(palette.ink, hsla(at("ink") as f32 / 64.0, 0.5, 0.5, 1.0));
for name in Syntax::NAMES {
*palette.syntax.token_mut(name) = hsla(0.4, 0.2, 0.3, 1.0);
}
assert_eq!(Syntax::NAMES.len(), 13, "every color of code");
assert_eq!(palette.syntax.comment, hsla(0.4, 0.2, 0.3, 1.0));
}