Answer five things the panel got wrong
- A tile no longer lifts under the pointer. A finger does not move away afterwards the way a cursor does, so whatever hover raised stayed raised until something else was touched: a tile stuck, not answering. - The ground's blobs wander a closed path on their own clock instead of sliding back and forth along one line, which read as things moving rather than as light in a room. - A bar is one grid now, its rows borrowing its columns, so names of different lengths no longer start and end their tracks in different places — two bars that share no baseline cannot be compared, which is the one thing a stack of them is for. The names read rightward into their tracks, with room either side. - A reading on its way somewhere is written to as many decimals as the value it is heading for. Without that a slider stepping in halves passed through 22.37460937 on its way to 24: a number nobody asked for, a different width every frame. - The brightness column is the same control as the slider widget's, stood on its end and thicker, and exactly as tall as the disc beside it. Getting there meant drawing a slider's rail, fill and handle rather than styling `::-webkit-slider-*`: those need one set of rules per orientation, each with its own centring quirk, and the handle landed off its track when the writing mode turned. The native input stays, laid transparent over the top, so the keyboard, the pointer and every `aria-` are still its.
This commit is contained in:
@@ -77,37 +77,45 @@ export function Switch(props: SwitchProps) {
|
||||
|
||||
export function Slider(props: SliderProps) {
|
||||
const { fraction, inputProps, marks } = useSliderDrag(props)
|
||||
const vertical = props.orientation === "vertical"
|
||||
const orientation = props.orientation ?? "horizontal"
|
||||
return (
|
||||
<div
|
||||
className={cn("dui-slider gl-slider", vertical ? "h-full" : "w-full")}
|
||||
className={cn(
|
||||
"dui-slider gl-slider",
|
||||
orientation === "horizontal" && "w-full",
|
||||
)}
|
||||
data-orientation={orientation}
|
||||
style={{ "--dui-fraction": fraction } as React.CSSProperties}
|
||||
>
|
||||
<div
|
||||
className={cn("flex min-w-0 flex-col", vertical ? "h-full" : "w-full")}
|
||||
>
|
||||
<input
|
||||
{...inputProps}
|
||||
data-orientation={props.orientation ?? "horizontal"}
|
||||
/>
|
||||
{marks.length > 0 ? (
|
||||
// Decoration: the input itself announces min, max and where it stands.
|
||||
<div aria-hidden className="gl-ticks">
|
||||
{marks.map((mark) => (
|
||||
<span
|
||||
key={mark.percent}
|
||||
className="absolute top-0"
|
||||
style={{
|
||||
left: `${mark.percent}%`,
|
||||
transform: `translateX(-${mark.percent}%)`,
|
||||
}}
|
||||
>
|
||||
{mark.label}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="dui-slider-body">
|
||||
<span className="dui-slider-rail" aria-hidden>
|
||||
<span className="dui-slider-fill" />
|
||||
</span>
|
||||
{/* The control itself, laid transparent over what is drawn: it keeps
|
||||
the keyboard, the pointer and every `aria-`, and owes the look
|
||||
nothing. */}
|
||||
<input {...inputProps} className="dui-slider-input" />
|
||||
<span className="dui-slider-thumb" aria-hidden />
|
||||
</div>
|
||||
{marks.length > 0 ? (
|
||||
// Decoration: the input itself announces min, max and where it stands.
|
||||
<div aria-hidden className="dui-ticks">
|
||||
{marks.map((mark) => (
|
||||
<span
|
||||
key={mark.percent}
|
||||
className="absolute top-0"
|
||||
// Shifted by its own share of itself: the first label sits flush
|
||||
// left and the last flush right, so neither hangs off the tile.
|
||||
style={{
|
||||
left: `${mark.percent}%`,
|
||||
transform: `translateX(-${mark.percent}%)`,
|
||||
}}
|
||||
>
|
||||
{mark.label}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export function Readout({
|
||||
}: ReadoutProps) {
|
||||
const { label, numeric } = useAnimatedNumber(value, precision)
|
||||
return (
|
||||
<span className="flex min-w-0 items-baseline gap-1.5">
|
||||
<span data-testid="readout" className="flex min-w-0 items-baseline gap-1.5">
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 truncate",
|
||||
|
||||
@@ -25,11 +25,18 @@ import type {
|
||||
import { TESTID } from "../core/contract"
|
||||
import { LOOK } from "../core/motion"
|
||||
|
||||
/** Where each blob drifts to and back. Pixels on the unscaled canvas. */
|
||||
/**
|
||||
* The path each blob wanders, in pixels on the unscaled canvas.
|
||||
*
|
||||
* A closed round rather than a line travelled back and forth: a blob that
|
||||
* retraces its own path reads as a thing sliding, and one that comes round
|
||||
* reads as light moving in a room. Each takes a different number of turns and
|
||||
* a different length of time, so the three never fall into step.
|
||||
*/
|
||||
const DRIFTS = [
|
||||
{ x: [0, 80], y: [0, -60] },
|
||||
{ x: [0, -70], y: [0, 50] },
|
||||
{ x: [0, 50], y: [0, -40] },
|
||||
{ x: [0, 90, 130, 40, 0], y: [0, -70, 20, 60, 0], seconds: 1 },
|
||||
{ x: [0, -80, -30, 60, 0], y: [0, 50, 110, 40, 0], seconds: 1.35 },
|
||||
{ x: [0, 60, -40, -90, 0], y: [0, -50, -90, -20, 0], seconds: 1.7 },
|
||||
]
|
||||
|
||||
export function Backdrop({ image }: BackdropProps) {
|
||||
@@ -50,16 +57,15 @@ export function Backdrop({ image }: BackdropProps) {
|
||||
className="pointer-events-none absolute inset-0 overflow-hidden"
|
||||
>
|
||||
<span className="gl-ground" />
|
||||
{DRIFTS.map((drift, index) => (
|
||||
{DRIFTS.map(({ seconds, ...path }, index) => (
|
||||
<motion.span
|
||||
// Position is the identity: which blob this is decides its colour.
|
||||
key={`blob-${index}`}
|
||||
className="gl-blob"
|
||||
animate={drift}
|
||||
animate={path}
|
||||
transition={{
|
||||
duration: LOOK.glass.drift,
|
||||
duration: LOOK.glass.drift * seconds,
|
||||
repeat: Number.POSITIVE_INFINITY,
|
||||
repeatType: "mirror",
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
/>
|
||||
@@ -92,16 +98,15 @@ export function Frame({
|
||||
onClick,
|
||||
children,
|
||||
}: FrameProps) {
|
||||
const { hover, spring } = LOOK.glass
|
||||
return (
|
||||
// A card is not a control: the click only picks it in edit mode, and every
|
||||
// interactive element inside keeps its own role and keyboard handling.
|
||||
<motion.div
|
||||
// biome-ignore lint/a11y/useKeyWithClickEvents: see above.
|
||||
// biome-ignore lint/a11y/noStaticElementInteractions: see above.
|
||||
<div
|
||||
data-testid={TESTID.frame}
|
||||
data-selected={selected ? "" : undefined}
|
||||
className="dui-frame gl-surface gl-frame"
|
||||
whileHover={hover}
|
||||
transition={spring}
|
||||
onClick={onClick}
|
||||
>
|
||||
{title ? (
|
||||
@@ -132,7 +137,7 @@ export function Frame({
|
||||
)}
|
||||
/>
|
||||
) : null}
|
||||
</motion.div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -263,89 +263,24 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.gl-slider {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.gl-slider input {
|
||||
width: 100%;
|
||||
height: var(--dui-control);
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.gl-slider input::-webkit-slider-runnable-track {
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
box-shadow: var(--gl-inset);
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
color-mix(in srgb, var(--primary) 85%, white)
|
||||
calc(var(--dui-fraction, 0) * 100%),
|
||||
var(--gl-track) calc(var(--dui-fraction, 0) * 100%)
|
||||
);
|
||||
}
|
||||
|
||||
.gl-slider input[data-orientation="vertical"]::-webkit-slider-runnable-track {
|
||||
width: 0.5rem;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
to top,
|
||||
color-mix(in srgb, var(--primary) 85%, white)
|
||||
calc(var(--dui-fraction, 0) * 100%),
|
||||
var(--gl-track) calc(var(--dui-fraction, 0) * 100%)
|
||||
);
|
||||
}
|
||||
|
||||
.gl-slider input::-moz-range-track {
|
||||
height: 0.5rem;
|
||||
.gl-slider .dui-slider-rail {
|
||||
border-radius: 9999px;
|
||||
background: var(--gl-track);
|
||||
box-shadow: var(--gl-inset);
|
||||
}
|
||||
|
||||
.gl-slider input::-moz-range-progress {
|
||||
height: 0.5rem;
|
||||
.gl-slider .dui-slider-fill {
|
||||
border-radius: 9999px;
|
||||
background: color-mix(in srgb, var(--primary) 85%, white);
|
||||
box-shadow: var(--gl-glow);
|
||||
}
|
||||
|
||||
.gl-slider input::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
width: var(--dui-thumb);
|
||||
height: var(--dui-thumb);
|
||||
margin-top: calc((0.5rem - var(--dui-thumb)) / 2);
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 50%;
|
||||
.gl-slider .dui-slider-thumb {
|
||||
background: #fff;
|
||||
border: 1px solid var(--gl-border);
|
||||
box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
|
||||
.gl-slider input::-moz-range-thumb {
|
||||
width: var(--dui-thumb);
|
||||
height: var(--dui-thumb);
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.gl-slider input:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.gl-ticks {
|
||||
position: relative;
|
||||
height: 1rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted-foreground);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.gl-segmented {
|
||||
position: relative;
|
||||
display: grid;
|
||||
|
||||
Reference in New Issue
Block a user