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_HIVE: &str = include_str!("../assets/icons/hive.svg");
|
||||||
const SVG_BOLT: &str = include_str!("../assets/icons/bolt.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
|
/// Recolour an SVG to the KPI card's colour (round 11 #15). Some Font Awesome
|
||||||
/// in the KPI card's colour (round 11 #15).
|
/// 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 {
|
fn svg_recolored(svg: &str, color: (u8, u8, u8)) -> String {
|
||||||
svg.replace(
|
let hex = format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2);
|
||||||
"currentColor",
|
let s = svg.replace("currentColor", &hex);
|
||||||
&format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2),
|
s.replacen("<svg ", &format!("<svg fill=\"{hex}\" "), 1)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Width to render an SVG at, preserving its viewBox aspect ratio at height `h`.
|
/// 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);
|
let row = Widget::box_sizer(false);
|
||||||
row.add_stretch(1);
|
row.add_stretch(1);
|
||||||
if let Some(svg) = icon {
|
if let Some(svg) = icon {
|
||||||
// Neutral cards (Est. power) colour the icon amber so the bolt
|
// Icon takes the card's value colour, so each icon matches its KPI
|
||||||
// reads; the rest take the card's value colour.
|
// text (otter = paused colour, bolt = est-power colour, etc.).
|
||||||
let icol = if matches!(kind, ColorKind::Neutral) { pal.amber } else { vc };
|
let icol = vc;
|
||||||
let h = 20;
|
let h = 20;
|
||||||
let ic = Widget::svg_icon(card, &svg_recolored(svg, icol), svg_width_for_height(svg, h), h);
|
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);
|
row.add(ic, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_RIGHT, 5);
|
||||||
|
|||||||
Reference in New Issue
Block a user