Figure
Content with a caption that names it, as a figure and its figcaption.
Previews are drawn in the theme you made.
Edit itA listing #
ts
const total = items.lengthimport { CodeBlock, Figure, FigureSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
const Code = Recipes.CodeBlock.style({})
// A `figure` whose caption names it for assistive technology on its own: the
// caption needs no ARIA. The content is anything: a picture, a chart, a quote.
export default example({
title: 'A listing',
slots: FigureSlots,
recipe: Recipes.Figure,
view: ({ style, h }) =>
h.div(
[h.Style({ inlineSize: 'min(100%, 22rem)' })],
[
Figure.view(
{
content: CodeBlock.view(
{ code: 'const total = items.length', language: 'ts', style: Code },
h,
),
caption: 'Listing 1. The count is read, never stored.',
style,
},
h,
),
],
),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
A caption above #
Simplicity is prerequisite for reliability.
import { Figure, FigureSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
// The caption above the content, as a table's is. The recipe only moves it
// with CSS `order`; the markup, and so the reading order, is unchanged.
export default example({
title: 'A caption above',
slots: FigureSlots,
recipe: Recipes.Figure,
pins: { caption: 'before' },
view: ({ style, h }) =>
h.div(
[h.Style({ inlineSize: 'min(100%, 22rem)' })],
[
Figure.view(
{
content: h.blockquote(
[h.Style({ margin: '0' })],
['Simplicity is prerequisite for reliability.'],
),
caption: 'Edsger Dijkstra, 1975',
style,
},
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.
Keyboard and accessibility
- A
figurewith afigcaption: the caption names the figure for assistive technology with noaria-labelof its own. - With no caption no
figcaptionis drawn, so the content must carry its own alternative text.