Pizza Picker
Pizza cards with a size and a crust radio group and an add button.
Install
npx ui8kit add pizza-pickerPulls in: box, button, compose, dish-showcase, empty-state, group, inline, kit-box, kit-button, kit-text, media-frame, option-chips, section-frame, stack, text, utils
Preview
Pizza
Choose a size and a crust.
Margherita
Tomato, mozzarella and basil.
Pepperoni
Tomato, mozzarella and spicy salami.
Garden veggie
Peppers, olives, onion and mushrooms.
Code
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdnnpx ui8kit add pizza-picker<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts
(each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Dish, FoodLabels } from "./dish-showcase.types";
import type { DishOption } from "../components/option-chips.types";
export type PizzaPickerProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
sizes: DishOption[];
crusts: DishOption[];
layout?: "cards" | "rows";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import EmptyState from "../components/empty-state.svelte";
import MediaFrame from "../components/media-frame.svelte";
import OptionChips from "../components/option-chips.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { fmtMoney, tpl } from "../utils";
let {
id,
title,
lead = "",
dishes,
empty = "",
labels,
sizes,
crusts,
layout = "cards",
tone = "default",
landmarkLabel,
}: PizzaPickerProps = $props();
</script>
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{#if ((dishes?.length ?? 0) === 0)}
<EmptyState icon="star" title={empty} />
{:else}
<Box
class={
(layout as string) === "rows" ? "flex flex-col gap-4"
: "grid grid-cols-1 gap-4 md:grid-cols-3"
}
data-slot="items"
>
{#each dishes as d (d.id)}
<Box
class={
(layout as string) === "rows" ? "rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3"
: "rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4"
}
data-slot="item"
>
<MediaFrame alt={d.name} src={d.image} ratio="1/1" />
<Stack gap="4" class={(((layout as string) === "rows") ? "md:col-span-2" : "")}>
<Stack gap="2">
<Text size="lg" weight="semibold">
{d.name}
</Text>
<Text size="sm" class="text-muted-foreground">
{d.summary}
</Text>
</Stack>
<OptionChips name={tpl("{0}-size-{1}", id, d.id)} legend={labels.size} options={sizes} />
<OptionChips name={tpl("{0}-crust-{1}", id, d.id)} legend={labels.crust} options={crusts} />
<Group gap="4" align="center" justify="between" class="mt-auto">
<Inline class="text-xl font-bold">
{fmtMoney(d.price, d.currency)}
</Inline>
<Button variant="default" size="default" type="button" aria-label={tpl(labels.addOf, d.name)}>
{labels.add}
</Button>
</Group>
</Stack>
</Box>
{/each}
</Box>
{/if}
</SectionFrame>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add pizza-picker// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts
* (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
*/
import { type ReactNode } from "react";
import { Box, Button, Group, Inline, Stack, Text } from "../compose";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { OptionChips } from "../components/option-chips";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";
import type { DishOption } from "../components/option-chips.types";
export type PizzaPickerProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
sizes: DishOption[];
crusts: DishOption[];
layout?: "cards" | "rows";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function PizzaPicker({
id,
title,
lead = "",
dishes,
empty = "",
labels,
sizes,
crusts,
layout = "cards",
tone = "default",
landmarkLabel,
}: PizzaPickerProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((dishes?.length ?? 0) === 0) ? (
<EmptyState icon="star" title={empty} />
) : (
<Box
className={
(layout as string) === "rows" ? "flex flex-col gap-4"
: "grid grid-cols-1 gap-4 md:grid-cols-3"
}
data-slot="items"
>
{(dishes ?? []).map((d) => (
<Box key={d.id}
className={
(layout as string) === "rows" ? "rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3"
: "rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4"
}
data-slot="item"
>
<MediaFrame alt={d.name} src={d.image} ratio="1/1" />
<Stack gap="4" className={(((layout as string) === "rows") ? "md:col-span-2" : "")}>
<Stack gap="2">
<Text size="lg" weight="semibold">
{d.name}
</Text>
<Text size="sm" className="text-muted-foreground">
{d.summary}
</Text>
</Stack>
<OptionChips name={tpl("{0}-size-{1}", id, d.id)} legend={labels.size} options={sizes} />
<OptionChips name={tpl("{0}-crust-{1}", id, d.id)} legend={labels.crust} options={crusts} />
<Group gap="4" align="center" justify="between" className="mt-auto">
<Inline className="text-xl font-bold">
{fmtMoney(d.price, d.currency)}
</Inline>
<Button variant="default" size="default" type="button" aria-label={tpl(labels.addOf, d.name)}>
{labels.add}
</Button>
</Group>
</Stack>
</Box>
))}
</Box>
)}
</SectionFrame>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add pizza-picker<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts
(each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
-->
<script lang="ts">
import type { Dish, FoodLabels } from "./dish-showcase.types";
import type { DishOption } from "../components/option-chips.types";
export type PizzaPickerProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
sizes: DishOption[];
crusts: DishOption[];
layout?: "cards" | "rows";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import EmptyState from "../components/empty-state.vue";
import MediaFrame from "../components/media-frame.vue";
import OptionChips from "../components/option-chips.vue";
import SectionFrame from "../components/section-frame.vue";
import { fmtMoney, tpl } from "../utils";
const {
id,
title,
lead = "",
dishes,
empty = "",
labels,
sizes,
crusts,
layout = "cards",
tone = "default",
landmarkLabel,
} = defineProps<PizzaPickerProps>();
</script>
<template>
<SectionFrame :id="id" :title="title" :lead="lead" :tone="tone" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((dishes?.length ?? 0) === 0)" icon="star" :title="empty" />
<Box v-else
:class="
(layout as string) === 'rows' ? 'flex flex-col gap-4'
: 'grid grid-cols-1 gap-4 md:grid-cols-3'
"
data-slot="items"
>
<Box v-for="d in dishes" :key="d.id"
:class="
(layout as string) === 'rows' ? 'rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3'
: 'rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4'
"
data-slot="item"
>
<MediaFrame :alt="d.name" :src="d.image" ratio="1/1" />
<Stack gap="4" :class="(((layout as string) === 'rows') ? 'md:col-span-2' : '')">
<Stack gap="2">
<Text size="lg" weight="semibold">
{{ d.name }}
</Text>
<Text size="sm" class="text-muted-foreground">
{{ d.summary }}
</Text>
</Stack>
<OptionChips :name="tpl('{0}-size-{1}', id, d.id)" :legend="labels.size" :options="sizes" />
<OptionChips :name="tpl('{0}-crust-{1}', id, d.id)" :legend="labels.crust" :options="crusts" />
<Group gap="4" align="center" justify="between" class="mt-auto">
<Inline class="text-xl font-bold">
{{ fmtMoney(d.price, d.currency) }}
</Inline>
<Button variant="default" size="default" type="button" :aria-label="tpl(labels.addOf, d.name)">
{{ labels.add }}
</Button>
</Group>
</Stack>
</Box>
</Box>
</SectionFrame>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add pizza-picker// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts
* (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
*/
import { For, type JSX } from "solid-js";
import { Box, Button, Group, Inline, Stack, Text } from "../compose";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { OptionChips } from "../components/option-chips";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";
import type { DishOption } from "../components/option-chips.types";
export type PizzaPickerProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
sizes: DishOption[];
crusts: DishOption[];
layout?: "cards" | "rows";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function PizzaPicker({
id,
title,
lead = "",
dishes,
empty = "",
labels,
sizes,
crusts,
layout = "cards",
tone = "default",
landmarkLabel,
}: PizzaPickerProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((dishes?.length ?? 0) === 0) ? (
<EmptyState icon="star" title={empty} />
) : (
<Box
class={
(layout as string) === "rows" ? "flex flex-col gap-4"
: "grid grid-cols-1 gap-4 md:grid-cols-3"
}
data-slot="items"
>
<For each={dishes ?? []}>{(d) => (
<Box
class={
(layout as string) === "rows" ? "rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3"
: "rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4"
}
data-slot="item"
>
<MediaFrame alt={d.name} src={d.image} ratio="1/1" />
<Stack gap="4" class={(((layout as string) === "rows") ? "md:col-span-2" : "")}>
<Stack gap="2">
<Text size="lg" weight="semibold">
{d.name}
</Text>
<Text size="sm" class="text-muted-foreground">
{d.summary}
</Text>
</Stack>
<OptionChips name={tpl("{0}-size-{1}", id, d.id)} legend={labels.size} options={sizes} />
<OptionChips name={tpl("{0}-crust-{1}", id, d.id)} legend={labels.crust} options={crusts} />
<Group gap="4" align="center" justify="between" class="mt-auto">
<Inline class="text-xl font-bold">
{fmtMoney(d.price, d.currency)}
</Inline>
<Button variant="default" size="default" type="button" aria-label={tpl(labels.addOf, d.name)}>
{labels.add}
</Button>
</Group>
</Stack>
</Box>
)}</For>
</Box>
)}
</SectionFrame>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add pizza-picker// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/pizza-picker.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// PizzaPickerProps are the props of PizzaPicker; the values are the JSON shapes of the TypeScript props.
type PizzaPickerProps struct {
Id any `json:"id"`
Title any `json:"title"`
Lead any `json:"lead"`
Dishes any `json:"dishes"`
Empty any `json:"empty"`
Labels any `json:"labels"`
Sizes any `json:"sizes"`
Crusts any `json:"crusts"`
Layout any `json:"layout"`
Tone any `json:"tone"`
LandmarkLabel any `json:"landmarkLabel"`
}
// Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
templ PizzaPicker(p PizzaPickerProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLead := uiutils.Def(p.Lead, "") }}
{{ vDishes := p.Dishes }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vSizes := p.Sizes }}
{{ vCrusts := p.Crusts }}
{{ vLayout := uiutils.Def(p.Layout, "cards") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Tone: vTone, LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Len(vDishes), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "star", Title: vEmpty})
} else {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "rows")), "flex flex-col gap-4", "grid grid-cols-1 gap-4 md:grid-cols-3")), Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vD := range uiutils.L(vDishes) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "rows")), "rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3", "rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4")), Attrs: uiutils.Attrs("data-slot", "item")}}) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vD, "name"), Src: uiutils.Get(vD, "image"), Ratio: "1/1"})
@compose.Stack(compose.StackProps{Gap: "4", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "rows")), "md:col-span-2", ""))}}) {
@compose.Stack(compose.StackProps{Gap: "2", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "lg", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vD, "name")) }
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vD, "summary")) }
}
}
@OptionChips(OptionChipsProps{Name: uiutils.Tpl("{0}-size-{1}", vId, uiutils.Get(vD, "id")), Legend: uiutils.Get(vLabels, "size"), Options: vSizes})
@OptionChips(OptionChipsProps{Name: uiutils.Tpl("{0}-crust-{1}", vId, uiutils.Get(vD, "id")), Legend: uiutils.Get(vLabels, "crust"), Options: vCrusts})
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "between", BoxProps: box.BoxProps{Class: "mt-auto"}}) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-xl font-bold"}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vD, "price"), uiutils.Get(vD, "currency"))) }
}
@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Type: "button", AriaLabel: uiutils.S(uiutils.Tpl(uiutils.Get(vLabels, "addOf"), uiutils.Get(vD, "name")))}}) {
{ uiutils.Text(uiutils.Get(vLabels, "add")) }
}
}
}
}
}
}
}
}
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdnnpx ui8kit add pizza-picker{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/pizza-picker.json
Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
Props (p): id, title, lead, dishes, empty, labels, sizes, crusts, layout, tone, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_lead = (p.lead ?? '') -%}
{%- set v_dishes = (p.dishes ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_sizes = (p.sizes ?? null) -%}
{%- set v_crusts = (p.crusts ?? null) -%}
{%- set v_layout = (p.layout ?? 'cards') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_10 -%}
{%- if og_t(og_eq(og_len(v_dishes), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'star', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_9 -%}
{%- for v_d in og_l(v_dishes) %}
{%- set c_8 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_d, ['name']), 'src': og_get(v_d, ['image']), 'ratio': '1/1'}}, with_context = false) }}
{%- set c_7 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_d, ['name'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'lg', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_get(v_d, ['summary'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'children': c_3}, with_context = false) }}
{{ include('blocks/option-chips.html.twig', {'p': {'name': og_tpl('{0}-size-{1}', [v_id, og_get(v_d, ['id'])]), 'legend': og_get(v_labels, ['size']), 'options': v_sizes}}, with_context = false) }}
{{ include('blocks/option-chips.html.twig', {'p': {'name': og_tpl('{0}-crust-{1}', [v_id, og_get(v_d, ['id'])]), 'legend': og_get(v_labels, ['crust']), 'options': v_crusts}}, with_context = false) }}
{%- set c_6 -%}
{%- set c_4 -%}
{{ og_text(og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'text-xl font-bold', 'children': c_4}, with_context = false) }}
{%- set c_5 -%}
{{ og_text(og_get(v_labels, ['add'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'type': 'button', 'ariaLabel': og_s(og_tpl(og_get(v_labels, ['addOf']), [og_get(v_d, ['name'])])), 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'between', 'class': 'mt-auto', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'class': og_s((og_t(og_eq(v_layout, 'rows')) ? 'md:col-span-2' : '')), 'children': c_7}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s((og_t(og_eq(v_layout, 'rows')) ? 'rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3' : 'rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4')), 'attrs': og_attrs(['data-slot', 'item']), 'children': c_8}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s((og_t(og_eq(v_layout, 'rows')) ? 'flex flex-col gap-4' : 'grid grid-cols-1 gap-4 md:grid-cols-3')), 'attrs': og_attrs(['data-slot', 'items']), 'children': c_9}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_10)}, with_context = false) }}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdnnpx ui8kit add pizza-picker{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/pizza-picker.json
Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
Props (p): id, title, lead, dishes, empty, labels, sizes, crusts, layout, tone, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_lead = ($p['lead'] ?? '')}
{var $v_dishes = ($p['dishes'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_sizes = ($p['sizes'] ?? null)}
{var $v_crusts = ($p['crusts'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'cards')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_10}
{if og_t(og_eq(og_len($v_dishes), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'star', 'title' => $v_empty]])|noescape}
{else}
{capture $c_9}
{foreach og_l($v_dishes) as $v_d}
{capture $c_8}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_d, ['name']), 'src' => og_get($v_d, ['image']), 'ratio' => '1/1']])|noescape}
{capture $c_7}
{capture $c_3}
{capture $c_1}
{=og_text(og_get($v_d, ['name']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'lg', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_get($v_d, ['summary']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'children' => (string) $c_3])|noescape}
{=og_include('blocks/option-chips.latte', ['p' => ['name' => og_tpl('{0}-size-{1}', [$v_id, og_get($v_d, ['id'])]), 'legend' => og_get($v_labels, ['size']), 'options' => $v_sizes]])|noescape}
{=og_include('blocks/option-chips.latte', ['p' => ['name' => og_tpl('{0}-crust-{1}', [$v_id, og_get($v_d, ['id'])]), 'legend' => og_get($v_labels, ['crust']), 'options' => $v_crusts]])|noescape}
{capture $c_6}
{capture $c_4}
{=og_text(og_money(og_get($v_d, ['price']), og_get($v_d, ['currency'])))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'text-xl font-bold', 'children' => (string) $c_4])|noescape}
{capture $c_5}
{=og_text(og_get($v_labels, ['add']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'type' => 'button', 'ariaLabel' => og_s(og_tpl(og_get($v_labels, ['addOf']), [og_get($v_d, ['name'])])), 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'between', 'class' => 'mt-auto', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'class' => og_s((og_t(og_eq($v_layout, 'rows')) ? 'md:col-span-2' : '')), 'children' => (string) $c_7])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s((og_t(og_eq($v_layout, 'rows')) ? 'rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3' : 'rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4')), 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_8])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s((og_t(og_eq($v_layout, 'rows')) ? 'flex flex-col gap-4' : 'grid grid-cols-1 gap-4 md:grid-cols-3')), 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_9])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'tone' => $v_tone, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_10)])|noescape}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdnnpx ui8kit add pizza-picker{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/pizza-picker.json
Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
Props (p): id, title, lead, dishes, empty, labels, sizes, crusts, layout, tone, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_lead = og_def(p['lead'], '') -%}
{%- set v_dishes = og_def(p['dishes'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_sizes = og_def(p['sizes'], none) -%}
{%- set v_crusts = og_def(p['crusts'], none) -%}
{%- set v_layout = og_def(p['layout'], 'cards') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_10 -%}
{%- if og_t(og_eq(og_len(v_dishes), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'star', 'title': v_empty}}) }}
{%- else %}
{%- set c_9 -%}
{%- for v_d in og_l(v_dishes) %}
{%- set c_8 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_d, ['name']), 'src': og_get(v_d, ['image']), 'ratio': '1/1'}}) }}
{%- set c_7 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_d, ['name'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'lg', 'Weight': 'semibold'}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_get(v_d, ['summary'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2'}, 'children': c_3}) }}
{{ og_include('blocks/option-chips.html.j2', {'p': {'name': og_tpl('{0}-size-{1}', [v_id, og_get(v_d, ['id'])]), 'legend': og_get(v_labels, ['size']), 'options': v_sizes}}) }}
{{ og_include('blocks/option-chips.html.j2', {'p': {'name': og_tpl('{0}-crust-{1}', [v_id, og_get(v_d, ['id'])]), 'legend': og_get(v_labels, ['crust']), 'options': v_crusts}}) }}
{%- set c_6 -%}
{%- set c_4 -%}
{{ og_text(og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-xl font-bold'}, 'children': c_4}) }}
{%- set c_5 -%}
{{ og_text(og_get(v_labels, ['add'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Type': 'button', 'AriaLabel': og_s(og_tpl(og_get(v_labels, ['addOf']), [og_get(v_d, ['name'])]))}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'between', 'Class': 'mt-auto'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Class': og_s(('md:col-span-2' if og_t(og_eq(v_layout, 'rows')) else ''))}, 'children': c_7}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(('rounded bg-card inset-ring inset-ring-border grid grid-cols-1 gap-4 p-4 md:grid-cols-3' if og_t(og_eq(v_layout, 'rows')) else 'rounded bg-card inset-ring inset-ring-border flex flex-col gap-4 p-4')), 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_8}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(('flex flex-col gap-4' if og_t(og_eq(v_layout, 'rows')) else 'grid grid-cols-1 gap-4 md:grid-cols-3')), 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_9}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_10)}) }}
Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
Pizzas with a picker on each card: the picture, name and toppings, a radio group of sizes and one of crusts (each a fieldset with role radiogroup), the price and an add button. Axes: layout (cards, rows), tone.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| lead | string | "" | |
| dishes (required) | Dish[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| labels (required) | FoodLabels | - | |
| sizes (required) | DishOption[] | - | the sizes, the first checked |
| crusts (required) | DishOption[] | - | the crusts, the first checked |
| layout | "cards" | "rows" | "cards" | |
| tone | "default" | "muted" | "default" | |
| landmarkLabel | string | - | accessible name of the landmark of this component when the page shows it more than once (a variant); replaces the heading name of the root landmark, follows the name of a nested one |