Spinner
Work in progress, announced politely.
Previews are drawn in the theme you made.
Edit itBasic #
import { Recipes, Spinner, SpinnerSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
// A spinner says work is ongoing where a bar would mislead about progress.
// With a label it is a polite status; without one it is hidden from assistive
// technology.
export default example({
title: 'Basic',
slots: SpinnerSlots,
recipe: Recipes.Spinner,
view: ({ style, h }) => Spinner.view({ label: 'Saving', style }, h),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
Kinds #
import { Recipes, Spinner, SpinnerSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { row } from '../../snippets/layout.js'
const Kinds = (['ring', 'dots', 'bars', 'pulse', 'orbit'] as const).map(kind =>
Recipes.Spinner.style({ kind }),
)
// Five ways to say "still working", each still under reduced motion.
export default example({
title: 'Kinds',
slots: SpinnerSlots,
recipe: Recipes.Spinner,
pins: { kind: 'ring' },
view: ({ h }) =>
row(
h,
Kinds.map(style => Spinner.view({ label: 'Loading', style }, h)),
),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
A label #
import { Recipes, Spinner, SpinnerSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
// The label shown beside the wheel is the status's words.
export default example({
title: 'A label',
slots: SpinnerSlots,
recipe: Recipes.Spinner,
view: ({ style, h }) => Spinner.view({ label: 'Saving your changes', showLabel: true, style }, h),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
Sizes #
import { Recipes, Spinner, SpinnerSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { row } from '../../snippets/layout.js'
const Sizes = (['sm', 'md', 'lg'] as const).map(size =>
Recipes.Spinner.style({ size, tone: 'current' }),
)
// Three sizes in the ink of the text around them, as inside a button or a badge.
export default example({
title: 'Sizes',
slots: SpinnerSlots,
recipe: Recipes.Spinner,
pins: { size: 'md', tone: 'current' },
view: ({ h }) =>
row(
h,
Sizes.map(style => Spinner.view({ label: 'Loading', style }, h)),
),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
Tones #
import { Recipes, Spinner, SpinnerSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { row } from '../../snippets/layout.js'
const Tones = (['accent', 'neutral', 'info', 'success', 'warning', 'danger'] as const).map(tone =>
Recipes.Spinner.style({ tone }),
)
// The status tones say which kind of work is under way: a retry, a deploy,
// something that may fail.
export default example({
title: 'Tones',
slots: SpinnerSlots,
recipe: Recipes.Spinner,
pins: { tone: 'accent' },
view: ({ h }) =>
row(
h,
Tones.map(style => Spinner.view({ label: 'Working', style }, h)),
),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
In a button #
import { Button, Recipes, Spinner, SpinnerSlots } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
const Face = Recipes.Button.style({})
// A spinner in a Button's `icon`, with `busy` on: the button draws none of its
// own, so a page that never shows one never ships it. The spinner takes the
// button's own ink, and the button reports `aria-busy` while the press does nothing.
export default example({
title: 'In a button',
slots: SpinnerSlots,
recipe: Recipes.Spinner,
pins: { size: 'sm', tone: 'current' },
view: ({ style, h }) =>
Button.view({ label: 'Saving…', busy: true, icon: Spinner.view({ style }, h), style: Face }, h),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
Usage
Each example above is a module of its own, shown whole and run as shown, over the theme module Create a theme writes. The page hands it the style picked above.