Card group
Cards as one choice, with a highlight that follows the pointer between them.
Starter
One editor and three pages.
FreeTeam
Ten editors and every page.
$12Business
Sign-on and audit logs.
$40Enterprise
Talk to us first.
Soon
forSlots(CardGroupSlots)(Recipes.CardGroup({}))
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 CardGroupStyle = forSlots(CardGroupSlots)(Recipes.CardGroup({}))
export const PlanStyle = forSlots(CardSlots)(
Recipes.Card({ surface: 'plain', orientation: 'inline' }),
)
const plans = [
{ key: 'starter', title: 'Starter', description: 'One editor and three pages.', price: 'Free' },
{ key: 'team', title: 'Team', description: 'Ten editors and every page.', price: '$12' },
{ key: 'business', title: 'Business', description: 'Sign-on and audit logs.', price: '$40' },
{ key: 'enterprise', title: 'Enterprise', description: 'Talk to us first.', price: 'Soon' },
] as const
/** The plan chosen, by key, and the Message that chooses another. */
export interface Choice<Message> {
readonly chosen: string
readonly onChoose: (key: string) => Message
}
export const cardGroup = <Message>(
style: NamedStyle<typeof CardGroupSlots>,
choice: Choice<Message>,
h: HtmlBuilder<Message>,
): Html =>
Card.group(
{
label: 'Plans',
cards: plans.map(plan => ({
key: plan.key,
title: plan.title,
description: plan.description,
footer: h.span([], [plan.price]),
selected: plan.key === choice.chosen,
disabled: plan.key === 'enterprise',
press: { onClick: choice.onChoose(plan.key) },
})),
style,
cardStyle: PlanStyle,
},
h,
)