Restaurant Menu
Menu sections with dotted leaders to the price; no cart.
Install
npx ui8kit add restaurant-menuPulls in: badge, box, compose, dish-showcase, empty-state, inline, kit-box, kit-text, list, list-item, menu-section-nav, section-frame, stack, text, title, utils
Preview
Menu
Starters, mains and desserts.
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 restaurant-menu<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as
menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { DishSection } from "./restaurant-menu.types";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type RestaurantMenuProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
sections: DishSection[];
empty?: string;
labels: FoodLabels;
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Badge from "../compose/Badge.svelte";
import Box from "../compose/Box.svelte";
import Inline from "../compose/Inline.svelte";
import List from "../compose/List.svelte";
import ListItem from "../compose/ListItem.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import Title from "../compose/Title.svelte";
import EmptyState from "../components/empty-state.svelte";
import MenuSectionNav from "../components/menu-section-nav.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { fmtMoney, tpl } from "../utils";
let {
id,
title,
lead = "",
dishes,
sections,
empty = "",
labels,
cols = "1",
tone = "default",
landmarkLabel,
}: RestaurantMenuProps = $props();
</script>
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{#if ((sections?.length ?? 0) === 0)}
<EmptyState icon="star" title={empty} />
{:else}
<Stack gap="8" align="stretch" class={(((cols as string) === "1") ? "mx-auto w-full max-w-3xl" : "")}>
<MenuSectionNav label={labels.sections} sections={sections} prefix={id} landmarkLabel={landmarkLabel} />
<Box
class={
(cols as string) === "2" ? "grid grid-cols-1 gap-8 md:grid-cols-2"
: "flex flex-col gap-8"
}
data-slot="items"
>
{#each sections as s (s.id)}
<Stack gap="4" id={tpl("{0}-{1}", id, s.key)} data-slot="menusection">
<Stack gap="0" class="border-b border-border pb-2">
<Title as={3} size="xl" weight="bold">
{s.title}
</Title>
<Text size="sm" class="text-muted-foreground">
{s.note}
</Text>
</Stack>
<List tag="ul" class="flex flex-col gap-4">
{#each dishes as d (d.id)}
{#if (d.tag === s.key)}
<ListItem class="flex flex-col gap-0" data-slot="item">
<Box class="flex items-baseline gap-2">
<Inline class="font-semibold">
{d.name}
</Inline>
{#if d.badge}
<Badge variant="outline" size="sm">
{d.badge}
</Badge>
{/if}
<Inline class="flex-1 border-b border-dotted border-border" aria-hidden="true" />
<Inline class="font-semibold">
{fmtMoney(d.price, d.currency)}
</Inline>
</Box>
<Text size="sm" class="text-muted-foreground">
{tpl("{0} · {1}", d.summary, d.weight)}
</Text>
</ListItem>
{/if}
{/each}
</List>
</Stack>
{/each}
</Box>
</Stack>
{/if}
</SectionFrame>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishSection = {
id: string;
key: string;
title: string;
note: string;
};
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 restaurant-menu// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as
* menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
*/
import { Fragment, type ReactNode } from "react";
import { Badge, Box, Inline, List, ListItem, Stack, Text, Title } from "../compose";
import { EmptyState } from "../components/empty-state";
import { MenuSectionNav } from "../components/menu-section-nav";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { DishSection } from "./restaurant-menu.types";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type RestaurantMenuProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
sections: DishSection[];
empty?: string;
labels: FoodLabels;
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function RestaurantMenu({
id,
title,
lead = "",
dishes,
sections,
empty = "",
labels,
cols = "1",
tone = "default",
landmarkLabel,
}: RestaurantMenuProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((sections?.length ?? 0) === 0) ? (
<EmptyState icon="star" title={empty} />
) : (
<Stack gap="8" align="stretch" className={(((cols as string) === "1") ? "mx-auto w-full max-w-3xl" : "")}>
<MenuSectionNav label={labels.sections} sections={sections} prefix={id} landmarkLabel={landmarkLabel} />
<Box
className={
(cols as string) === "2" ? "grid grid-cols-1 gap-8 md:grid-cols-2"
: "flex flex-col gap-8"
}
data-slot="items"
>
{(sections ?? []).map((s) => (
<Stack key={s.id} gap="4" id={tpl("{0}-{1}", id, s.key)} data-slot="menusection">
<Stack gap="0" className="border-b border-border pb-2">
<Title as={3} size="xl" weight="bold">
{s.title}
</Title>
<Text size="sm" className="text-muted-foreground">
{s.note}
</Text>
</Stack>
<List tag="ul" className="flex flex-col gap-4">
{(dishes ?? []).map((d) => (
<Fragment key={d.id}>
{(d.tag === s.key) ? (
<ListItem className="flex flex-col gap-0" data-slot="item">
<Box className="flex items-baseline gap-2">
<Inline className="font-semibold">
{d.name}
</Inline>
{d.badge ? (
<Badge variant="outline" size="sm">
{d.badge}
</Badge>
) : null}
<Inline className="flex-1 border-b border-dotted border-border" aria-hidden="true" />
<Inline className="font-semibold">
{fmtMoney(d.price, d.currency)}
</Inline>
</Box>
<Text size="sm" className="text-muted-foreground">
{tpl("{0} · {1}", d.summary, d.weight)}
</Text>
</ListItem>
) : null}
</Fragment>
))}
</List>
</Stack>
))}
</Box>
</Stack>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishSection = {
id: string;
key: string;
title: string;
note: string;
};
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 restaurant-menu// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishSection = {
id: string;
key: string;
title: string;
note: string;
};
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as
menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
-->
<script lang="ts">
import type { DishSection } from "./restaurant-menu.types";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type RestaurantMenuProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
sections: DishSection[];
empty?: string;
labels: FoodLabels;
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Box from "../compose/Box.vue";
import Inline from "../compose/Inline.vue";
import List from "../compose/List.vue";
import ListItem from "../compose/ListItem.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import EmptyState from "../components/empty-state.vue";
import MenuSectionNav from "../components/menu-section-nav.vue";
import SectionFrame from "../components/section-frame.vue";
import { fmtMoney, tpl } from "../utils";
const {
id,
title,
lead = "",
dishes,
sections,
empty = "",
labels,
cols = "1",
tone = "default",
landmarkLabel,
} = defineProps<RestaurantMenuProps>();
</script>
<template>
<SectionFrame :id="id" :title="title" :lead="lead" :tone="tone" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((sections?.length ?? 0) === 0)" icon="star" :title="empty" />
<Stack v-else gap="8" align="stretch" :class="(((cols as string) === '1') ? 'mx-auto w-full max-w-3xl' : '')">
<MenuSectionNav :label="labels.sections" :sections="sections" :prefix="id" :landmarkLabel="landmarkLabel" />
<Box
:class="
(cols as string) === '2' ? 'grid grid-cols-1 gap-8 md:grid-cols-2'
: 'flex flex-col gap-8'
"
data-slot="items"
>
<Stack v-for="s in sections" :key="s.id" gap="4" :id="tpl('{0}-{1}', id, s.key)" data-slot="menusection">
<Stack gap="0" class="border-b border-border pb-2">
<Title :as="3" size="xl" weight="bold">
{{ s.title }}
</Title>
<Text size="sm" class="text-muted-foreground">
{{ s.note }}
</Text>
</Stack>
<List tag="ul" class="flex flex-col gap-4">
<template v-for="d in dishes" :key="d.id">
<ListItem v-if="(d.tag === s.key)" class="flex flex-col gap-0" data-slot="item">
<Box class="flex items-baseline gap-2">
<Inline class="font-semibold">
{{ d.name }}
</Inline>
<Badge v-if="d.badge" variant="outline" size="sm">
{{ d.badge }}
</Badge>
<Inline class="flex-1 border-b border-dotted border-border" aria-hidden="true" />
<Inline class="font-semibold">
{{ fmtMoney(d.price, d.currency) }}
</Inline>
</Box>
<Text size="sm" class="text-muted-foreground">
{{ tpl("{0} · {1}", d.summary, d.weight) }}
</Text>
</ListItem>
</template>
</List>
</Stack>
</Box>
</Stack>
</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 restaurant-menu// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as
* menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
*/
import { For, type JSX } from "solid-js";
import { Badge, Box, Inline, List, ListItem, Stack, Text, Title } from "../compose";
import { EmptyState } from "../components/empty-state";
import { MenuSectionNav } from "../components/menu-section-nav";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { DishSection } from "./restaurant-menu.types";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type RestaurantMenuProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
sections: DishSection[];
empty?: string;
labels: FoodLabels;
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function RestaurantMenu({
id,
title,
lead = "",
dishes,
sections,
empty = "",
labels,
cols = "1",
tone = "default",
landmarkLabel,
}: RestaurantMenuProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((sections?.length ?? 0) === 0) ? (
<EmptyState icon="star" title={empty} />
) : (
<Stack gap="8" align="stretch" class={(((cols as string) === "1") ? "mx-auto w-full max-w-3xl" : "")}>
<MenuSectionNav label={labels.sections} sections={sections} prefix={id} landmarkLabel={landmarkLabel} />
<Box
class={
(cols as string) === "2" ? "grid grid-cols-1 gap-8 md:grid-cols-2"
: "flex flex-col gap-8"
}
data-slot="items"
>
<For each={sections ?? []}>{(s) => (
<Stack gap="4" id={tpl("{0}-{1}", id, s.key)} data-slot="menusection">
<Stack gap="0" class="border-b border-border pb-2">
<Title as={3} size="xl" weight="bold">
{s.title}
</Title>
<Text size="sm" class="text-muted-foreground">
{s.note}
</Text>
</Stack>
<List tag="ul" class="flex flex-col gap-4">
<For each={dishes ?? []}>{(d) => (
<>
{(d.tag === s.key) ? (
<ListItem class="flex flex-col gap-0" data-slot="item">
<Box class="flex items-baseline gap-2">
<Inline class="font-semibold">
{d.name}
</Inline>
{d.badge ? (
<Badge variant="outline" size="sm">
{d.badge}
</Badge>
) : null}
<Inline class="flex-1 border-b border-dotted border-border" aria-hidden="true" />
<Inline class="font-semibold">
{fmtMoney(d.price, d.currency)}
</Inline>
</Box>
<Text size="sm" class="text-muted-foreground">
{tpl("{0} · {1}", d.summary, d.weight)}
</Text>
</ListItem>
) : null}
</>
)}</For>
</List>
</Stack>
)}</For>
</Box>
</Stack>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishSection = {
id: string;
key: string;
title: string;
note: string;
};
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 restaurant-menu// 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/restaurant-menu.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// RestaurantMenuProps are the props of RestaurantMenu; the values are the JSON shapes of the TypeScript props.
type RestaurantMenuProps struct {
Id any `json:"id"`
Title any `json:"title"`
Lead any `json:"lead"`
Dishes any `json:"dishes"`
Sections any `json:"sections"`
Empty any `json:"empty"`
Labels any `json:"labels"`
Cols any `json:"cols"`
Tone any `json:"tone"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
templ RestaurantMenu(p RestaurantMenuProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLead := uiutils.Def(p.Lead, "") }}
{{ vDishes := p.Dishes }}
{{ vSections := p.Sections }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vCols := uiutils.Def(p.Cols, "1") }}
{{ 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(vSections), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "star", Title: vEmpty})
} else {
@compose.Stack(compose.StackProps{Gap: "8", Align: "stretch", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "1")), "mx-auto w-full max-w-3xl", ""))}}) {
@MenuSectionNav(MenuSectionNavProps{Label: uiutils.Get(vLabels, "sections"), Sections: vSections, Prefix: vId, LandmarkLabel: vLandmarkLabel})
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "grid grid-cols-1 gap-8 md:grid-cols-2", "flex flex-col gap-8")), Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vS := range uiutils.L(vSections) {
@compose.Stack(compose.StackProps{Gap: "4", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-{1}", vId, uiutils.Get(vS, "key")), "data-slot", "menusection")}}) {
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: "border-b border-border pb-2"}}) {
@compose.Title(compose.TitleProps{As: "3", Size: "xl", Weight: "bold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vS, "title")) }
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vS, "note")) }
}
}
@compose.List(compose.ListProps{BoxProps: box.BoxProps{Tag: "ul", Class: "flex flex-col gap-4"}}) {
for _, vD := range uiutils.L(vDishes) {
if uiutils.T(uiutils.Eq(uiutils.Get(vD, "tag"), uiutils.Get(vS, "key"))) {
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Class: "flex flex-col gap-0", Attrs: uiutils.Attrs("data-slot", "item")}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex items-baseline gap-2"}}) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "font-semibold"}}) {
{ uiutils.Text(uiutils.Get(vD, "name")) }
}
if uiutils.T(uiutils.Get(vD, "badge")) {
@compose.Badge(compose.BadgeProps{Variant: "outline", Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vD, "badge")) }
}
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "flex-1 border-b border-dotted border-border", Attrs: uiutils.Attrs("aria-hidden", "true")}})
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "font-semibold"}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vD, "price"), uiutils.Get(vD, "currency"))) }
}
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Tpl("{0} · {1}", uiutils.Get(vD, "summary"), uiutils.Get(vD, "weight"))) }
}
}
}
}
}
}
}
}
}
}
}
}
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 restaurant-menu{#- 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/restaurant-menu.json
A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
Props (p): id, title, lead, dishes, sections, empty, labels, cols, 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_sections = (p.sections ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_cols = (p.cols ?? '1') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_14 -%}
{%- if og_t(og_eq(og_len(v_sections), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'star', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_13 -%}
{{ include('blocks/menu-section-nav.html.twig', {'p': {'label': og_get(v_labels, ['sections']), 'sections': v_sections, 'prefix': v_id, 'landmarkLabel': v_landmarkLabel}}, with_context = false) }}
{%- set c_12 -%}
{%- for v_s in og_l(v_sections) %}
{%- set c_11 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_s, ['title'])) }}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 3, 'size': 'xl', 'weight': 'bold', 'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_get(v_s, ['note'])) }}
{%- 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': '0', 'class': 'border-b border-border pb-2', 'children': c_3}, with_context = false) }}
{%- set c_10 -%}
{%- for v_d in og_l(v_dishes) %}
{%- if og_t(og_eq(og_get(v_d, ['tag']), og_get(v_s, ['key']))) %}
{%- set c_9 -%}
{%- set c_7 -%}
{%- set c_4 -%}
{{ og_text(og_get(v_d, ['name'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'font-semibold', 'children': c_4}, with_context = false) }}
{%- if og_t(og_get(v_d, ['badge'])) %}
{%- set c_5 -%}
{{ og_text(og_get(v_d, ['badge'])) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'outline', 'size': 'sm', 'children': c_5}, with_context = false) }}
{%- endif %}
{{ include('compose/Inline.html.twig', {'class': 'flex-1 border-b border-dotted border-border', 'attrs': og_attrs(['aria-hidden', 'true'])}, with_context = false) }}
{%- set c_6 -%}
{{ og_text(og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'font-semibold', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex items-baseline gap-2', 'children': c_7}, with_context = false) }}
{%- set c_8 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_d, ['summary']), og_get(v_d, ['weight'])])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'class': 'flex flex-col gap-0', 'attrs': og_attrs(['data-slot', 'item']), 'children': c_9}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('compose/List.html.twig', {'tag': 'ul', 'class': 'flex flex-col gap-4', 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'attrs': og_attrs(['id', og_tpl('{0}-{1}', [v_id, og_get(v_s, ['key'])]), 'data-slot', 'menusection']), 'children': c_11}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s((og_t(og_eq(v_cols, '2')) ? 'grid grid-cols-1 gap-8 md:grid-cols-2' : 'flex flex-col gap-8')), 'attrs': og_attrs(['data-slot', 'items']), 'children': c_12}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '8', 'align': 'stretch', 'class': og_s((og_t(og_eq(v_cols, '1')) ? 'mx-auto w-full max-w-3xl' : '')), 'children': c_13}, 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_14)}, 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 restaurant-menu{* 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/restaurant-menu.json
A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
Props (p): id, title, lead, dishes, sections, empty, labels, cols, 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_sections = ($p['sections'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_cols = ($p['cols'] ?? '1')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_14}
{if og_t(og_eq(og_len($v_sections), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'star', 'title' => $v_empty]])|noescape}
{else}
{capture $c_13}
{=og_include('blocks/menu-section-nav.latte', ['p' => ['label' => og_get($v_labels, ['sections']), 'sections' => $v_sections, 'prefix' => $v_id, 'landmarkLabel' => $v_landmarkLabel]])|noescape}
{capture $c_12}
{foreach og_l($v_sections) as $v_s}
{capture $c_11}
{capture $c_3}
{capture $c_1}
{=og_text(og_get($v_s, ['title']))}
{/capture}
{=og_include('compose/Title.latte', ['as' => 3, 'size' => 'xl', 'weight' => 'bold', 'children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_get($v_s, ['note']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '0', 'class' => 'border-b border-border pb-2', 'children' => (string) $c_3])|noescape}
{capture $c_10}
{foreach og_l($v_dishes) as $v_d}
{if og_t(og_eq(og_get($v_d, ['tag']), og_get($v_s, ['key'])))}
{capture $c_9}
{capture $c_7}
{capture $c_4}
{=og_text(og_get($v_d, ['name']))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'font-semibold', 'children' => (string) $c_4])|noescape}
{if og_t(og_get($v_d, ['badge']))}
{capture $c_5}
{=og_text(og_get($v_d, ['badge']))}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'outline', 'size' => 'sm', 'children' => (string) $c_5])|noescape}
{/if}
{=og_include('compose/Inline.latte', ['class' => 'flex-1 border-b border-dotted border-border', 'attrs' => og_attrs(['aria-hidden', 'true'])])|noescape}
{capture $c_6}
{=og_text(og_money(og_get($v_d, ['price']), og_get($v_d, ['currency'])))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'font-semibold', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex items-baseline gap-2', 'children' => (string) $c_7])|noescape}
{capture $c_8}
{=og_text(og_tpl('{0} · {1}', [og_get($v_d, ['summary']), og_get($v_d, ['weight'])]))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['class' => 'flex flex-col gap-0', 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_9])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('compose/List.latte', ['tag' => 'ul', 'class' => 'flex flex-col gap-4', 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'attrs' => og_attrs(['id', og_tpl('{0}-{1}', [$v_id, og_get($v_s, ['key'])]), 'data-slot', 'menusection']), 'children' => (string) $c_11])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s((og_t(og_eq($v_cols, '2')) ? 'grid grid-cols-1 gap-8 md:grid-cols-2' : 'flex flex-col gap-8')), 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_12])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '8', 'align' => 'stretch', 'class' => og_s((og_t(og_eq($v_cols, '1')) ? 'mx-auto w-full max-w-3xl' : '')), 'children' => (string) $c_13])|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_14)])|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 restaurant-menu{#- 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/restaurant-menu.json
A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
Props (p): id, title, lead, dishes, sections, empty, labels, cols, 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_sections = og_def(p['sections'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_cols = og_def(p['cols'], '1') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_14 -%}
{%- if og_t(og_eq(og_len(v_sections), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'star', 'title': v_empty}}) }}
{%- else %}
{%- set c_13 -%}
{{ og_include('blocks/menu-section-nav.html.j2', {'p': {'label': og_get(v_labels, ['sections']), 'sections': v_sections, 'prefix': v_id, 'landmarkLabel': v_landmarkLabel}}) }}
{%- set c_12 -%}
{%- for v_s in og_l(v_sections) %}
{%- set c_11 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_s, ['title'])) }}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': 'xl', 'Weight': 'bold'}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_get(v_s, ['note'])) }}
{%- 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': '0', 'Class': 'border-b border-border pb-2'}, 'children': c_3}) }}
{%- set c_10 -%}
{%- for v_d in og_l(v_dishes) %}
{%- if og_t(og_eq(og_get(v_d, ['tag']), og_get(v_s, ['key']))) %}
{%- set c_9 -%}
{%- set c_7 -%}
{%- set c_4 -%}
{{ og_text(og_get(v_d, ['name'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'font-semibold'}, 'children': c_4}) }}
{%- if og_t(og_get(v_d, ['badge'])) %}
{%- set c_5 -%}
{{ og_text(og_get(v_d, ['badge'])) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm'}, 'children': c_5}) }}
{%- endif %}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'flex-1 border-b border-dotted border-border', 'Attrs': og_attrs(['aria-hidden', 'true'])}}) }}
{%- set c_6 -%}
{{ og_text(og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'font-semibold'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex items-baseline gap-2'}, 'children': c_7}) }}
{%- set c_8 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_d, ['summary']), og_get(v_d, ['weight'])])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Class': 'flex flex-col gap-0', 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_9}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/list.html.j2', {'p': {'Tag': 'ul', 'Class': 'flex flex-col gap-4'}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Attrs': og_attrs(['id', og_tpl('{0}-{1}', [v_id, og_get(v_s, ['key'])]), 'data-slot', 'menusection'])}, 'children': c_11}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(('grid grid-cols-1 gap-8 md:grid-cols-2' if og_t(og_eq(v_cols, '2')) else 'flex flex-col gap-8')), 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_12}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '8', 'Align': 'stretch', 'Class': og_s(('mx-auto w-full max-w-3xl' if og_t(og_eq(v_cols, '1')) else ''))}, 'children': c_13}) }}
{%- 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_14)}) }}
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.
A restaurant menu by sections: a nav of section links, then each section (heading and note) with its dishes as menu lines (name, a dotted leader, the price; the summary and weight below). No cart. Axes: cols (1, 2), tone.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| lead | string | "" | |
| dishes (required) | Dish[] | - | |
| sections (required) | DishSection[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| labels (required) | FoodLabels | - | |
| cols | "1" | "2" | "1" | |
| 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 |