Compare commits

...
1 Commits
Author SHA1 Message Date
noahandClaude Opus 4.8 3ae80efdde GUI round 11: KPI icons match their card text colour + recolour SVGs without a fill
- Each KPI icon now uses its card's value colour (dropped the amber special-case),
  so the otter matches the Paused text colour and the lightning bolt matches the
  Est-power text colour, etc.
- svg_recolored also injects a root fill: some Font Awesome exports (e.g. the Free
  otter) omit fill entirely and default to black, so replacing currentColor alone
  left them black. Now shapes without their own fill inherit the card colour.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 20:53:28 -06:00
+9 -9
View File
@@ -295,13 +295,13 @@ const SVG_OTTER: &str = include_str!("../assets/icons/otter.svg");
const SVG_HIVE: &str = include_str!("../assets/icons/hive.svg");
const SVG_BOLT: &str = include_str!("../assets/icons/bolt.svg");
/// Replace an SVG's `currentColor` fill with an explicit hex colour so it renders
/// in the KPI card's colour (round 11 #15).
/// Recolour an SVG to the KPI card's colour (round 11 #15). Some Font Awesome
/// exports use fill="currentColor" (replaced here); others omit fill entirely and
/// default to black, so a root `fill` is also injected for shapes to inherit.
fn svg_recolored(svg: &str, color: (u8, u8, u8)) -> String {
svg.replace(
"currentColor",
&format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2),
)
let hex = format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2);
let s = svg.replace("currentColor", &hex);
s.replacen("<svg ", &format!("<svg fill=\"{hex}\" "), 1)
}
/// Width to render an SVG at, preserving its viewBox aspect ratio at height `h`.
@@ -592,9 +592,9 @@ pub fn build(frame: Widget) -> App {
let row = Widget::box_sizer(false);
row.add_stretch(1);
if let Some(svg) = icon {
// Neutral cards (Est. power) colour the icon amber so the bolt
// reads; the rest take the card's value colour.
let icol = if matches!(kind, ColorKind::Neutral) { pal.amber } else { vc };
// Icon takes the card's value colour, so each icon matches its KPI
// text (otter = paused colour, bolt = est-power colour, etc.).
let icol = vc;
let h = 20;
let ic = Widget::svg_icon(card, &svg_recolored(svg, icol), svg_width_for_height(svg, h), h);
row.add(ic, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_RIGHT, 5);