Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ae80efdde |
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user