fix(color-picker): ValueSwatch color overlay now actually shows on top of checker

Follow-up to 8515f5e6 — that commit had the stacking inverted.

The bug
-------
I put the checker on `::before { z-index: -1 }` and expected the soma's
inline `background-color` to paint on top. But within a stacking context
(my parent has `isolation: isolate`), `::before { z-index: -1 }` lands
in layer 2 — ABOVE the parent's own background (layer 1). So the
checker still covered the colour and the user only saw transparency.

The fix
-------
Inverted the layering — back to the same pattern the trigger swatch
already uses:

- Parent `[data-color-picker-value-swatch]` carries the **checker** as
  its own `background-image` (sits at layer 1 of the stacking context).
- `::before` (positioned descendant, layer 2 ABOVE layer 1) paints the
  **colour** via `var(--cp-current-color, transparent)`. The soma
  emits `--cp-current-color: <hex>` inline as part of the swatch style.
- Where the colour has alpha < 1 (rgba), the checker shows through
  the `::before` because semitransparent colour over the checker is
  the standard pattern.

Default brand colour (opaque blue) now renders as a solid blue square
again; semitransparent colours show the checker behind. Checks:
67/67 component-audit PASS, svelte-check 0 errors / 0 warnings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
active-uix
dev 5 months ago
parent 8515f5e673
commit cae638c993

@ -182,6 +182,15 @@
/* ── ValueSwatch / ValueText ─────────────────────────────────────────────── */ /* ── ValueSwatch / ValueText ─────────────────────────────────────────────── */
/* Stacking notes:
* • Element's own `background-image` (checker) sits at the bottom of
* the stacking context.
* • `::before` is a positioned descendant painted ABOVE the parent's
* own background — perfect place for the colour overlay.
* • The colour comes from `--cp-current-color`, set inline by
* `ColorPickerValueSwatchProvider`. Where the colour has alpha < 1
* (rgba) the checker shows through underneath. */
[data-color-picker-value-swatch] { [data-color-picker-value-swatch] {
position: relative; position: relative;
display: inline-block; display: inline-block;
@ -189,12 +198,13 @@
block-size: var(--_color-picker-swatch-size); block-size: var(--_color-picker-swatch-size);
border-radius: var(--color-picker-swatch-radius); border-radius: var(--color-picker-swatch-radius);
border: 1px solid var(--color-picker-swatch-border); border: 1px solid var(--color-picker-swatch-border);
/* Checker behind the colour swatch — visible only where the colour background-image: var(--cp-checker);
has alpha < 1. We use ::before for the checker (z-index -1 inside an background-size: var(--cp-checker-cell) var(--cp-checker-cell);
isolated stacking context) and let the soma-set inline background-position:
background-color paint the colour itself. The inline `style` from 0 0,
`ColorPickerValueSwatchProvider` also emits `--cp-current-color` so 0 calc(var(--cp-checker-cell) / 2),
downstream consumers can pull the value as a CSS variable too. */ calc(var(--cp-checker-cell) / 2) calc(var(--cp-checker-cell) / -2),
calc(var(--cp-checker-cell) / -2) 0;
overflow: hidden; overflow: hidden;
isolation: isolate; isolation: isolate;
} }
@ -203,14 +213,7 @@
content: ''; content: '';
position: absolute; position: absolute;
inset: 0; inset: 0;
z-index: -1; background: var(--cp-current-color, transparent);
background-image: var(--cp-checker);
background-size: var(--cp-checker-cell) var(--cp-checker-cell);
background-position:
0 0,
0 calc(var(--cp-checker-cell) / 2),
calc(var(--cp-checker-cell) / 2) calc(var(--cp-checker-cell) / -2),
calc(var(--cp-checker-cell) / -2) 0;
pointer-events: none; pointer-events: none;
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.