Composition / API

foldkit-composition/appearance

foldkit-composition/appearance: a Block's look, as choices within a design system rather than CSS.

A look is a foldkit-mixins slot recipe, whose variant axes are the choices an author makes ({ tone: 'accent', space: 'roomy' }), and token axes, whose choices are the names of a theme's tokens ({ gap: 'm' }). The Document stores only the names. Attached to a Block, the look gives the Block its appearance axes, so validating a page and applying setAppearance check the names; drawn, it gives the Block's view its Slots with the chosen Style attached.

Every piece is compiled once, when the look is made: a selection attaches the pieces it picks side by side, so a page draws no new CSS, and look.styles is every rule any selection can use, for Style.stylesheet.

Namespaces

Interfaces

Look
TokenAxisA choice among a theme's tokens, written as one declaration on one slot: Appearance.token(t.space, { slot: 'root', property: 'gap' }), where t is…