hyperhive/frontend/packages/shared/src/badge/Badge.css
iris 51a9262202 theme: add --muted-on-dim, a --muted anchored to --purple-dim instead of --bg
--muted is color-mix()'d toward --base00/--bg — correct for dimmed text
on the page background, wrong for dimmed text sitting on the elevated
--purple-dim fill (badge/dropdown-item backgrounds). Badge's label/caret
used bare --muted there and mara measured it at ~1.3:1 contrast against
her theme's badge fill, essentially invisible.

--muted-on-dim mixes toward --purple-dim instead, same contrast-floor
technique as --muted itself, just anchored to the surface it's actually
used on. Applied to .ui-badge-label/.ui-badge-caret and to Dropdown's
active-item description (same bug: its row bg is --purple-dim too).

Ceiling note: even plain --fg only reaches ~3.4:1 against --purple-dim
in mara's theme, short of formal 4.5:1 AA — that's the theme's own
limit, not something the anchor choice can fix on its own. 90% gets
close to that ceiling (~3:1, more than double the old ~1.3:1) while
keeping a hint of the label/value visual distinction.
2026-08-29 10:43:38 +02:00

70 lines
2.4 KiB
CSS

/* <Badge> — pill-shaped status/control chip. Same touch-target floor as
the rest of the shared control set (2.75em ≈ 44px, WCAG 2.5.5) when
interactive; a plain display badge (no `onClick`) stays compact since
it's not a tap target at all. Colours are the shared base16-derived
vars (../theme.css) — `--bg-elev` is the same slot dropdowns/popovers
use, so an open Badge and the Dropdown it triggers read as one surface. */
.ui-badge {
display: inline-flex;
align-items: center;
gap: 0.35em;
padding: 0.15em 0.6em;
border-radius: 1em;
font: inherit;
font-size: 0.85em;
line-height: 1.4;
background: var(--purple-dim);
color: var(--fg);
border: none;
white-space: nowrap;
}
.ui-badge-interactive {
cursor: pointer;
min-height: 2.75em;
padding-inline: 0.8em;
}
.ui-badge-interactive:hover {
background: var(--border);
}
.ui-badge-interactive:disabled {
opacity: 0.6;
cursor: default;
}
.ui-badge-interactive[aria-expanded='true'] {
background: var(--bg-elev);
outline: 1px solid var(--purple);
}
.ui-badge-label {
color: var(--muted-on-dim); /* --muted alone is too low-contrast on this fill, see theme.css */
}
.ui-badge-value {
color: var(--fg);
}
.ui-badge-caret {
font-size: 0.75em;
color: var(--muted-on-dim);
}
/* Blended with `--fg`, not the raw accent — a stylix-fed scheme can pick
any hue/lightness for `--green`/`--amber`/etc., and nothing guarantees
an arbitrary accent clears 4.5:1 against `--purple-dim` the way the two
bundled palettes were hand-tuned to (see colors.css's comment above
`--latte-base08..0F`). `--fg` is the one color the base16 contract
already guarantees is legible on every surface in the theme, so mixing
toward it gives every accent a contrast floor without trying to
compute/fix an operator's own theme (mara, on the low-contrast-badges
report: "we cant fix a broken theme ... we need to follow base16
conventions or css mix new colors" — this is that; stock mocha/latte
keep their existing look, since both accents already sit close to
`--fg` in contrast terms). */
.ui-badge-positive .ui-badge-value {
color: color-mix(in srgb, var(--green) 60%, var(--fg));
}
.ui-badge-warning .ui-badge-value {
color: color-mix(in srgb, var(--amber) 60%, var(--fg));
}
.ui-badge-negative .ui-badge-value {
color: color-mix(in srgb, var(--red) 60%, var(--fg));
}
.ui-badge-accent .ui-badge-value {
color: color-mix(in srgb, var(--purple) 60%, var(--fg));
}