Veggie Box
Fill a box by weight: produce tiles beside the box with a meter.
Install
npx ui8kit add veggie-boxPulls in: box, button, compose, dish-showcase, empty-state, group, inline, kit-box, kit-button, kit-label, kit-meter, kit-text, label, lucide-icon, media-frame, meter, number-field, section-frame, stack, text, utils
Preview
Vegetable box
Fill the box by weight.
Tomatoes
$4.50 per kg
Cucumbers
$3.20 per kg
Potatoes
$1.90 per kg
Carrots
$2.20 per kg
Apples
$3.80 per kg
Bell peppers
$5.90 per kg
Your order
Total
$21.50Code
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 veggie-box<!-- 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 vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the
item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout
(split, stacked), tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type VeggieBoxProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
fill?: number;
total: number;
currency: string;
layout?: "split" | "stacked";
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 Label from "../compose/Label.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Meter from "../compose/Meter.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 NumberField from "../components/number-field.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { fmtMoney, tpl } from "../utils";
let {
id,
title,
lead = "",
dishes,
empty = "",
labels,
fill = 60,
total,
currency,
layout = "split",
tone = "default",
landmarkLabel,
}: VeggieBoxProps = $props();
</script>
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{#if ((dishes?.length ?? 0) === 0)}
<EmptyState icon="package" title={empty} />
{:else}
<Box class="grid grid-cols-1 items-start gap-8 lg:grid-cols-3">
<Box
class={
(layout as string) === "split" ? "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2"
: "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6"
}
data-slot="items"
>
{#each dishes as d (d.id)}
<Stack gap="2" class="rounded bg-card inset-ring inset-ring-border p-4" data-slot="item">
<MediaFrame alt={d.name} src={d.image} ratio="1/1" />
<Text size="sm" weight="semibold">
{d.name}
</Text>
<Text size="xs" class="text-muted-foreground">
{tpl(labels.perKg, fmtMoney(d.price, d.currency))}
</Text>
<NumberField
value="1"
name={tpl("{0}-kg-{1}", id, d.id)}
min="0"
label={tpl(labels.weightOf, d.name)}
decrease={tpl(labels.decreaseOf, d.name)}
increase={tpl(labels.increaseOf, d.name)}
/>
</Stack>
{/each}
</Box>
<Stack
gap="4"
class={
(layout as string) === "split" ? "rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8"
: "rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3"
}
data-slot="summary"
>
<Text size="lg" weight="semibold">
{labels.summary}
</Text>
<Label for={tpl("{0}-fill", id)} class="text-sm text-muted-foreground">
{labels.boxFill}
</Label>
<Meter value={fill} min={0} max={100} id={tpl("{0}-fill", id)} />
<Group gap="2" align="baseline" justify="between">
<Text size="sm" class="text-muted-foreground">
{labels.total}
</Text>
<Inline class="text-2xl font-bold" role="status" aria-live="polite" data-slot="total">
{fmtMoney(total, currency)}
</Inline>
</Group>
<Button variant="default" size="lg" type="button" class="w-full">
<LucideIcon name="shopping-bag" size={16} />
{labels.order}
</Button>
</Stack>
</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 veggie-box// 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 vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the
* item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout
* (split, stacked), tone.
*/
import { type ReactNode } from "react";
import { Box, Button, Group, Inline, Label, Meter, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { NumberField } from "../components/number-field";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type VeggieBoxProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
fill?: number;
total: number;
currency: string;
layout?: "split" | "stacked";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function VeggieBox({
id,
title,
lead = "",
dishes,
empty = "",
labels,
fill = 60,
total,
currency,
layout = "split",
tone = "default",
landmarkLabel,
}: VeggieBoxProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((dishes?.length ?? 0) === 0) ? (
<EmptyState icon="package" title={empty} />
) : (
<Box className="grid grid-cols-1 items-start gap-8 lg:grid-cols-3">
<Box
className={
(layout as string) === "split" ? "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2"
: "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6"
}
data-slot="items"
>
{(dishes ?? []).map((d) => (
<Stack key={d.id} gap="2" className="rounded bg-card inset-ring inset-ring-border p-4" data-slot="item">
<MediaFrame alt={d.name} src={d.image} ratio="1/1" />
<Text size="sm" weight="semibold">
{d.name}
</Text>
<Text size="xs" className="text-muted-foreground">
{tpl(labels.perKg, fmtMoney(d.price, d.currency))}
</Text>
<NumberField
value="1"
name={tpl("{0}-kg-{1}", id, d.id)}
min="0"
label={tpl(labels.weightOf, d.name)}
decrease={tpl(labels.decreaseOf, d.name)}
increase={tpl(labels.increaseOf, d.name)}
/>
</Stack>
))}
</Box>
<Stack
gap="4"
className={
(layout as string) === "split" ? "rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8"
: "rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3"
}
data-slot="summary"
>
<Text size="lg" weight="semibold">
{labels.summary}
</Text>
<Label htmlFor={tpl("{0}-fill", id)} className="text-sm text-muted-foreground">
{labels.boxFill}
</Label>
<Meter value={fill} min={0} max={100} id={tpl("{0}-fill", id)} />
<Group gap="2" align="baseline" justify="between">
<Text size="sm" className="text-muted-foreground">
{labels.total}
</Text>
<Inline className="text-2xl font-bold" role="status" aria-live="polite" data-slot="total">
{fmtMoney(total, currency)}
</Inline>
</Group>
<Button variant="default" size="lg" type="button" className="w-full">
<LucideIcon name="shopping-bag" size={16} />
{labels.order}
</Button>
</Stack>
</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 veggie-box<!-- 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 vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the
item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout
(split, stacked), tone.
-->
<script lang="ts">
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type VeggieBoxProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
fill?: number;
total: number;
currency: string;
layout?: "split" | "stacked";
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 Label from "../compose/Label.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Meter from "../compose/Meter.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 NumberField from "../components/number-field.vue";
import SectionFrame from "../components/section-frame.vue";
import { fmtMoney, tpl } from "../utils";
const {
id,
title,
lead = "",
dishes,
empty = "",
labels,
fill = 60,
total,
currency,
layout = "split",
tone = "default",
landmarkLabel,
} = defineProps<VeggieBoxProps>();
</script>
<template>
<SectionFrame :id="id" :title="title" :lead="lead" :tone="tone" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((dishes?.length ?? 0) === 0)" icon="package" :title="empty" />
<Box v-else class="grid grid-cols-1 items-start gap-8 lg:grid-cols-3">
<Box
:class="
(layout as string) === 'split' ? 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2'
: 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6'
"
data-slot="items"
>
<Stack
v-for="d in dishes"
:key="d.id"
gap="2"
class="rounded bg-card inset-ring inset-ring-border p-4"
data-slot="item"
>
<MediaFrame :alt="d.name" :src="d.image" ratio="1/1" />
<Text size="sm" weight="semibold">
{{ d.name }}
</Text>
<Text size="xs" class="text-muted-foreground">
{{ tpl(labels.perKg, fmtMoney(d.price, d.currency)) }}
</Text>
<NumberField
value="1"
:name="tpl('{0}-kg-{1}', id, d.id)"
min="0"
:label="tpl(labels.weightOf, d.name)"
:decrease="tpl(labels.decreaseOf, d.name)"
:increase="tpl(labels.increaseOf, d.name)"
/>
</Stack>
</Box>
<Stack
gap="4"
:class="
(layout as string) === 'split' ? 'rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8'
: 'rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3'
"
data-slot="summary"
>
<Text size="lg" weight="semibold">
{{ labels.summary }}
</Text>
<Label :for="tpl('{0}-fill', id)" class="text-sm text-muted-foreground">
{{ labels.boxFill }}
</Label>
<Meter :value="fill" :min="0" :max="100" :id="tpl('{0}-fill', id)" />
<Group gap="2" align="baseline" justify="between">
<Text size="sm" class="text-muted-foreground">
{{ labels.total }}
</Text>
<Inline class="text-2xl font-bold" role="status" aria-live="polite" data-slot="total">
{{ fmtMoney(total, currency) }}
</Inline>
</Group>
<Button variant="default" size="lg" type="button" class="w-full">
<LucideIcon name="shopping-bag" :size="16" />
{{ labels.order }}
</Button>
</Stack>
</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 veggie-box// 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 vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the
* item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout
* (split, stacked), tone.
*/
import { For, type JSX } from "solid-js";
import { Box, Button, Group, Inline, Label, Meter, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { NumberField } from "../components/number-field";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";
export type VeggieBoxProps = {
id: string;
title: string;
lead?: string;
dishes: Dish[];
empty?: string;
labels: FoodLabels;
fill?: number;
total: number;
currency: string;
layout?: "split" | "stacked";
tone?: "default" | "muted";
landmarkLabel?: string;
};
export function VeggieBox({
id,
title,
lead = "",
dishes,
empty = "",
labels,
fill = 60,
total,
currency,
layout = "split",
tone = "default",
landmarkLabel,
}: VeggieBoxProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
{((dishes?.length ?? 0) === 0) ? (
<EmptyState icon="package" title={empty} />
) : (
<Box class="grid grid-cols-1 items-start gap-8 lg:grid-cols-3">
<Box
class={
(layout as string) === "split" ? "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2"
: "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6"
}
data-slot="items"
>
<For each={dishes ?? []}>{(d) => (
<Stack gap="2" class="rounded bg-card inset-ring inset-ring-border p-4" data-slot="item">
<MediaFrame alt={d.name} src={d.image} ratio="1/1" />
<Text size="sm" weight="semibold">
{d.name}
</Text>
<Text size="xs" class="text-muted-foreground">
{tpl(labels.perKg, fmtMoney(d.price, d.currency))}
</Text>
<NumberField
value="1"
name={tpl("{0}-kg-{1}", id, d.id)}
min="0"
label={tpl(labels.weightOf, d.name)}
decrease={tpl(labels.decreaseOf, d.name)}
increase={tpl(labels.increaseOf, d.name)}
/>
</Stack>
)}</For>
</Box>
<Stack
gap="4"
class={
(layout as string) === "split" ? "rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8"
: "rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3"
}
data-slot="summary"
>
<Text size="lg" weight="semibold">
{labels.summary}
</Text>
<Label for={tpl("{0}-fill", id)} class="text-sm text-muted-foreground">
{labels.boxFill}
</Label>
<Meter value={fill} min={0} max={100} id={tpl("{0}-fill", id)} />
<Group gap="2" align="baseline" justify="between">
<Text size="sm" class="text-muted-foreground">
{labels.total}
</Text>
<Inline class="text-2xl font-bold" role="status" aria-live="polite" data-slot="total">
{fmtMoney(total, currency)}
</Inline>
</Group>
<Button variant="default" size="lg" type="button" class="w-full">
<LucideIcon name="shopping-bag" size={16} />
{labels.order}
</Button>
</Stack>
</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 veggie-box// 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/veggie-box.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/icons"
"github.com/ui8kit/codegen/generated/templ/ui/label"
"github.com/ui8kit/codegen/generated/templ/ui/meter"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// VeggieBoxProps are the props of VeggieBox; the values are the JSON shapes of the TypeScript props.
type VeggieBoxProps 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"`
Fill any `json:"fill"`
Total any `json:"total"`
Currency any `json:"currency"`
Layout any `json:"layout"`
Tone any `json:"tone"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout (split, stacked), tone.
templ VeggieBox(p VeggieBoxProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLead := uiutils.Def(p.Lead, "") }}
{{ vDishes := p.Dishes }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vFill := uiutils.Def(p.Fill, float64(60)) }}
{{ vTotal := p.Total }}
{{ vCurrency := p.Currency }}
{{ vLayout := uiutils.Def(p.Layout, "split") }}
{{ 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: "package", Title: vEmpty})
} else {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "grid grid-cols-1 items-start gap-8 lg:grid-cols-3"}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "split")), "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2", "grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6")), Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vD := range uiutils.L(vDishes) {
@compose.Stack(compose.StackProps{Gap: "2", BoxProps: box.BoxProps{Class: "rounded bg-card inset-ring inset-ring-border p-4", Attrs: uiutils.Attrs("data-slot", "item")}}) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vD, "name"), Src: uiutils.Get(vD, "image"), Ratio: "1/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(uiutils.Get(vLabels, "perKg"), uiutils.Money(uiutils.Get(vD, "price"), uiutils.Get(vD, "currency")))) }
}
@NumberField(NumberFieldProps{Value: "1", Name: uiutils.Tpl("{0}-kg-{1}", vId, uiutils.Get(vD, "id")), Min: "0", Label: uiutils.Tpl(uiutils.Get(vLabels, "weightOf"), uiutils.Get(vD, "name")), Decrease: uiutils.Tpl(uiutils.Get(vLabels, "decreaseOf"), uiutils.Get(vD, "name")), Increase: uiutils.Tpl(uiutils.Get(vLabels, "increaseOf"), uiutils.Get(vD, "name"))})
}
}
}
@compose.Stack(compose.StackProps{Gap: "4", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "split")), "rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8", "rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3")), Attrs: uiutils.Attrs("data-slot", "summary")}}) {
@compose.Text(compose.TextProps{Size: "lg", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLabels, "summary")) }
}
@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{For: uiutils.S(uiutils.Tpl("{0}-fill", vId)), Class: "text-sm text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "boxFill")) }
}
@compose.Meter(compose.MeterProps{MeterProps: meter.MeterProps{Value: uiutils.SP(vFill), Min: "0", Max: "100", Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-fill", vId))}})
@compose.Group(compose.GroupProps{Gap: "2", Align: "baseline", Justify: "between", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "total")) }
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-2xl font-bold", Attrs: uiutils.Attrs("role", "status", "aria-live", "polite", "data-slot", "total")}}) {
{ uiutils.Text(uiutils.Money(vTotal, vCurrency)) }
}
}
@compose.Button(compose.ButtonProps{Variant: "default", Size: "lg", ButtonProps: button.ButtonProps{Type: "button", Class: "w-full"}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "shopping-bag", Size: 16})
{ uiutils.Text(uiutils.Get(vLabels, "order")) }
}
}
}
}
}
}
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 veggie-box{#- 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/veggie-box.json
A vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout (split, stacked), tone.
Props (p): id, title, lead, dishes, empty, labels, fill, total, currency, 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_fill = (p.fill ?? 60) -%}
{%- set v_total = (p.total ?? null) -%}
{%- set v_currency = (p.currency ?? null) -%}
{%- set v_layout = (p.layout ?? 'split') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_13 -%}
{%- if og_t(og_eq(og_len(v_dishes), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'package', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_12 -%}
{%- set c_4 -%}
{%- for v_d in og_l(v_dishes) %}
{%- set c_3 -%}
{{ 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_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(og_get(v_labels, ['perKg']), [og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
{{ include('blocks/number-field.html.twig', {'p': {'value': '1', 'name': og_tpl('{0}-kg-{1}', [v_id, og_get(v_d, ['id'])]), 'min': '0', 'label': og_tpl(og_get(v_labels, ['weightOf']), [og_get(v_d, ['name'])]), 'decrease': og_tpl(og_get(v_labels, ['decreaseOf']), [og_get(v_d, ['name'])]), 'increase': og_tpl(og_get(v_labels, ['increaseOf']), [og_get(v_d, ['name'])])}}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'class': 'rounded bg-card inset-ring inset-ring-border p-4', 'attrs': og_attrs(['data-slot', 'item']), 'children': c_3}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s((og_t(og_eq(v_layout, 'split')) ? 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2' : 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6')), 'attrs': og_attrs(['data-slot', 'items']), 'children': c_4}, with_context = false) }}
{%- set c_11 -%}
{%- set c_5 -%}
{{ og_text(og_get(v_labels, ['summary'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'lg', 'weight': 'semibold', 'children': c_5}, with_context = false) }}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['boxFill'])) }}
{%- endset -%}
{{ include('compose/Label.html.twig', {'htmlFor': og_s(og_tpl('{0}-fill', [v_id])), 'class': 'text-sm text-muted-foreground', 'children': c_6}, with_context = false) }}
{{ include('compose/Meter.html.twig', {'value': og_s(v_fill), 'min': og_s(0), 'max': og_s(100), 'attrs': og_attrs(['id', og_tpl('{0}-fill', [v_id])])}, with_context = false) }}
{%- set c_9 -%}
{%- set c_7 -%}
{{ og_text(og_get(v_labels, ['total'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_7}, with_context = false) }}
{%- set c_8 -%}
{{ og_text(og_money(v_total, v_currency)) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'text-2xl font-bold', 'attrs': og_attrs(['role', 'status', 'aria-live', 'polite', 'data-slot', 'total']), 'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'align': 'baseline', 'justify': 'between', 'children': c_9}, with_context = false) }}
{%- set c_10 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'shopping-bag', 'size': 16}, with_context = false) }}
{{ og_text(og_get(v_labels, ['order'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'lg', 'type': 'button', 'class': 'w-full', 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'class': og_s((og_t(og_eq(v_layout, 'split')) ? 'rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8' : 'rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3')), 'attrs': og_attrs(['data-slot', 'summary']), 'children': c_11}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'grid grid-cols-1 items-start gap-8 lg:grid-cols-3', 'children': c_12}, 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_13)}, 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 veggie-box{* 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/veggie-box.json
A vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout (split, stacked), tone.
Props (p): id, title, lead, dishes, empty, labels, fill, total, currency, 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_fill = ($p['fill'] ?? 60)}
{var $v_total = ($p['total'] ?? null)}
{var $v_currency = ($p['currency'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'split')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_13}
{if og_t(og_eq(og_len($v_dishes), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'package', 'title' => $v_empty]])|noescape}
{else}
{capture $c_12}
{capture $c_4}
{foreach og_l($v_dishes) as $v_d}
{capture $c_3}
{=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_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(og_get($v_labels, ['perKg']), [og_money(og_get($v_d, ['price']), og_get($v_d, ['currency']))]))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{=og_include('blocks/number-field.latte', ['p' => ['value' => '1', 'name' => og_tpl('{0}-kg-{1}', [$v_id, og_get($v_d, ['id'])]), 'min' => '0', 'label' => og_tpl(og_get($v_labels, ['weightOf']), [og_get($v_d, ['name'])]), 'decrease' => og_tpl(og_get($v_labels, ['decreaseOf']), [og_get($v_d, ['name'])]), 'increase' => og_tpl(og_get($v_labels, ['increaseOf']), [og_get($v_d, ['name'])])]])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'class' => 'rounded bg-card inset-ring inset-ring-border p-4', 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_3])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s((og_t(og_eq($v_layout, 'split')) ? 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2' : 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6')), 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_4])|noescape}
{capture $c_11}
{capture $c_5}
{=og_text(og_get($v_labels, ['summary']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'lg', 'weight' => 'semibold', 'children' => (string) $c_5])|noescape}
{capture $c_6}
{=og_text(og_get($v_labels, ['boxFill']))}
{/capture}
{=og_include('compose/Label.latte', ['htmlFor' => og_s(og_tpl('{0}-fill', [$v_id])), 'class' => 'text-sm text-muted-foreground', 'children' => (string) $c_6])|noescape}
{=og_include('compose/Meter.latte', ['value' => og_s($v_fill), 'min' => og_s(0), 'max' => og_s(100), 'attrs' => og_attrs(['id', og_tpl('{0}-fill', [$v_id])])])|noescape}
{capture $c_9}
{capture $c_7}
{=og_text(og_get($v_labels, ['total']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_7])|noescape}
{capture $c_8}
{=og_text(og_money($v_total, $v_currency))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'text-2xl font-bold', 'attrs' => og_attrs(['role', 'status', 'aria-live', 'polite', 'data-slot', 'total']), 'children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'baseline', 'justify' => 'between', 'children' => (string) $c_9])|noescape}
{capture $c_10}
{=og_include('icons/LucideIcon.latte', ['name' => 'shopping-bag', 'size' => 16])|noescape}
{=og_text(og_get($v_labels, ['order']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'lg', 'type' => 'button', 'class' => 'w-full', 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'class' => og_s((og_t(og_eq($v_layout, 'split')) ? 'rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8' : 'rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3')), 'attrs' => og_attrs(['data-slot', 'summary']), 'children' => (string) $c_11])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'grid grid-cols-1 items-start gap-8 lg:grid-cols-3', 'children' => (string) $c_12])|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_13)])|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 veggie-box{#- 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/veggie-box.json
A vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout (split, stacked), tone.
Props (p): id, title, lead, dishes, empty, labels, fill, total, currency, 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_fill = og_def(p['fill'], 60) -%}
{%- set v_total = og_def(p['total'], none) -%}
{%- set v_currency = og_def(p['currency'], none) -%}
{%- set v_layout = og_def(p['layout'], 'split') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_13 -%}
{%- if og_t(og_eq(og_len(v_dishes), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'package', 'title': v_empty}}) }}
{%- else %}
{%- set c_12 -%}
{%- set c_4 -%}
{%- for v_d in og_l(v_dishes) %}
{%- set c_3 -%}
{{ 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_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(og_get(v_labels, ['perKg']), [og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
{{ og_include('blocks/number-field.html.j2', {'p': {'value': '1', 'name': og_tpl('{0}-kg-{1}', [v_id, og_get(v_d, ['id'])]), 'min': '0', 'label': og_tpl(og_get(v_labels, ['weightOf']), [og_get(v_d, ['name'])]), 'decrease': og_tpl(og_get(v_labels, ['decreaseOf']), [og_get(v_d, ['name'])]), 'increase': og_tpl(og_get(v_labels, ['increaseOf']), [og_get(v_d, ['name'])])}}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Class': 'rounded bg-card inset-ring inset-ring-border p-4', 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_3}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(('grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-2' if og_t(og_eq(v_layout, 'split')) else 'grid grid-cols-2 gap-4 md:grid-cols-3 lg:col-span-3 lg:grid-cols-6')), 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_4}) }}
{%- set c_11 -%}
{%- set c_5 -%}
{{ og_text(og_get(v_labels, ['summary'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'lg', 'Weight': 'semibold'}, 'children': c_5}) }}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['boxFill'])) }}
{%- endset -%}
{{ og_include('compose/label.html.j2', {'p': {'For': og_s(og_tpl('{0}-fill', [v_id])), 'Class': 'text-sm text-muted-foreground'}, 'children': c_6}) }}
{{ og_include('compose/meter.html.j2', {'p': {'Value': og_s(v_fill), 'Min': og_s(0), 'Max': og_s(100), 'Attrs': og_attrs(['id', og_tpl('{0}-fill', [v_id])])}}) }}
{%- set c_9 -%}
{%- set c_7 -%}
{{ og_text(og_get(v_labels, ['total'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_7}) }}
{%- set c_8 -%}
{{ og_text(og_money(v_total, v_currency)) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-2xl font-bold', 'Attrs': og_attrs(['role', 'status', 'aria-live', 'polite', 'data-slot', 'total'])}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'baseline', 'Justify': 'between'}, 'children': c_9}) }}
{%- set c_10 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'shopping-bag', 'Size': 16}}) }}
{{ og_text(og_get(v_labels, ['order'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'lg', 'Type': 'button', 'Class': 'w-full'}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Class': og_s(('rounded bg-card inset-ring inset-ring-border p-6 lg:sticky lg:top-8' if og_t(og_eq(v_layout, 'split')) else 'rounded bg-card inset-ring inset-ring-border p-6 lg:col-span-3')), 'Attrs': og_attrs(['data-slot', 'summary'])}, 'children': c_11}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'grid grid-cols-1 items-start gap-8 lg:grid-cols-3'}, 'children': c_12}) }}
{%- 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_13)}) }}
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 vegetable box by weight: produce tiles (picture, name, price per kg, a weight field in kg named after the item) beside the box card with a meter of how full the box is, the total and the order button. Axes: layout (split, stacked), 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 | - | |
| fill | number | 60 | how full the box is, percent |
| total (required) | number | - | minor units |
| currency (required) | string | - | |
| layout | "split" | "stacked" | "split" | |
| 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 |