feat: establish color slider geometry and picker composition
This commit is contained in:
@@ -0,0 +1,277 @@
|
||||
/* Adapted from HeroUI ce90ea3, Apache-2.0; see third-party/HEROUI-LICENSE. */
|
||||
/* ==========================================================================
|
||||
ColorSlider - A slider for adjusting individual color channel values
|
||||
========================================================================== */
|
||||
|
||||
/* Base styles */
|
||||
.hv-color-slider {
|
||||
@apply grid w-full gap-1;
|
||||
|
||||
grid-template-areas:
|
||||
"label output"
|
||||
"track track";
|
||||
grid-template-columns: 1fr auto;
|
||||
grid-template-rows: auto auto;
|
||||
|
||||
/* When neither label nor output exist, collapse to single row */
|
||||
&:not(:has([data-slot="label"])):not(:has(.hv-color-slider__output)) {
|
||||
grid-template-areas: "track";
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: auto;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
/* When only label exists (no output) */
|
||||
&:has([data-slot="label"]):not(:has(.hv-color-slider__output)) {
|
||||
grid-template-areas:
|
||||
"label"
|
||||
"track";
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
/* When only output exists (no label) */
|
||||
&:not(:has([data-slot="label"])):has(.hv-color-slider__output) {
|
||||
grid-template-areas:
|
||||
"output"
|
||||
"track";
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
.hv-color-slider__output {
|
||||
justify-self: end;
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="label"] {
|
||||
@apply w-fit text-sm font-medium;
|
||||
|
||||
grid-area: label;
|
||||
}
|
||||
|
||||
.hv-color-slider__output {
|
||||
@apply text-sm font-medium tabular-nums;
|
||||
|
||||
grid-area: output;
|
||||
}
|
||||
|
||||
.hv-color-slider__track {
|
||||
@apply relative rounded-2xl;
|
||||
|
||||
grid-area: track;
|
||||
/* Edge cap pseudo-elements */
|
||||
&::before,
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-color-slider__thumb {
|
||||
/* Flex container for centering */
|
||||
@apply absolute flex cursor-grab items-center justify-center rounded-2xl no-highlight;
|
||||
|
||||
/* Border to create white ring around the thumb */
|
||||
@apply border-3 border-white shadow-overlay;
|
||||
|
||||
/* Ensure thumb is above edge caps */
|
||||
z-index: 1;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
transform 250ms var(--ease-out),
|
||||
box-shadow 150ms var(--ease-out);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
/* Dragging state - cursor changes and thumb scales down */
|
||||
&[data-dragging="true"] {
|
||||
@apply cursor-grabbing;
|
||||
}
|
||||
|
||||
/* Focus state - show focus ring */
|
||||
&[data-focus-visible="true"] {
|
||||
@apply z-10 status-focused;
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&[data-disabled="true"] {
|
||||
@apply cursor-default bg-default;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&:disabled,
|
||||
&[data-disabled="true"],
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
|
||||
[data-slot="label"] {
|
||||
@apply opacity-100;
|
||||
}
|
||||
}
|
||||
|
||||
/* Horizontal orientation */
|
||||
&[data-orientation="horizontal"] {
|
||||
flex-direction: column;
|
||||
|
||||
.hv-color-slider__track {
|
||||
@apply h-5 justify-self-center rounded-none;
|
||||
width: calc(100% - 1.25rem);
|
||||
|
||||
/* Default border for visibility against similar backgrounds */
|
||||
box-shadow:
|
||||
inset 0 1px 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
||||
|
||||
/* Edge caps for horizontal orientation */
|
||||
&::before,
|
||||
&::after {
|
||||
@apply top-0 h-full;
|
||||
width: 0.625rem; /* Half thumb width + 2px gap */
|
||||
}
|
||||
|
||||
&::before {
|
||||
@apply rounded-ss-2xl rounded-es-2xl;
|
||||
inset-inline-start: -0.625rem;
|
||||
box-shadow:
|
||||
inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 1px 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
||||
background:
|
||||
linear-gradient(
|
||||
var(--track-start-color, transparent),
|
||||
var(--track-start-color, transparent)
|
||||
),
|
||||
repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px
|
||||
16px;
|
||||
}
|
||||
|
||||
&::after {
|
||||
@apply rounded-se-2xl rounded-ee-2xl;
|
||||
inset-inline-end: -0.625rem;
|
||||
box-shadow:
|
||||
inset -1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 1px 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
||||
background:
|
||||
linear-gradient(
|
||||
var(--track-end-color, transparent),
|
||||
var(--track-end-color, transparent)
|
||||
),
|
||||
repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px
|
||||
16px;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-color-slider__thumb {
|
||||
@apply top-1/2 size-4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Vertical orientation */
|
||||
&[data-orientation="vertical"] {
|
||||
@apply h-full gap-2;
|
||||
|
||||
flex-direction: row;
|
||||
grid-template-areas:
|
||||
"output"
|
||||
"track"
|
||||
"label";
|
||||
grid-template-rows: auto 1fr auto;
|
||||
grid-template-columns: 1fr;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
|
||||
/* When neither label nor output exist in vertical, just show track */
|
||||
&:not(:has([data-slot="label"])):not(:has(.hv-color-slider__output)) {
|
||||
grid-template-areas: "track";
|
||||
grid-template-rows: 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
/* When only label exists in vertical (no output) */
|
||||
&:has([data-slot="label"]):not(:has(.hv-color-slider__output)) {
|
||||
grid-template-areas:
|
||||
"track"
|
||||
"label";
|
||||
grid-template-rows: 1fr auto;
|
||||
}
|
||||
|
||||
/* When only output exists in vertical (no label) */
|
||||
&:not(:has([data-slot="label"])):has(.hv-color-slider__output) {
|
||||
grid-template-areas:
|
||||
"output"
|
||||
"track";
|
||||
grid-template-rows: auto 1fr;
|
||||
}
|
||||
|
||||
.hv-color-slider__output {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-slot="label"] {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hv-color-slider__track {
|
||||
@apply w-5 justify-self-center rounded-none;
|
||||
height: calc(100% - 1.25rem);
|
||||
|
||||
/* Left and right borders for vertical track */
|
||||
box-shadow:
|
||||
inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset -1px 0 0 0 rgba(0, 0, 0, 0.1);
|
||||
|
||||
/* Edge caps for vertical orientation */
|
||||
&::before,
|
||||
&::after {
|
||||
@apply start-0 w-full;
|
||||
height: 0.625rem; /* Half thumb height + 2px gap */
|
||||
}
|
||||
|
||||
&::before {
|
||||
bottom: -0.625rem;
|
||||
border-end-start-radius: 999px;
|
||||
border-end-end-radius: 999px;
|
||||
/* Left, right, and bottom borders for bottom cap */
|
||||
box-shadow:
|
||||
inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset -1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
||||
background:
|
||||
linear-gradient(
|
||||
var(--track-start-color, transparent),
|
||||
var(--track-start-color, transparent)
|
||||
),
|
||||
repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px
|
||||
16px;
|
||||
}
|
||||
|
||||
&::after {
|
||||
top: -0.625rem;
|
||||
border-start-start-radius: 999px;
|
||||
border-start-end-radius: 999px;
|
||||
/* Left, right, and top borders for top cap */
|
||||
box-shadow:
|
||||
inset 1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset -1px 0 0 0 rgba(0, 0, 0, 0.1),
|
||||
inset 0 1px 0 0 rgba(0, 0, 0, 0.1);
|
||||
background:
|
||||
linear-gradient(
|
||||
var(--track-end-color, transparent),
|
||||
var(--track-end-color, transparent)
|
||||
),
|
||||
repeating-conic-gradient(#efefef 0% 25%, #f7f7f7 0% 50%) 50% / 16px
|
||||
16px;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-color-slider__thumb {
|
||||
/* Cross-axis centering; React Aria applies a physical translateX(-50%), so keep left-1/2 for RTL correctness */
|
||||
@apply left-1/2 size-4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
@apply origin-(--reka-popper-transform-origin) bg-overlay p-0 text-sm;
|
||||
border-radius: min(32px, var(--radius-3xl));
|
||||
box-shadow: var(--overlay-shadow);
|
||||
/* React Aria supplies this constraint inline; Reka exposes the available size. */
|
||||
max-height: var(--reka-popover-content-available-height);
|
||||
|
||||
/* Entering animations */
|
||||
&[data-entering="true"] {
|
||||
@@ -51,6 +53,10 @@
|
||||
/* Popover dialog */
|
||||
.hv-popover__dialog {
|
||||
@apply p-4 outline-none;
|
||||
/* Keep arrows outside the surface visible; scroll the dialog's content instead. */
|
||||
max-height: inherit;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
/* Popover heading */
|
||||
|
||||
@@ -163,3 +163,5 @@
|
||||
|
||||
/* Private color interaction foundation; public components are not exported yet. */
|
||||
@import "./components/color-area.css" layer(components);
|
||||
|
||||
@import "./components/color-slider.css" layer(components);
|
||||
|
||||
Reference in New Issue
Block a user