Mixins / foldkit-mixins-ui
ColorPickerSlots
const · packages/mixins-ui/src/colorPicker.ts:48
const ColorPickerSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-labelledby">], readonly Slot.RequirementName[], boolean>; readonly label: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly area: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly areaThumb: Slot.UnnamedSlot<Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [Event.EventToken<"keydown">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-valuenow">], readonly Slot.RequirementName[], boolean>; readonly controls: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], …;A color picker after ReUI's: a 2D area of saturation (across) and
brightness (up) at the color's hue, hue and alpha sliders (two Sliders of
this package), an eyedropper when the application asks for one, the color as text
in a chosen format (hex, rgb, hsl or oklch) that the user can type into,
and presets, a radio group of swatches. popover draws it in the
package's Popover, opened by a swatch of the color.
The color, the format and the text being typed are a small Model of this
module's, which the application keeps and folds with update. Every key,
press and drag reaches update as a Message that says what was done (a
key, a point of the area), not the color the last frame drew, so keys
faster than a frame each move from the color before them.
The area is one focusable thumb, role="slider" with both values in its
aria-valuetext, as the APG has no two-dimensional slider: its value is the
saturation and Up and Down move the brightness. Arrows step by 1% (with
Shift by 10%), Page Up and Page Down move the brightness by 10% (with Shift
the saturation), Home and End take the saturation to its ends. The plane is
drawn the same way in either direction, so its keys are physical too. A
press or drag on it, a Mount, says where in it the pointer is, from 0 to 1
each way.
The root carries the color for the recipe as custom properties computed
from it: --fk-color (with alpha), --fk-color-opaque, --fk-color-hue
(the pure hue the area runs to), --fk-color-area (the area's paint),
--fk-color-hues (the hue track's stops), and --fk-color-x,
--fk-color-y (the thumb's place, 0 to 1). A preset carries its own
--fk-color. The sliders take a style of their own (slider), since they
are Sliders; Recipes.Slider({ track: 'paint', label: 'hidden' }) paints
them from what each channel (data-channel) sets.