Resizable
Two panels and a handle between them, dragged or stepped by the arrow keys.
forSlots(ResizableSlots)(Recipes.Resizable({}))
Usage
The function that drew the preview, over the theme module Create a theme writes. The preview passes it the style picked above instead of its default.
export const ResizableStyle = forSlots(ResizableSlots)(Recipes.Resizable({}))
export const resizable = <Message>(
style: NamedStyle<typeof ResizableSlots>,
model: Resizable.Model,
onMessage: (message: Resizable.Message) => Message,
h: HtmlBuilder<Message>,
): Html =>
h.div(
[
h.Style({
blockSize: '12rem',
inlineSize: 'min(32rem, 100%)',
border: '1px solid currentColor',
borderRadius: '0.5rem',
overflow: 'hidden',
}),
],
[
Resizable.view(
{
model,
onMessage,
label: 'Resize the file list',
min: 0.2,
max: 0.8,
first: h.ul(
[h.Style({ margin: '0', padding: '0.75rem 1.5rem' })],
[h.li([], ['notes.txt']), h.li([], ['todo.md']), h.li([], ['grid.ts'])],
),
second: h.p(
[h.Style({ margin: '0', padding: '0.75rem' })],
['Pick a file to preview it.'],
),
style,
},
h,
),
],
)