/* Adapted from HeroUI ce90ea3 (packages/styles/components/color-swatch-picker.css), * Apache-2.0; see third-party/HEROUI-LICENSE. Modified: hv- class prefix. * Baseline adaptations recorded in docs/tasks/results/COLOR-SWATCH-PICKER.md: * 1. The light-color rule is corrected to target the indicator's own children; * the upstream nested `&[data-light-color] & > *` never matches its own node. * 2. The swatch keeps the ColorSwatch transparency checkerboard: the upstream * picker relies on RAC ColorSwatch inline styles for the plain color fill. */ /* ========================================================================== ColorSwatchPicker - A list of color swatches for selection ========================================================================== */ /* Base styles */ .hv-color-swatch-picker { @apply flex flex-wrap items-center gap-2; } /* ========================================================================== Item - Individual swatch picker item ========================================================================== */ .hv-color-swatch-picker__item { @apply relative flex size-8 items-center justify-center rounded-2xl border-2 border-transparent outline-none no-highlight; /* Cursor */ cursor: var(--cursor-interactive); /** * Transitions * CRITICAL: motion-reduce must be AFTER transition for correct override specificity */ transition: border-color 100ms var(--ease-out), box-shadow 100ms var(--ease-out); @apply transform-gpu motion-reduce:transition-none; /* Focus state */ &:focus-visible, &[data-focus-visible="true"] { @apply status-focused; } /* Disabled state */ &[data-disabled="true"] { @apply status-disabled; } /* Selected state */ &[data-selected="true"] { border-color: var(--color-swatch-current); box-shadow: var(--field-shadow); /* Shrink the swatch to reveal the white gap */ .hv-color-swatch-picker__swatch { transform: scale(0.77); } } } /* ========================================================================== Swatch - The color swatch visual ========================================================================== */ .hv-color-swatch-picker__swatch { @apply block size-full; /* Inherit border-radius from item */ border-radius: inherit; /* Checkered background pattern for transparency (ColorSwatch baseline). */ background: linear-gradient(var(--color-swatch-current), var(--color-swatch-current)), repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px 16px; /** * Transitions * CRITICAL: motion-reduce must be AFTER transition for correct override specificity */ transition: transform 100ms var(--ease-out); @apply transform-gpu motion-reduce:transition-none; @media (hover: hover) { &:hover { transform: scale(1.1); } } } /* ========================================================================== Indicator - Checkmark indicator for selected state ========================================================================== */ .hv-color-swatch-picker__indicator { @apply pointer-events-none absolute inset-0 z-10 flex items-center justify-center; /* Checkmark SVG styles - default to white for dark backgrounds */ & > * { @apply size-1/3 text-white; /* Start scaled down - use translateZ(0) for GPU acceleration */ transform: scale(0) translateZ(0); /** * Transitions */ transition: transform 150ms var(--ease-out); @apply motion-reduce:transition-none; } /* Use black checkmark on light backgrounds (adapted selector, see header). */ &[data-light-color="true"] > * { @apply text-black; } /* Scale up when parent item is selected */ .hv-color-swatch-picker__item[data-selected="true"] & > * { transform: scale(1) translateZ(0); } } /* ========================================================================== Layout variants ========================================================================== */ .hv-color-swatch-picker--grid { /* Default is already grid (flex-wrap) - no additional styles needed */ } .hv-color-swatch-picker--stack { @apply flex-col; } /* ========================================================================== Size variants ========================================================================== */ .hv-color-swatch-picker--xs { .hv-color-swatch-picker__item { @apply size-4 rounded-lg border; } } .hv-color-swatch-picker--sm { .hv-color-swatch-picker__item { @apply size-6 rounded-xl border-2; } } .hv-color-swatch-picker--md { .hv-color-swatch-picker__item { /* No styles as this is the default size */ } } .hv-color-swatch-picker--lg { .hv-color-swatch-picker__item { @apply size-9 rounded-3xl border-3; } } .hv-color-swatch-picker--xl { .hv-color-swatch-picker__item { @apply size-10 rounded-3xl border-3; } } /* ========================================================================== Shape variants ========================================================================== */ /* Circle variant (default) - no additional styles needed */ .hv-color-swatch-picker--circle .hv-color-swatch-picker__item { /* Default is already circle - radius set per size */ } /* Square variant */ .hv-color-swatch-picker--square { .hv-color-swatch-picker__item { @apply rounded-xl; .hv-color-swatch-picker__swatch { @apply rounded-lg; } &[data-selected="true"] { .hv-color-swatch-picker__swatch { @apply rounded-lg; } } } } /* Square variant - item radius for xs */ .hv-color-swatch-picker--square.hv-color-swatch-picker--xs { .hv-color-swatch-picker__item { @apply rounded-md; .hv-color-swatch-picker__swatch { @apply rounded-md; } &[data-selected="true"] { .hv-color-swatch-picker__swatch { @apply rounded-md; } } } } /* Square variant - item radius for sm */ .hv-color-swatch-picker--square.hv-color-swatch-picker--sm { .hv-color-swatch-picker__item { @apply rounded-lg; .hv-color-swatch-picker__swatch { @apply rounded-lg; } &[data-selected="true"] { .hv-color-swatch-picker__swatch { @apply rounded-md; } } } } /* Square variant - item radius for md (default) */ .hv-color-swatch-picker--square.hv-color-swatch-picker--md { /* No styles as this is the default size */ } /* Square variant - item radius for lg */ .hv-color-swatch-picker--square.hv-color-swatch-picker--lg { .hv-color-swatch-picker__item { @apply rounded-xl; .hv-color-swatch-picker__swatch { @apply rounded-lg; } &[data-selected="true"] { .hv-color-swatch-picker__swatch { @apply rounded-lg; } } } } /* Square variant - item radius for xl */ .hv-color-swatch-picker--square.hv-color-swatch-picker--xl { .hv-color-swatch-picker__item { @apply rounded-xl; .hv-color-swatch-picker__swatch { @apply rounded-lg; } &[data-selected="true"] { .hv-color-swatch-picker__swatch { @apply rounded-lg; } } } }