Skip to content

Add the Basic components and draw the Material ones over them - #355

Merged
smelfungus merged 7 commits into
masterfrom
basic-components
Sep 26, 2026
Merged

smelfungus merged 7 commits into
masterfrom
basic-components

Conversation

@smelfungus

Copy link
Copy Markdown
Member

A design system that does not use Material needs the picker's behaviour without its look. The foundation package gets that layer, and the Material components are rebuilt on it with their public signatures unchanged.

New in codes.side.colorpicker.foundation

  • BasicChannelSlider and BasicAlphaSlider carry the channel and alpha sliders' behaviour: the displayed hue for a grey, a value past the track pinning the thumb while it keeps its number, the controlled edit path, the channel's own steps. Their track and thumb slots read ChannelSliderScope and AlphaSliderScope, which extend ColorSliderScope with the channel, its value and the track's gradient, computed in the channel's space and already mirrored right to left.
  • BasicColorPlane and BasicChannelPlane carry the planes' pointer, focus, key and accessibility handling. Their thumb slot reads ColorPlaneScope and ChannelPlaneScope. They impose no size, and a shape clips the field.
  • BasicColorPicker, over a state, a ColorValue or a Compose Color, lays out the plane it is given (handed its axes), a slider per channel and alpha, stacked or side by side (orientation), with null leaving the plane or alpha out. While disabled it disables the library's parts in its slots and refuses touches to the rest.
  • Modifier.checkerboard(light, dark).
  • ColoringMode.defaultFor(space), the default every picker's and channel slider's coloringMode took from an internal function.
  • PlaneActionLabels moves here from codes.side.colorpicker.ui.

The Material components

  • ColorSlider, ChannelSlider, AlphaSlider, ColorPlane, ChannelPlane and ColorPicker are the Material look over those components: the label row, the gradient track with its gap, the handles, the minimum sizes and the disabled look. ColorSwatch draws with Modifier.checkerboard. The 27 screenshot baselines validate unchanged.
  • ColorPlane draws a value outside 0..1 at the nearer edge rather than off the plane, and no longer throws on a NaN.
  • ColorPicker over a space with no plane never calls its plane slot, even with showPlane = true.

Tests: colorpicker 341 JVM, 122 Android host, 122 wasm; color 216, 206, 206; color-compose 14, 14, 14. apiCheck, the iOS klib compile, the Android sample and the 27 screenshot previews pass.

…tion

Every picker and channel slider took its coloringMode default from an internal function, so a default expression in the public API called code a caller could not; ColoringMode.defaultFor is that function, public. PlaneActionLabels describes the accessibility actions any plane offers, with or without Material, so it moves to the foundation package beside ColorPickerStrings, which builds it.
A swatch is a clip, a checkerboard and a background, so a design system without Material needs the checkerboard rather than a swatch component. The swatch draws the same tile from the same origin, and its preview is unchanged.
A design system without Material needs the channel slider's behaviour, not its look: the displayed hue for a grey, a value past the track pinning the thumb while it keeps its number, the controlled edit path, and a track computed in the channel's space and brought into sRGB. These sliders carry all of it and hand the track's gradient, already mirrored right to left, to slots that draw it however they like.
ColorSlider, ChannelSlider and AlphaSlider kept their own copy of the channel logic under a Material frame. They now add only the frame: the label row, the gradient track with its gap, the handle, the minimum touch size and the disabled look, over BasicColorSlider, BasicChannelSlider and BasicAlphaSlider. The track takes the gradient the Basic slider computed, already mirrored, so the two layers cannot draw different colors. The 27 screenshot baselines validate unchanged.
The planes' input, focus, accessibility actions and field painting move into foundation components that draw only what their thumb slot draws and take no size of their own; the Material planes add the ring-and-halo indicator, the theme's plane shape, the fallback minimum size and the disabled look over them. A value outside 0..1 is drawn at the nearer edge rather than off the plane, and a NaN no longer reaches the indicator's placement.
A picker built from a design system's own sliders and plane still needs the layout, the plane's axes, the controlled value and color forms, and the disabled state reaching every replaced part. BasicColorPicker carries them and draws nothing itself; it also lays the parts out side by side, with the plane in the start half. ColorPicker is now that layout with Material parts and its theme, and looks as before.
ColorPicker's showPlane read as a switch for any plane slot, but the picker is laid out by BasicColorPicker, which hands the plane its axes and so calls it only for a space with one hue and two other channels. A custom plane slot over sRGB, Lab, Oklab or CMYK is not drawn, whatever showPlane says.
@smelfungus
smelfungus merged commit a214e93 into master Sep 26, 2026
2 checks passed
@smelfungus
smelfungus deleted the basic-components branch September 26, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant