feat(webui): add spring-based range sliders
Replace native range inputs with an accessible Radix-backed control that preserves keyboard and assistive-technology semantics. Reproduce the elastic handle, track stretch, tick visibility, and reduced-motion behavior while keeping SnowLuma theme tokens. Adopt the component for interface scale and background image controls.
This commit is contained in:
5 files changed
+774
-103
No files matched your search
+134
-51
@@ -431,67 +431,150 @@ html {
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Custom range slider (via the <Slider> component, class `.slider`).
|
||||
The component sets `--slider-pct` for the WebKit filled track; Firefox
|
||||
uses native ::-moz-range-progress.
|
||||
Elastic range slider. Interaction and geometry intentionally follow the
|
||||
Mikk Martin slider demo; only the palette and focus treatment are themed.
|
||||
────────────────────────────────────────────── */
|
||||
.slider {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
.slider-root {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
/* Match the track height so WebKit can't top-align a short track inside a
|
||||
taller input; the 1rem thumb overflows symmetrically as the grab target. */
|
||||
height: 0.375rem;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
.slider::-webkit-slider-runnable-track {
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
background: linear-gradient(to right,
|
||||
var(--primary) var(--slider-pct, 0%),
|
||||
var(--muted) var(--slider-pct, 0%));
|
||||
}
|
||||
.slider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
margin-top: -0.3125rem; /* center the 1rem thumb on the 0.375rem track */
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--background);
|
||||
border: 2px solid var(--primary);
|
||||
box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
|
||||
transition: transform 0.12s ease;
|
||||
}
|
||||
.slider:active::-webkit-slider-thumb { transform: scale(1.12); }
|
||||
.slider:focus-visible::-webkit-slider-thumb {
|
||||
box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
|
||||
}
|
||||
.slider::-moz-range-track {
|
||||
height: 0.375rem;
|
||||
border-radius: 9999px;
|
||||
min-width: 0;
|
||||
height: 3rem;
|
||||
align-items: center;
|
||||
overflow: clip;
|
||||
border: 0.5px solid var(--border);
|
||||
border-radius: 0.75rem;
|
||||
background: var(--muted);
|
||||
cursor: grab;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
backdrop-filter: blur(20px);
|
||||
transition-property: background-color, border-color, box-shadow;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider::-moz-range-progress {
|
||||
height: 0.375rem;
|
||||
.slider-root:hover {
|
||||
border-color: color-mix(in oklab, var(--primary) 24%, var(--border));
|
||||
background: color-mix(in oklab, var(--primary) 6%, var(--muted));
|
||||
}
|
||||
.slider-root:active { cursor: grabbing; }
|
||||
.slider-root:has(.slider-native-thumb:focus-visible) {
|
||||
box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
|
||||
}
|
||||
.slider-root[data-disabled] {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
.slider-radix-root {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.slider-native-thumb {
|
||||
width: 1.25rem;
|
||||
height: 2.75rem;
|
||||
border: 0;
|
||||
border-radius: 9999px;
|
||||
background: transparent;
|
||||
opacity: 0;
|
||||
outline: none;
|
||||
}
|
||||
.slider-active-range {
|
||||
height: 100%;
|
||||
border-radius: 0.75rem;
|
||||
background: color-mix(in oklab, var(--primary) 18%, var(--muted));
|
||||
transition-property: background-color;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider-root:hover .slider-active-range {
|
||||
background: color-mix(in oklab, var(--primary) 26%, var(--muted));
|
||||
}
|
||||
.slider-handle-slot {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
width: 1.5rem;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: grab;
|
||||
}
|
||||
.slider-root:active .slider-handle-slot { cursor: grabbing; }
|
||||
.slider-handle-line {
|
||||
display: block;
|
||||
width: 0.125rem;
|
||||
border-radius: 9999px;
|
||||
background: color-mix(in oklab, var(--primary) 64%, transparent);
|
||||
transition-property: background-color;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider-root:hover .slider-handle-line {
|
||||
background: var(--primary);
|
||||
}
|
||||
.slider::-moz-range-thumb {
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
border: 2px solid var(--primary);
|
||||
.slider-ticks {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
pointer-events: none;
|
||||
}
|
||||
.slider-tick {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 0.25rem;
|
||||
height: 0.25rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--background);
|
||||
box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
|
||||
background: color-mix(in oklab, var(--muted-foreground) 24%, transparent);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.slider:focus-visible::-moz-range-thumb {
|
||||
box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
|
||||
.slider-root:hover .slider-tick {
|
||||
background: color-mix(in oklab, var(--primary) 34%, transparent);
|
||||
}
|
||||
.slider-labels {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-inline: 1.25rem;
|
||||
color: var(--muted-foreground);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5rem;
|
||||
pointer-events: none;
|
||||
transition-property: color;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease-out;
|
||||
}
|
||||
.slider-root:hover .slider-labels {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.slider-value-label {
|
||||
color: var(--foreground);
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: -0.025em;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
html[data-reduce-motion="1"] .slider-root,
|
||||
html[data-reduce-motion="1"] .slider-active-range,
|
||||
html[data-reduce-motion="1"] .slider-handle-line,
|
||||
html[data-reduce-motion="1"] .slider-labels {
|
||||
transition-duration: 0s !important;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.slider-root,
|
||||
.slider-active-range,
|
||||
.slider-handle-line,
|
||||
.slider-labels {
|
||||
transition-duration: 0s !important;
|
||||
}
|
||||
}
|
||||
/* The global reduce-motion rule can't match pseudo-elements, so kill the
|
||||
thumb's active-scale transition explicitly. */
|
||||
html[data-reduce-motion="1"] .slider::-webkit-slider-thumb { transition: none !important; }
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
gridstack dashboard — mesh the library's item shell with our cards.
|
||||
|
||||
Reference in new issue
Block a user