Grocery List
A compact list of groceries with a small picture and an add button.
Install
npx ui8kit add grocery-listPulls in: add-icon, compose, dish-showcase, empty-state, inline, kit-box, kit-text, list, list-item, media-frame, section-frame, stack, text, utils
Preview
Groceries
Everyday basics, delivered today.
- $1.60
Whole milk
1 l · dairy
- $3.90
Free-range eggs
10 pcs · dairy
- $2.90
Rye bread
500 g · bakery
- $6.90
Hard cheese
200 g · dairy
- $2.50
Long grain rice
1 kg · pantry
- $8.90
Olive oil
500 ml · pantry
- $3.40
Salad greens
150 g · vegetables
- $2.60
Lemons
4 pcs · fruit
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 grocery-list<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add
button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type GroceryListProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
thumbs?: "show" | "hide";
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script lang="ts">
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 AddIcon from "../components/add-icon.svelte";
import EmptyState from "../components/empty-state.svelte";
import MediaFrame from "../components/media-frame.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { fmtMoney, tpl } from "../utils";
let {
id,
title,
lead = "",
dishes,
empty = "",
labels,
thumbs = "show",
cols = "2",
tone = "default",
landmarkLabel,
}: GroceryListProps = $props();
</script>
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{#if ((dishes?.length ?? 0) === 0)}
<EmptyState icon="shopping-bag" title={empty} />
{:else}
<List
tag="ul"
class={
(cols as string) === "2" ? "grid grid-cols-1 gap-x-8 md:grid-cols-2"
: "grid grid-cols-1"
}
data-slot="items"
>
{#each dishes as d (d.id)}
<ListItem class="flex items-center gap-4 border-b border-border py-2" data-slot="item">
{#if ((thumbs as string) === "show")}
<MediaFrame alt={d.name} src={d.image} ratio="1/1" class="size-12 shrink-0" />
{/if}
<Stack gap="0" class="min-w-0 flex-1">
<Text size="sm" weight="semibold">
{d.name}
</Text>
<Text size="xs" class="text-muted-foreground">
{tpl("{0} · {1}", d.weight, d.tag)}
</Text>
</Stack>
<Inline class="text-sm font-bold">
{fmtMoney(d.price, d.currency)}
</Inline>
<AddIcon label={tpl(labels.addOf, d.name)} />
</ListItem>
{/each}
</List>
{/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 grocery-list// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add
* button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
*/
import { type ReactNode } from "react";
import { Inline, List, ListItem, Stack, Text } from "../compose";
import { AddIcon } from "../components/add-icon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type GroceryListProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
thumbs?: "show" | "hide";
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function GroceryList({
id,
title,
lead = "",
dishes,
empty = "",
labels,
thumbs = "show",
cols = "2",
tone = "default",
landmarkLabel,
}: GroceryListProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((dishes?.length ?? 0) === 0) ? (
<EmptyState icon="shopping-bag" title={empty} />
) : (
<List
tag="ul"
className={
(cols as string) === "2" ? "grid grid-cols-1 gap-x-8 md:grid-cols-2"
: "grid grid-cols-1"
}
data-slot="items"
>
{(dishes ?? []).map((d) => (
<ListItem key={d.id} className="flex items-center gap-4 border-b border-border py-2" data-slot="item">
{((thumbs as string) === "show") ? (
<MediaFrame alt={d.name} src={d.image} ratio="1/1" className="size-12 shrink-0" />
) : null}
<Stack gap="0" className="min-w-0 flex-1">
<Text size="sm" weight="semibold">
{d.name}
</Text>
<Text size="xs" className="text-muted-foreground">
{tpl("{0} · {1}", d.weight, d.tag)}
</Text>
</Stack>
<Inline className="text-sm font-bold">
{fmtMoney(d.price, d.currency)}
</Inline>
<AddIcon label={tpl(labels.addOf, d.name)} />
</ListItem>
))}
</List>
)}
</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 grocery-list<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add
button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
-->
<script lang="ts">
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type GroceryListProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
thumbs?: "show" | "hide";
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
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 AddIcon from "../components/add-icon.vue";
import EmptyState from "../components/empty-state.vue";
import MediaFrame from "../components/media-frame.vue";
import SectionFrame from "../components/section-frame.vue";
import { fmtMoney, tpl } from "../utils";
const {
id,
title,
lead = "",
dishes,
empty = "",
labels,
thumbs = "show",
cols = "2",
tone = "default",
landmarkLabel,
} = defineProps<GroceryListProps>();
</script>
<template>
<SectionFrame :id="id" :title="title" :lead="lead" :tone="tone" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((dishes?.length ?? 0) === 0)" icon="shopping-bag" :title="empty" />
<List v-else
tag="ul"
:class="
(cols as string) === '2' ? 'grid grid-cols-1 gap-x-8 md:grid-cols-2'
: 'grid grid-cols-1'
"
data-slot="items"
>
<ListItem
v-for="d in dishes"
:key="d.id"
class="flex items-center gap-4 border-b border-border py-2"
data-slot="item"
>
<MediaFrame
v-if="((thumbs as string) === 'show')"
:alt="d.name"
:src="d.image"
ratio="1/1"
class="size-12 shrink-0"
/>
<Stack gap="0" class="min-w-0 flex-1">
<Text size="sm" weight="semibold">
{{ d.name }}
</Text>
<Text size="xs" class="text-muted-foreground">
{{ tpl("{0} · {1}", d.weight, d.tag) }}
</Text>
</Stack>
<Inline class="text-sm font-bold">
{{ fmtMoney(d.price, d.currency) }}
</Inline>
<AddIcon :label="tpl(labels.addOf, d.name)" />
</ListItem>
</List>
</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 grocery-list// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add
* button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
*/
import { For, type JSX } from "solid-js";
import { Inline, List, ListItem, Stack, Text } from "../compose";
import { AddIcon } from "../components/add-icon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type GroceryListProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
thumbs?: "show" | "hide";
cols?: "1" | "2";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function GroceryList({
id,
title,
lead = "",
dishes,
empty = "",
labels,
thumbs = "show",
cols = "2",
tone = "default",
landmarkLabel,
}: GroceryListProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((dishes?.length ?? 0) === 0) ? (
<EmptyState icon="shopping-bag" title={empty} />
) : (
<List
tag="ul"
class={
(cols as string) === "2" ? "grid grid-cols-1 gap-x-8 md:grid-cols-2"
: "grid grid-cols-1"
}
data-slot="items"
>
<For each={dishes ?? []}>{(d) => (
<ListItem class="flex items-center gap-4 border-b border-border py-2" data-slot="item">
{((thumbs as string) === "show") ? (
<MediaFrame alt={d.name} src={d.image} ratio="1/1" class="size-12 shrink-0" />
) : null}
<Stack gap="0" class="min-w-0 flex-1">
<Text size="sm" weight="semibold">
{d.name}
</Text>
<Text size="xs" class="text-muted-foreground">
{tpl("{0} · {1}", d.weight, d.tag)}
</Text>
</Stack>
<Inline class="text-sm font-bold">
{fmtMoney(d.price, d.currency)}
</Inline>
<AddIcon label={tpl(labels.addOf, d.name)} />
</ListItem>
)}</For>
</List>
)}
</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 grocery-list// 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/grocery-list.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"
)
// GroceryListProps are the props of GroceryList; the values are the JSON shapes of the TypeScript props.
type GroceryListProps 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"`
Thumbs any `json:"thumbs"`
Cols any `json:"cols"`
Tone any `json:"tone"`
LandmarkLabel any `json:"landmarkLabel"`
}
// Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
templ GroceryList(p GroceryListProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLead := uiutils.Def(p.Lead, "") }}
{{ vDishes := p.Dishes }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vThumbs := uiutils.Def(p.Thumbs, "show") }}
{{ vCols := uiutils.Def(p.Cols, "2") }}
{{ 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: "shopping-bag", Title: vEmpty})
} else {
@compose.List(compose.ListProps{BoxProps: box.BoxProps{Tag: "ul", Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "grid grid-cols-1 gap-x-8 md:grid-cols-2", "grid grid-cols-1")), Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vD := range uiutils.L(vDishes) {
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Class: "flex items-center gap-4 border-b border-border py-2", Attrs: uiutils.Attrs("data-slot", "item")}}) {
if uiutils.Eq(vThumbs, "show") {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vD, "name"), Src: uiutils.Get(vD, "image"), Ratio: "1/1", Class: uiutils.Cnv("size-12 shrink-0")})
}
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: "min-w-0 flex-1"}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vD, "name")) }
}
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Tpl("{0} · {1}", uiutils.Get(vD, "weight"), uiutils.Get(vD, "tag"))) }
}
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-sm font-bold"}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vD, "price"), uiutils.Get(vD, "currency"))) }
}
@AddIcon(AddIconProps{Label: uiutils.Tpl(uiutils.Get(vLabels, "addOf"), uiutils.Get(vD, "name"))})
}
}
}
}
}
}
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 grocery-list{#- 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/grocery-list.json
Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
Props (p): id, title, lead, dishes, empty, labels, thumbs, 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_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_thumbs = (p.thumbs ?? 'show') -%}
{%- set v_cols = (p.cols ?? '2') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_7 -%}
{%- if og_t(og_eq(og_len(v_dishes), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'shopping-bag', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_6 -%}
{%- for v_d in og_l(v_dishes) %}
{%- set c_5 -%}
{%- if og_t(og_eq(v_thumbs, 'show')) %}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_d, ['name']), 'src': og_get(v_d, ['image']), 'ratio': '1/1', 'className': og_cnv(['size-12 shrink-0'])}}, with_context = false) }}
{%- endif %}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_d, ['name'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_d, ['weight']), og_get(v_d, ['tag'])])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '0', 'class': 'min-w-0 flex-1', 'children': c_3}, with_context = false) }}
{%- 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-sm font-bold', 'children': c_4}, with_context = false) }}
{{ include('blocks/add-icon.html.twig', {'p': {'label': og_tpl(og_get(v_labels, ['addOf']), [og_get(v_d, ['name'])])}}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'class': 'flex items-center gap-4 border-b border-border py-2', 'attrs': og_attrs(['data-slot', 'item']), 'children': c_5}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/List.html.twig', {'tag': 'ul', 'class': og_s((og_t(og_eq(v_cols, '2')) ? 'grid grid-cols-1 gap-x-8 md:grid-cols-2' : 'grid grid-cols-1')), 'attrs': og_attrs(['data-slot', 'items']), 'children': c_6}, 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_7)}, 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 grocery-list{* 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/grocery-list.json
Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
Props (p): id, title, lead, dishes, empty, labels, thumbs, 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_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_thumbs = ($p['thumbs'] ?? 'show')}
{var $v_cols = ($p['cols'] ?? '2')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_7}
{if og_t(og_eq(og_len($v_dishes), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'shopping-bag', 'title' => $v_empty]])|noescape}
{else}
{capture $c_6}
{foreach og_l($v_dishes) as $v_d}
{capture $c_5}
{if og_t(og_eq($v_thumbs, 'show'))}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_d, ['name']), 'src' => og_get($v_d, ['image']), 'ratio' => '1/1', 'className' => og_cnv(['size-12 shrink-0'])]])|noescape}
{/if}
{capture $c_3}
{capture $c_1}
{=og_text(og_get($v_d, ['name']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_tpl('{0} · {1}', [og_get($v_d, ['weight']), og_get($v_d, ['tag'])]))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '0', 'class' => 'min-w-0 flex-1', 'children' => (string) $c_3])|noescape}
{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-sm font-bold', 'children' => (string) $c_4])|noescape}
{=og_include('blocks/add-icon.latte', ['p' => ['label' => og_tpl(og_get($v_labels, ['addOf']), [og_get($v_d, ['name'])])]])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['class' => 'flex items-center gap-4 border-b border-border py-2', 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_5])|noescape}
{/foreach}
{/capture}
{=og_include('compose/List.latte', ['tag' => 'ul', 'class' => og_s((og_t(og_eq($v_cols, '2')) ? 'grid grid-cols-1 gap-x-8 md:grid-cols-2' : 'grid grid-cols-1')), 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_6])|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_7)])|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 grocery-list{#- 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/grocery-list.json
Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), tone.
Props (p): id, title, lead, dishes, empty, labels, thumbs, 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_empty = og_def(p['empty'], '') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_thumbs = og_def(p['thumbs'], 'show') -%}
{%- set v_cols = og_def(p['cols'], '2') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_7 -%}
{%- if og_t(og_eq(og_len(v_dishes), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'shopping-bag', 'title': v_empty}}) }}
{%- else %}
{%- set c_6 -%}
{%- for v_d in og_l(v_dishes) %}
{%- set c_5 -%}
{%- if og_t(og_eq(v_thumbs, 'show')) %}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_d, ['name']), 'src': og_get(v_d, ['image']), 'ratio': '1/1', 'className': og_cnv(['size-12 shrink-0'])}}) }}
{%- endif %}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_d, ['name'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_tpl('{0} · {1}', [og_get(v_d, ['weight']), og_get(v_d, ['tag'])])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '0', 'Class': 'min-w-0 flex-1'}, 'children': c_3}) }}
{%- 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-sm font-bold'}, 'children': c_4}) }}
{{ og_include('blocks/add-icon.html.j2', {'p': {'label': og_tpl(og_get(v_labels, ['addOf']), [og_get(v_d, ['name'])])}}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Class': 'flex items-center gap-4 border-b border-border py-2', 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_5}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/list.html.j2', {'p': {'Tag': 'ul', 'Class': og_s(('grid grid-cols-1 gap-x-8 md:grid-cols-2' if og_t(og_eq(v_cols, '2')) else 'grid grid-cols-1')), 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_6}) }}
{%- 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_7)}) }}
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.
Groceries as a compact list: a small square picture (or none), the name, the pack size, the price and an add button, in one or two columns. Axes: thumbs (show, hide), cols (1, 2), 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 | - | |
| thumbs | "show" | "hide" | "show" | |
| cols | "1" | "2" | "2" | |
| 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 |