Feature icons: masked span painted by currentColor, not <img>
Deploy / deploy (push) Successful in 1m1s

An image can't take the text color; a mask-image painted by
background-color can. Icons now follow --feature-accent when the
feature declares a color, and the surrounding text color otherwise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Bendik Aagaard Lynghaug
2026-08-12 23:36:14 +02:00
co-authored by Claude Sonnet 5
parent 34a027e17b
commit ca09dce90c
2 changed files with 17 additions and 2 deletions
+10 -2
View File
@@ -699,8 +699,16 @@ fn AlternativeCard(
let icon = feature.icon.clone();
view! {
<div class="feature" style:--feature-accent=color>
{icon.filter(|i| is_safe_icon_name(i)).map(|icon| view! {
<img class="feature-icon" src=format!("https://api.iconify.design/{icon}.svg") alt="" />
{icon.filter(|i| is_safe_icon_name(i)).map(|icon| {
// Masked span, not <img>: an image can't take
// currentColor, a mask painted by background-color can.
let u = format!("https://api.iconify.design/{icon}.svg");
view! {
<span
class="feature-icon"
style=format!("mask-image:url({u});-webkit-mask-image:url({u})")
></span>
}
})}
<Show when={
let name = feature.name.clone();
+7
View File
@@ -365,6 +365,13 @@ main.not-found {
width: 1.3rem;
height: 1.3rem;
margin: 0.1rem 0.6rem 0.4rem 0;
background-color: var(--feature-accent, currentColor);
mask-repeat: no-repeat;
mask-size: contain;
mask-position: center;
-webkit-mask-repeat: no-repeat;
-webkit-mask-size: contain;
-webkit-mask-position: center;
}
.feature h3 {