Segmented
A few options in a tray, one pressed, with a pill that slides to a new press.
forSlots(SegmentedSlots)(Recipes.Segmented({}))
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 SegmentedStyle = forSlots(SegmentedSlots)(Recipes.Segmented({}))
export const Range = Schema.Literals(['day', 'week', 'month', 'year'])
export type Range = typeof Range.Type
export const segmented = <Message>(
style: NamedStyle<typeof SegmentedSlots>,
range: Range,
onRange: (range: Range) => Message,
h: HtmlBuilder<Message>,
): Html =>
Segmented.view(
{
label: 'Range',
options: Range.literals.map(value => ({
value,
label: value[0]!.toUpperCase() + value.slice(1),
})),
pressed: [range],
onPress: onRange,
style,
// The pill glides to a new press; one is pressed at a time.
mixins: Segmented.fluid,
},
h,
)