Per-tab accent tokens: fill, ink and tint for every tab, with a contrast guard

This commit is contained in:
Nathan Dane
2026-10-20 12:25:01 +02:00
parent a5e0fe3ec4
commit f2eaead594
10 changed files with 264 additions and 68 deletions
+36
View File
@@ -81,6 +81,24 @@ impl Tokens {
mesh_accent: Color32::from_rgb(130, 103, 0),
form_accent: Color32::from_rgb(115, 73, 205),
render_accent: Color32::from_rgb(174, 45, 113),
sketch_ink: Color32::from_rgb(5, 127, 69),
sketch_soft: Color32::from_rgb(237, 247, 241),
surface_fill: Color32::from_rgb(164, 80, 0),
surface_ink: Color32::from_rgb(164, 80, 0),
surface_soft: Color32::from_rgb(251, 235, 216),
mesh_fill: Color32::from_rgb(224, 178, 0),
mesh_ink: Color32::from_rgb(138, 109, 0),
mesh_soft: Color32::from_rgb(255, 248, 220),
form_fill: Color32::from_rgb(115, 73, 205),
form_tab_ink: Color32::from_rgb(115, 73, 205),
form_soft: Color32::from_rgb(238, 232, 250),
sheet_fill: Color32::from_rgb(30, 111, 150),
sheet_ink: Color32::from_rgb(30, 111, 150),
sheet_soft: Color32::from_rgb(225, 240, 247),
render_fill: Color32::from_rgb(168, 50, 110),
render_ink: Color32::from_rgb(168, 50, 110),
render_soft: Color32::from_rgb(248, 230, 239),
tab_on_fill_dark: Color32::BLACK,
on_accent: Color32::WHITE,
agent_ok: Color32::from_rgb(76, 194, 122),
agent_busy: Color32::from_rgb(108, 180, 240),
@@ -256,6 +274,24 @@ impl Tokens {
t.mesh_accent = Color32::from_rgb(133, 113, 0);
t.form_accent = Color32::from_rgb(123, 99, 166);
t.render_accent = Color32::from_rgb(224, 116, 174);
t.sketch_ink = Color32::from_rgb(70, 190, 120);
t.sketch_soft = Color32::from_rgb(31, 59, 43);
t.surface_fill = Color32::from_rgb(178, 106, 20);
t.surface_ink = Color32::from_rgb(224, 145, 74);
t.surface_soft = Color32::from_rgb(69, 51, 30);
t.mesh_fill = Color32::from_rgb(198, 168, 0);
t.mesh_ink = Color32::from_rgb(212, 183, 38);
t.mesh_soft = Color32::from_rgb(65, 57, 26);
t.form_fill = Color32::from_rgb(138, 111, 204);
t.form_tab_ink = Color32::from_rgb(179, 155, 238);
t.form_soft = Color32::from_rgb(55, 47, 79);
t.sheet_fill = Color32::from_rgb(42, 127, 168);
t.sheet_ink = Color32::from_rgb(79, 179, 217);
t.sheet_soft = Color32::from_rgb(31, 58, 71);
t.render_fill = Color32::from_rgb(200, 88, 143);
t.render_ink = Color32::from_rgb(224, 116, 174);
t.render_soft = Color32::from_rgb(64, 35, 54);
t.tab_on_fill_dark = Color32::BLACK;
t.dialog_body = Color32::from_rgb(59, 68, 83);
t.dialog_footer = Color32::from_rgb(47, 52, 62);
t.dialog_rule = Color32::from_rgb(53, 59, 71);
+2 -5
View File
@@ -424,11 +424,8 @@ pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp {
icons::paint_icon(ui.painter(), ir, row.icon, if row.dim { DIM_ICON_OPACITY } else { 1.0 });
x += 21.0;
}
let col = if row.selected {
crate::theme::selected_ink(&t, crate::theme::TabAccent::current(ui.ctx()).color)
} else {
row.color.unwrap_or(if row.dim { t.text_dim } else { t.text })
};
let col =
if row.selected { crate::theme::TabAccent::current(ui.ctx()).ink } else { row.color.unwrap_or(if row.dim { t.text_dim } else { t.text }) };
let label_display = if row.name { crate::i18n::tr_name(row.label) } else { crate::i18n::tr_dyn(row.label) };
let font = if row.selected { crate::fonts::semibold(t.font_label) } else { FontId::proportional(t.font_label) };
let galley = ui.painter().layout_no_wrap(label_display, font, col);
+25 -20
View File
@@ -45,28 +45,33 @@ fn browser_card_shrinks_and_scrolls_without_covering_history() {
#[test]
fn selected_row_paints_tab_soft_fill_and_accent_text_in_both_layouts() {
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
for tab in ["MODEL", "SURFACE", "SKETCH"] {
let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(Default::default(), Default::default());
app.ui.layout = mode;
app.ui.tab = tab.into();
crate::theme::TabAccent::publish(&app, &ctx);
let accent = crate::theme::TabAccent::for_tab(&Tokens::get(), tab);
let mut row_rect = Rect::NOTHING;
let out = crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
let row = Row { selected: true, label: "Selected body", dim: true, color: Some(Tokens::get().error), ..Default::default() };
row_rect = draw_row(ui, egui::Id::new("selected-row"), &row).rect.unwrap();
});
assert_eq!(row_rect.height(), 26.0);
assert!(out.shapes.iter().any(|s| matches!(&s.shape, egui::Shape::Rect(r) if r.rect == row_rect && r.fill == accent.soft)));
assert!(
out.shapes
.iter()
.any(|s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == "Selected body" && t.fallback_color == crate::theme::selected_ink(&Tokens::get(), accent.color)))
);
let previous = crate::theme::is_dark();
for dark in [false, true] {
crate::theme::set_dark(dark);
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
for tab in ["MODEL", "SKETCH", "SURFACE", "MESH", "FORM", "SHEET METAL", "RENDER"] {
let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(Default::default(), Default::default());
app.ui.layout = mode;
app.ui.tab = tab.into();
crate::theme::TabAccent::publish(&app, &ctx);
let accent = crate::theme::TabAccent::for_tab(&Tokens::get(), tab);
let mut row_rect = Rect::NOTHING;
let out = crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
let row = Row { selected: true, label: "Selected body", dim: true, color: Some(Tokens::get().error), ..Default::default() };
row_rect = draw_row(ui, egui::Id::new("selected-row"), &row).rect.unwrap();
});
assert_eq!(row_rect.height(), 26.0);
assert!(out.shapes.iter().any(|s| matches!(&s.shape, egui::Shape::Rect(r) if r.rect == row_rect && r.fill == accent.soft)));
assert!(
out.shapes
.iter()
.any(|s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == "Selected body" && t.fallback_color == accent.ink))
);
}
}
}
crate::theme::set_dark(previous);
}
#[test]
+23
View File
@@ -367,6 +367,29 @@ fn groups(t: &Tokens) -> Vec<Group> {
group("agent status", &[("agent_ok", t.agent_ok), ("agent_busy", t.agent_busy)], &[("app_bar", t.app_bar)]),
group("logo", &[("logo[0]", t.logo[0]), ("logo[1]", t.logo[1]), ("logo[2]", t.logo[2])], &[("app_bar", t.app_bar)]),
];
// Tab fills and small-text inks have distinct jobs: compare each with its actual
// grounds, rather than with the same-hue fill/ink. WCAG text ratios are also guarded
// in theme::tests::tab_accents_hold_wcag_small_text_contrast_in_both_themes.
for (name, ink_name, ink, soft_name, soft) in [
("sketch tab text", "sketch_ink", t.sketch_ink, "sketch_soft", t.sketch_soft),
("surface tab text", "surface_ink", t.surface_ink, "surface_soft", t.surface_soft),
("mesh tab text", "mesh_ink", t.mesh_ink, "mesh_soft", t.mesh_soft),
("form tab text", "form_tab_ink", t.form_tab_ink, "form_soft", t.form_soft),
("sheet tab text", "sheet_ink", t.sheet_ink, "sheet_soft", t.sheet_soft),
("render tab text", "render_ink", t.render_ink, "render_soft", t.render_soft),
] {
out.push(group(name, &[(ink_name, ink)], &[(soft_name, soft), ("panel", t.panel)]));
}
for (name, key, fill) in [
("surface tab fill", "surface_fill", t.surface_fill),
("mesh tab fill", "mesh_fill", t.mesh_fill),
("form tab fill", "form_fill", t.form_fill),
("sheet tab fill", "sheet_fill", t.sheet_fill),
("render tab fill", "render_fill", t.render_fill),
] {
out.push(group(name, &[(key, fill)], &[("panel", t.panel)]));
}
out.push(group("dark pill text", &[("tab_on_fill_dark", t.tab_on_fill_dark)], &[("mesh_fill", t.mesh_fill)]));
// The removed part of a cut preview is translucent over the body.
if let Some(sel) = out.iter_mut().find(|g| g.name == "selection") {
sel.members.push(("preview_cut", over(t.preview_cut, t.body)));
+4 -6
View File
@@ -1788,14 +1788,12 @@ fn workspace_menu(ui: &mut egui::Ui, items: &[Item], key_row: Option<usize>, hei
};
let planned = tabs.is_none();
let current = item.shortcut == "current";
let accent = if planned {
t.text_dim
} else if slug == "render" {
t.render_accent
let (accent, soft) = if !planned && slug == "render" {
(t.render_fill, t.render_soft)
} else {
t.accent
let accent = if planned { t.text_dim } else { t.accent };
(accent, t.panel.lerp_to_gamma(accent, 0.10))
};
let soft = t.panel.lerp_to_gamma(accent, 0.10);
let (r, resp) = ui
.allocate_exact_size(vec2(450.0, if planned { 60.0 } else { 72.0 }), if item.enabled { Sense::click() } else { Sense::hover() });
for handle in [format!("menu:{}", item.id), format!("workspace:menu:{slug}")] {
+109 -27
View File
@@ -45,34 +45,41 @@ pub fn set_custom(custom: Option<Custom>) -> bool {
#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) struct TabAccent {
pub color: Color32,
pub ink: Color32,
pub soft: Color32,
}
/// The foreground of a selected element on its tinted background: light blue in the dark theme,
/// a darker blue in the light theme. Other accents (Sketch green…) get the same treatment.
pub(crate) fn selected_ink(t: &Tokens, accent: Color32) -> Color32 {
if accent == t.accent {
t.selected_ink
} else if is_dark() {
accent.lerp_to_gamma(t.on_accent, 0.5)
} else {
accent.lerp_to_gamma(Color32::BLACK, 0.3)
}
/// WCAG contrast of two opaque sRGB colours.
fn contrast_ratio(a: Color32, b: Color32) -> f64 {
let luminance = |c: Color32| {
let linear = |v: u8| {
let v = f64::from(v) / 255.0;
if v <= 0.04045 { v / 12.92 } else { ((v + 0.055) / 1.055).powf(2.4) }
};
0.2126 * linear(c.r()) + 0.7152 * linear(c.g()) + 0.0722 * linear(c.b())
};
let (a, b) = (luminance(a), luminance(b));
(a.max(b) + 0.05) / (a.min(b) + 0.05)
}
impl TabAccent {
pub fn for_tab(t: &Tokens, tab: &str) -> Self {
let color = match tab {
"SKETCH" => t.sketch_accent,
"SURFACE" => t.surface_accent,
"MESH" => t.mesh_accent,
"FORM" => t.form_accent,
_ => t.accent,
let (color, ink, soft) = match tab {
"SKETCH" => (t.sketch_accent, t.sketch_ink, t.sketch_soft),
"SURFACE" => (t.surface_fill, t.surface_ink, t.surface_soft),
"MESH" => (t.mesh_fill, t.mesh_ink, t.mesh_soft),
"FORM" => (t.form_fill, t.form_tab_ink, t.form_soft),
"SHEET METAL" => (t.sheet_fill, t.sheet_ink, t.sheet_soft),
"RENDER" => (t.render_fill, t.render_ink, t.render_soft),
// Model and shared utility tabs retain their existing selection exactly.
_ => (t.accent, t.selected_ink, t.accent_soft),
};
// Preserve the existing Solid selection exactly. Other tabs blend against the same
// panel surface in either theme rather than introducing independent palette entries.
let soft = if color == t.accent { t.accent_soft } else { t.panel.lerp_to_gamma(color, 0.18) };
Self { color, soft }
Self { color, ink, soft }
}
/// Small text on a tab's solid pill. Brighter fills need dark ink in either theme.
pub fn on_fill(self, t: &Tokens) -> Color32 {
if contrast_ratio(t.on_accent, self.color) >= 4.5 { t.on_accent } else { t.tab_on_fill_dark }
}
pub fn current(ctx: &egui::Context) -> Self {
@@ -331,6 +338,27 @@ pub struct Tokens {
pub mesh_accent: Color32,
pub form_accent: Color32,
pub render_accent: Color32,
/// Per-tab fills, small-text inks and selected-row tints. Sketch reuses sketch_accent.
/// The other fill keys preserve the legacy *_accent values used by other surfaces.
pub sketch_ink: Color32,
pub sketch_soft: Color32,
pub surface_fill: Color32,
pub surface_ink: Color32,
pub surface_soft: Color32,
pub mesh_fill: Color32,
pub mesh_ink: Color32,
pub mesh_soft: Color32,
pub form_fill: Color32,
pub form_tab_ink: Color32,
pub form_soft: Color32,
pub sheet_fill: Color32,
pub sheet_ink: Color32,
pub sheet_soft: Color32,
pub render_fill: Color32,
pub render_ink: Color32,
pub render_soft: Color32,
/// Dark text for tab pills whose fill has insufficient contrast with on_accent.
pub tab_on_fill_dark: Color32,
/// Ink on accent-filled buttons and selection chips.
pub on_accent: Color32,
/// Agent status on the dark application bar, in either theme.
@@ -580,24 +608,78 @@ pub fn apply(ctx: &egui::Context) {
#[cfg(test)]
mod tests {
#[test]
fn tab_accents_map_tokens_and_derive_selection_without_changing_solid() {
fn tab_accents_map_explicit_tokens_without_changing_model() {
for dark in [false, true] {
for vision in super::ColorVision::ALL {
let t = super::Tokens::themed(dark, vision);
for (tab, color) in [("SKETCH", t.sketch_accent), ("SURFACE", t.surface_accent), ("MESH", t.mesh_accent), ("FORM", t.form_accent)] {
// Explicit palette tints and text replace the old gamma lerps. They can be
// overridden independently by theme files and hold small-text contrast.
for (tab, color, ink, soft) in [
("SKETCH", t.sketch_accent, t.sketch_ink, t.sketch_soft),
("SURFACE", t.surface_fill, t.surface_ink, t.surface_soft),
("MESH", t.mesh_fill, t.mesh_ink, t.mesh_soft),
("FORM", t.form_fill, t.form_tab_ink, t.form_soft),
("SHEET METAL", t.sheet_fill, t.sheet_ink, t.sheet_soft),
("RENDER", t.render_fill, t.render_ink, t.render_soft),
] {
let accent = super::TabAccent::for_tab(&t, tab);
assert_eq!(accent.color, color);
assert_eq!(accent.soft, t.panel.lerp_to_gamma(color, 0.18));
assert_eq!(accent, super::TabAccent { color, ink, soft });
assert_ne!(accent.soft, color);
assert_ne!(accent.soft, t.panel);
}
for tab in ["MODEL", "ASSEMBLE", "INSERT", "INSPECT", "MANAGE", "VIEW", "SHEET METAL", "RENDER", "unknown"] {
assert_eq!(super::TabAccent::for_tab(&t, tab), super::TabAccent { color: t.accent, soft: t.accent_soft });
for tab in ["MODEL", "SOLID", "ASSEMBLE", "INSERT", "INSPECT", "MANAGE", "VIEW", "unknown"] {
assert_eq!(super::TabAccent::for_tab(&t, tab), super::TabAccent { color: t.accent, ink: t.selected_ink, soft: t.accent_soft });
}
}
}
}
#[test]
fn tab_accents_match_approved_palette() {
let rgb = |hex: u32| egui::Color32::from_rgb((hex >> 16) as u8, (hex >> 8) as u8, hex as u8);
for (tab, light, dark) in [
("SKETCH", [0x057f45, 0x057f45, 0xedf7f1], [0x128d45, 0x46be78, 0x1f3b2b]),
("SURFACE", [0xa45000, 0xa45000, 0xfbebd8], [0xb26a14, 0xe0914a, 0x45331e]),
("MESH", [0xe0b200, 0x8a6d00, 0xfff8dc], [0xc6a800, 0xd4b726, 0x41391a]),
("FORM", [0x7349cd, 0x7349cd, 0xeee8fa], [0x8a6fcc, 0xb39bee, 0x372f4f]),
("SHEET METAL", [0x1e6f96, 0x1e6f96, 0xe1f0f7], [0x2a7fa8, 0x4fb3d9, 0x1f3a47]),
("RENDER", [0xa8326e, 0xa8326e, 0xf8e6ef], [0xc8588f, 0xe074ae, 0x402336]),
] {
for (t, values) in [(super::Tokens::light(), light), (super::Tokens::dark(), dark)] {
let [color, ink, soft] = values.map(rgb);
assert_eq!(super::TabAccent::for_tab(&t, tab), super::TabAccent { color, ink, soft }, "{tab}");
}
let accent = super::TabAccent::for_tab(&super::Tokens::light(), tab);
assert_eq!(accent.ink != accent.color, tab == "MESH", "only light Mesh separates ink from fill");
}
// These existing Model values intentionally take precedence over the board's proposal.
for (t, values) in [(super::Tokens::light(), [0x2678da, 0x1a507f, 0xd6e6fa]), (super::Tokens::dark(), [0x3a88ee, 0x9cc7f5, 0x2a466e])] {
let [color, ink, soft] = values.map(rgb);
assert_eq!(super::TabAccent::for_tab(&t, "MODEL"), super::TabAccent { color, ink, soft });
}
}
#[test]
fn tab_accents_hold_wcag_small_text_contrast_in_both_themes() {
for (dark, t) in [(false, super::Tokens::light()), (true, super::Tokens::dark())] {
for tab in ["MODEL", "SKETCH", "SURFACE", "MESH", "FORM", "SHEET METAL", "RENDER"] {
let accent = super::TabAccent::for_tab(&t, tab);
let card = if dark { t.panel } else { egui::Color32::WHITE };
for (name, ink, ground) in [
("ink on card", accent.ink, card),
("ink on panel", accent.ink, t.panel),
("ink on soft", accent.ink, accent.soft),
("text on fill", accent.on_fill(&t), accent.color),
] {
let ratio = super::contrast_ratio(ink, ground);
assert!(ratio >= 4.5, "{tab} dark={dark}: {name} is {ratio:.4}:1 ({ink:?} on {ground:?})");
}
let white_ok = super::contrast_ratio(t.on_accent, accent.color) >= 4.5;
assert_eq!(accent.on_fill(&t), if white_ok { t.on_accent } else { t.tab_on_fill_dark });
}
}
}
#[test]
fn tab_accent_context_is_per_app_and_does_not_change_widget_visuals() {
let mut harness = crate::scenario::Harness::new();
@@ -607,7 +689,7 @@ mod tests {
let before = first.style_of(egui::Theme::Dark).visuals.clone();
app.ui.tab = "SURFACE".into();
super::TabAccent::publish(app, &first);
assert_eq!(super::TabAccent::current(&first).color, super::Tokens::get().surface_accent);
assert_eq!(super::TabAccent::current(&first).color, super::Tokens::get().surface_fill);
assert_eq!(super::TabAccent::current(&second).color, super::Tokens::get().accent);
assert_eq!(first.style_of(egui::Theme::Dark).visuals, before, "dialog OK, checkboxes and status styles must not inherit the tab");
app.ui.tab = "MODEL".into();
+1
View File
@@ -108,6 +108,7 @@ theme_keys! {
profile_fill, glyph_bg, glyph_edge, glyph_text, overlay, rubber_band, app_bar_text, app_bar_hover, timeline_item,
timeline_item_error, timeline_marker, field, box_window, box_crossing, sketch_projected, sketch_lost,
sketch_construction, sketch_centerline, bend_up, bend_down, interference,
sketch_ink, sketch_soft, surface_fill, surface_ink, surface_soft, mesh_fill, mesh_ink, mesh_soft, form_fill, form_tab_ink, form_soft, sheet_fill, sheet_ink, sheet_soft, render_fill, render_ink, render_soft, tab_on_fill_dark,
app_bar_separator, surface_accent, mesh_accent, form_accent, render_accent, on_accent, agent_ok, agent_busy, app_bar_hover_subtle,
app_bar_hover_button, app_bar_hover_strong, app_bar_tab_active,
form_ink, form_dim, form_primary, form_error, form_error_fill, dialog_body, dialog_footer, dialog_rule, control_fill, control_border, dialog_label, selected_ink, selected_bg,
+9 -10
View File
@@ -869,9 +869,9 @@ fn ribbon_tabs(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect) {
&ribbon_label(app, tab),
t.font_button,
if contextual {
t.on_accent
accent.on_fill(&t)
} else if active {
selected_ink(&accent)
accent.ink
} else {
t.text
},
@@ -915,11 +915,6 @@ fn dropdown_arrow(painter: &egui::Painter, at: egui::Pos2, ink: Color32) {
crate::ui_kit::dropdown_indicator(painter, Rect::from_center_size(at, vec2(10.0, 10.0)), ink);
}
/// The label colour on a selected tab or open section.
fn selected_ink(accent: &crate::theme::TabAccent) -> Color32 {
crate::theme::selected_ink(&Tokens::get(), accent.color)
}
pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
crate::workspace::sync_context(app);
@@ -1191,17 +1186,21 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
let info = c.info(&app.session);
let resp = ui.interact(cell, ui.id().with(("cmd", c.id)), Sense::click_and_drag());
let active = running.as_deref() == Some(c.id);
let accent = crate::theme::TabAccent::for_tab(&t, &tab);
painter.rect(
cell,
4.0,
if active {
t.panel.lerp_to_gamma(command_accent(c.icon), 0.18)
if accent.color == t.accent { t.panel.lerp_to_gamma(command_accent(c.icon), 0.18) } else { accent.soft }
} else if resp.hovered() && info.enabled {
t.hover
} else {
t.panel
},
Stroke::new(1.0, if active { command_accent(c.icon) } else { t.border }),
Stroke::new(
1.0,
if active { if accent.color == t.accent { command_accent(c.icon) } else { accent.color } } else { t.border },
),
egui::StrokeKind::Inside,
);
icons::paint_icon(
@@ -1254,7 +1253,7 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
FontId::proportional(crate::theme::Tokens::get().font_caption)
};
let label_width = painter.layout_no_wrap(label.clone(), font, t.text_dim).size().x;
let ink = if panel_open { selected_ink(&accent) } else { t.text_dim };
let ink = if panel_open { accent.ink } else { t.text_dim };
ribbon_text(ui, lr.center() - vec2(if finish { 0.0 } else { 6.0 }, 0.0), &label, t.font_caption, ink, panel_open || hot);
if !finish {
dropdown_arrow(&painter, pos2(lr.center().x + label_width / 2.0 + 1.0, lr.center().y + 0.5), ink);
+10
View File
@@ -106,6 +106,16 @@ colours by name:
Colours are `#rrggbb`, or `#rrggbbaa` for translucent ones. A few colours, such as the view
triad's X, Y and Z, take a list. Any colour the file leaves out keeps the base palette's value.
Tab accents also have separate fill, small-text ink and tint keys. Sketch uses
`sketch_accent`, `sketch_ink`, `sketch_soft`; Surface, Mesh, Sheet Metal and Render
use `<tab>_fill`, `<tab>_ink`, `<tab>_soft` (`sheet` for Sheet Metal). Form uses
`form_fill`, `form_tab_ink`, `form_soft` because `form_ink` names the general form
text. Model keeps `accent`, `selected_ink`, `accent_soft`. The older
`surface_accent`, `mesh_accent`, `form_accent` and `render_accent` keys retain their
existing roles and values. `tab_on_fill_dark` is the dark text fallback for tab
pills when `on_accent` has less than 4.5:1 contrast with the fill. See the
[per-tab token reference](../dev/ui-kit.md#per-tab-accent-tokens) for all pairs.
- **Import…** adds a theme file and turns it on. Importing a file with the same name again updates
that theme. A file with an unknown colour name or a malformed colour is refused, and the message
names every problem.
+45
View File
@@ -249,3 +249,48 @@ Dropdown arrows always point down; submenu arrows point right. Playback, reorder
window management and overflow controls are not disclosures. The source guard scans
UI, apps and compiled asset glyphs without caller allowances; render tests inspect
the actual icon textures used by sections, card folds and window folds.
## Per-tab accent tokens
`TabAccent::for_tab` supplies three independent theme colours: `color` (fill) for
pills, active-tool borders and the history marker; `ink` for small text and selected
rows; `soft` for tinted selection/tool backgrounds. These are palette entries, not
blends. Browser rows and selected ribbon labels use `ink` directly.
| Tab id | Fill token | Ink token | Soft token |
| --- | --- | --- | --- |
| `MODEL` / default | `accent` | `selected_ink` | `accent_soft` |
| `SKETCH` | `sketch_accent` | `sketch_ink` | `sketch_soft` |
| `SURFACE` | `surface_fill` | `surface_ink` | `surface_soft` |
| `MESH` | `mesh_fill` | `mesh_ink` | `mesh_soft` |
| `FORM` | `form_fill` | `form_tab_ink` | `form_soft` |
| `SHEET METAL` | `sheet_fill` | `sheet_ink` | `sheet_soft` |
| `RENDER` | `render_fill` | `render_ink` | `render_soft` |
`form_tab_ink` is separate from the existing `form_ink` used for form controls.
Sketch reuses its existing fill in both themes. Surface and Form fills match their
existing accents in light mode but need independent dark values; Mesh and Render
fills also differ from their existing `mesh_accent` and `render_accent` values.
All existing tokens, including Model's fill, ink and tint, retain their values.
The Model/default mapping preserves its existing appearance rather than adopting
the proposed Model colours from the board.
The new palette entries (fill / ink / soft) are:
| Tab | Light | Dark |
| --- | --- | --- |
| Sketch | `#057F45` / `#057F45` / `#EDF7F1` | `#128D45` / `#46BE78` / `#1F3B2B` |
| Surface | `#A45000` / `#A45000` / `#FBEBD8` | `#B26A14` / `#E0914A` / `#45331E` |
| Mesh | `#E0B200` / `#8A6D00` / `#FFF8DC` | `#C6A800` / `#D4B726` / `#41391A` |
| Form | `#7349CD` / `#7349CD` / `#EEE8FA` | `#8A6FCC` / `#B39BEE` / `#372F4F` |
| Sheet Metal | `#1E6F96` / `#1E6F96` / `#E1F0F7` | `#2A7FA8` / `#4FB3D9` / `#1F3A47` |
| Render | `#A8326E` / `#A8326E` / `#F8E6EF` | `#C8588F` / `#E074AE` / `#402336` |
Each key is supported by `solidcraft-theme/1` import/export, including
`tab_on_fill_dark` (`#000000` in both themes). `TabAccent::on_fill` uses `on_accent`
(white in the built-in palettes) when it reaches 4.5:1, otherwise that dark ink.
The fallback is black because the board's dark ink does not reach 4.5:1 on several
of the approved fills. It only styles tab pills; global primary actions still use
`on_accent`. Built-in palette tests require WCAG contrast of at least 4.5:1 for
ink on the card and panel, ink on soft, and pill text on fill in both themes.
Only Mesh separates ink from fill in the light theme.