Skip to content
ui8kit

block / commerce

Dish Compare

Grill cuts side by side: a table or compare cards.

Install

npx ui8kit add dish-compare

Pulls in: box, compose, cut-cards, dish-showcase, empty-state, kit-box, section-frame, table, table-body, table-caption, table-cell, table-head, table-head-cell, table-row, utils

Preview

Compare the cuts

Weight, cooking time, heat and price side by side.

Grill cuts compared by weight, cooking time, heat, marinade and price
CutWeight{0} minHeatMarinadePrice
Pork neck500 g25 minmedium heatMarinade: onion, pepper$18.90
Chicken thigh500 g20 minmedium heatMarinade: yogurt, garlic$12.90
Lamb rack500 g15 minhigh heatMarinade: rosemary$34.90
Beef sirloin500 g12 minhigh heatMarinade: salt, pepper$29.90

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking
  time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes:
  layout (table, cards), tone.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Dish, FoodLabels } from "./dish-showcase.types";

  export type DishCompareProps = {
    id: string;
    title: string;
    lead?: string;
    dishes: Dish[];
    empty?: string;
    labels: FoodLabels;
    layout?: "table" | "cards";
    tone?: "default" | "muted";
    landmarkLabel?: string;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Table from "../compose/Table.svelte";
  import TableBody from "../compose/TableBody.svelte";
  import TableCaption from "../compose/TableCaption.svelte";
  import TableCell from "../compose/TableCell.svelte";
  import TableHead from "../compose/TableHead.svelte";
  import TableHeadCell from "../compose/TableHeadCell.svelte";
  import TableRow from "../compose/TableRow.svelte";
  import CutCards from "../components/cut-cards.svelte";
  import EmptyState from "../components/empty-state.svelte";
  import SectionFrame from "../components/section-frame.svelte";
  import { fmtMoney, tpl } from "../utils";

  let {
    id,
    title,
    lead = "",
    dishes,
    empty = "",
    labels,
    layout = "table",
    tone = "default",
    landmarkLabel,
  }: DishCompareProps = $props();
</script>

<SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
  {#if ((dishes?.length ?? 0) === 0)}
    <EmptyState icon="scale" title={empty} />
  {:else if ((layout as string) === "table")}
    <Box class="w-full overflow-x-auto" data-slot="compare-table">
      <Table class="w-full text-sm">
        <TableCaption class="sr-only">
          {labels.caption}
        </TableCaption>
        <TableHead>
          <TableRow>
            <TableHeadCell scope="col" class="py-2">
              {labels.cut}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {labels.weight}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {labels.minutes}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {labels.heat}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {labels.marinade}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {labels.price}
            </TableHeadCell>
          </TableRow>
        </TableHead>
        <TableBody>
          {#each dishes as d (d.id)}
            <TableRow data-slot="item">
              <TableHeadCell scope="row" class="py-2 font-semibold">
                {d.name}
              </TableHeadCell>
              <TableCell>
                {d.weight}
              </TableCell>
              <TableCell>
                {tpl(labels.minutes, (d.minutes == null ? undefined : String(d.minutes)))}
              </TableCell>
              <TableCell>
                {d.tag}
              </TableCell>
              <TableCell>
                {#each d.items as x (x)}
                  {x}
                {/each}
              </TableCell>
              <TableCell class="font-semibold">
                {fmtMoney(d.price, d.currency)}
              </TableCell>
            </TableRow>
          {/each}
        </TableBody>
      </Table>
    </Box>
  {:else}
    <CutCards dishes={dishes} labels={labels} />
  {/if}
</SectionFrame>

Svelte registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking
 * time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes:
 * layout (table, cards), tone.
 */
import { Fragment, type ReactNode } from "react";
import { Box, Table, TableBody, TableCaption, TableCell, TableHead, TableHeadCell, TableRow } from "../compose";
import { CutCards } from "../components/cut-cards";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";

export type DishCompareProps = {
  id: string;
  title: string;
  lead?: string;
  dishes: Dish[];
  empty?: string;
  labels: FoodLabels;
  layout?: "table" | "cards";
  tone?: "default" | "muted";
  landmarkLabel?: string;
};

export function DishCompare({
  id,
  title,
  lead = "",
  dishes,
  empty = "",
  labels,
  layout = "table",
  tone = "default",
  landmarkLabel,
}: DishCompareProps) {
  return (
    <SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
      {((dishes?.length ?? 0) === 0) ? (
        <EmptyState icon="scale" title={empty} />
      ) : ((layout as string) === "table") ? (
        <Box className="w-full overflow-x-auto" data-slot="compare-table">
          <Table className="w-full text-sm">
            <TableCaption className="sr-only">
              {labels.caption}
            </TableCaption>
            <TableHead>
              <TableRow>
                <TableHeadCell scope="col" className="py-2">
                  {labels.cut}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-2">
                  {labels.weight}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-2">
                  {labels.minutes}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-2">
                  {labels.heat}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-2">
                  {labels.marinade}
                </TableHeadCell>
                <TableHeadCell scope="col" className="py-2">
                  {labels.price}
                </TableHeadCell>
              </TableRow>
            </TableHead>
            <TableBody>
              {(dishes ?? []).map((d) => (
                <TableRow key={d.id} data-slot="item">
                  <TableHeadCell scope="row" className="py-2 font-semibold">
                    {d.name}
                  </TableHeadCell>
                  <TableCell>
                    {d.weight}
                  </TableCell>
                  <TableCell>
                    {tpl(labels.minutes, (d.minutes == null ? undefined : String(d.minutes)))}
                  </TableCell>
                  <TableCell>
                    {d.tag}
                  </TableCell>
                  <TableCell>
                    {(d.items ?? []).map((x) => (
                      <Fragment key={x}>
                        {x}
                      </Fragment>
                    ))}
                  </TableCell>
                  <TableCell className="font-semibold">
                    {fmtMoney(d.price, d.currency)}
                  </TableCell>
                </TableRow>
              ))}
            </TableBody>
          </Table>
        </Box>
      ) : (
        <CutCards dishes={dishes} labels={labels} />
      )}
    </SectionFrame>
  );
}

React registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking
  time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes:
  layout (table, cards), tone.
-->
<script lang="ts">
import type { Dish, FoodLabels } from "./dish-showcase.types";

export type DishCompareProps = {
  id: string;
  title: string;
  lead?: string;
  dishes: Dish[];
  empty?: string;
  labels: FoodLabels;
  layout?: "table" | "cards";
  tone?: "default" | "muted";
  landmarkLabel?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Table from "../compose/Table.vue";
import TableBody from "../compose/TableBody.vue";
import TableCaption from "../compose/TableCaption.vue";
import TableCell from "../compose/TableCell.vue";
import TableHead from "../compose/TableHead.vue";
import TableHeadCell from "../compose/TableHeadCell.vue";
import TableRow from "../compose/TableRow.vue";
import CutCards from "../components/cut-cards.vue";
import EmptyState from "../components/empty-state.vue";
import SectionFrame from "../components/section-frame.vue";
import { fmtMoney, tpl } from "../utils";

const {
  id,
  title,
  lead = "",
  dishes,
  empty = "",
  labels,
  layout = "table",
  tone = "default",
  landmarkLabel,
} = defineProps<DishCompareProps>();
</script>

<template>
  <SectionFrame :id="id" :title="title" :lead="lead" :tone="tone" :landmarkLabel="landmarkLabel">
    <EmptyState v-if="((dishes?.length ?? 0) === 0)" icon="scale" :title="empty" />
    <Box v-else-if="((layout as string) === 'table')" class="w-full overflow-x-auto" data-slot="compare-table">
      <Table class="w-full text-sm">
        <TableCaption class="sr-only">
          {{ labels.caption }}
        </TableCaption>
        <TableHead>
          <TableRow>
            <TableHeadCell scope="col" class="py-2">
              {{ labels.cut }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {{ labels.weight }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {{ labels.minutes }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {{ labels.heat }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {{ labels.marinade }}
            </TableHeadCell>
            <TableHeadCell scope="col" class="py-2">
              {{ labels.price }}
            </TableHeadCell>
          </TableRow>
        </TableHead>
        <TableBody>
          <TableRow v-for="d in dishes" :key="d.id" data-slot="item">
            <TableHeadCell scope="row" class="py-2 font-semibold">
              {{ d.name }}
            </TableHeadCell>
            <TableCell>
              {{ d.weight }}
            </TableCell>
            <TableCell>
              {{ tpl(labels.minutes, (d.minutes == null ? undefined : String(d.minutes))) }}
            </TableCell>
            <TableCell>
              {{ d.tag }}
            </TableCell>
            <TableCell>
              <template v-for="x in d.items" :key="x">
                {{ x }}
              </template>
            </TableCell>
            <TableCell class="font-semibold">
              {{ fmtMoney(d.price, d.currency) }}
            </TableCell>
          </TableRow>
        </TableBody>
      </Table>
    </Box>
    <CutCards v-else :dishes="dishes" :labels="labels" />
  </SectionFrame>
</template>

Vue registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking
 * time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes:
 * layout (table, cards), tone.
 */
import { For, type JSX } from "solid-js";
import { Box, Table, TableBody, TableCaption, TableCell, TableHead, TableHeadCell, TableRow } from "../compose";
import { CutCards } from "../components/cut-cards";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { fmtMoney, tpl } from "../utils";
import type { Dish, FoodLabels } from "./dish-showcase.types";

export type DishCompareProps = {
  id: string;
  title: string;
  lead?: string;
  dishes: Dish[];
  empty?: string;
  labels: FoodLabels;
  layout?: "table" | "cards";
  tone?: "default" | "muted";
  landmarkLabel?: string;
};

export function DishCompare({
  id,
  title,
  lead = "",
  dishes,
  empty = "",
  labels,
  layout = "table",
  tone = "default",
  landmarkLabel,
}: DishCompareProps) {
  return (
    <SectionFrame id={id} title={title} lead={lead} tone={tone} landmarkLabel={landmarkLabel}>
      {((dishes?.length ?? 0) === 0) ? (
        <EmptyState icon="scale" title={empty} />
      ) : ((layout as string) === "table") ? (
        <Box class="w-full overflow-x-auto" data-slot="compare-table">
          <Table class="w-full text-sm">
            <TableCaption class="sr-only">
              {labels.caption}
            </TableCaption>
            <TableHead>
              <TableRow>
                <TableHeadCell scope="col" class="py-2">
                  {labels.cut}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-2">
                  {labels.weight}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-2">
                  {labels.minutes}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-2">
                  {labels.heat}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-2">
                  {labels.marinade}
                </TableHeadCell>
                <TableHeadCell scope="col" class="py-2">
                  {labels.price}
                </TableHeadCell>
              </TableRow>
            </TableHead>
            <TableBody>
              <For each={dishes ?? []}>{(d) => (
                <TableRow data-slot="item">
                  <TableHeadCell scope="row" class="py-2 font-semibold">
                    {d.name}
                  </TableHeadCell>
                  <TableCell>
                    {d.weight}
                  </TableCell>
                  <TableCell>
                    {tpl(labels.minutes, (d.minutes == null ? undefined : String(d.minutes)))}
                  </TableCell>
                  <TableCell>
                    {d.tag}
                  </TableCell>
                  <TableCell>
                    <For each={d.items ?? []}>{(x) => (
                      <>
                        {x}
                      </>
                    )}</For>
                  </TableCell>
                  <TableCell class="font-semibold">
                    {fmtMoney(d.price, d.currency)}
                  </TableCell>
                </TableRow>
              )}</For>
            </TableBody>
          </Table>
        </Box>
      ) : (
        <CutCards dishes={dishes} labels={labels} />
      )}
    </SectionFrame>
  );
}

Solid registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.templ
// 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/dish-compare.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// DishCompareProps are the props of DishCompare; the values are the JSON shapes of the TypeScript props.
type DishCompareProps 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"`
	Layout any `json:"layout"`
	Tone any `json:"tone"`
	LandmarkLabel any `json:"landmarkLabel"`
}

// Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes: layout (table, cards), tone.
templ DishCompare(p DishCompareProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vLead := uiutils.Def(p.Lead, "") }}
	{{ vDishes := p.Dishes }}
	{{ vEmpty := uiutils.Def(p.Empty, "") }}
	{{ vLabels := p.Labels }}
	{{ vLayout := uiutils.Def(p.Layout, "table") }}
	{{ 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: "scale", Title: vEmpty})
		} else if uiutils.Eq(vLayout, "table") {
			@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "w-full overflow-x-auto", Attrs: uiutils.Attrs("data-slot", "compare-table")}}) {
				@compose.Table(compose.TableProps{BoxProps: box.BoxProps{Class: "w-full text-sm"}}) {
					@compose.TableCaption(compose.TableCaptionProps{BoxProps: box.BoxProps{Class: "sr-only"}}) {
						{ uiutils.Text(uiutils.Get(vLabels, "caption")) }
					}
					@compose.TableHead(compose.TableHeadProps{BoxProps: box.BoxProps{}}) {
						@compose.TableRow(compose.TableRowProps{BoxProps: box.BoxProps{}}) {
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "cut")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "weight")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "minutes")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "heat")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "marinade")) }
							}
							@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2", Attrs: uiutils.Attrs("scope", "col")}}) {
								{ uiutils.Text(uiutils.Get(vLabels, "price")) }
							}
						}
					}
					@compose.TableBody(compose.TableBodyProps{BoxProps: box.BoxProps{}}) {
						for _, vD := range uiutils.L(vDishes) {
							@compose.TableRow(compose.TableRowProps{BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "item")}}) {
								@compose.TableHeadCell(compose.TableHeadCellProps{BoxProps: box.BoxProps{Class: "py-2 font-semibold", Attrs: uiutils.Attrs("scope", "row")}}) {
									{ uiutils.Text(uiutils.Get(vD, "name")) }
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{}}) {
									{ uiutils.Text(uiutils.Get(vD, "weight")) }
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{}}) {
									{ uiutils.Text(uiutils.Tpl(uiutils.Get(vLabels, "minutes"), uiutils.Str(uiutils.Get(vD, "minutes")))) }
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{}}) {
									{ uiutils.Text(uiutils.Get(vD, "tag")) }
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{}}) {
									for _, vX := range uiutils.L(uiutils.Get(vD, "items")) {
										{ uiutils.Text(vX) }
									}
								}
								@compose.TableCell(compose.TableCellProps{BoxProps: box.BoxProps{Class: "font-semibold"}}) {
									{ uiutils.Text(uiutils.Money(uiutils.Get(vD, "price"), uiutils.Get(vD, "currency"))) }
								}
							}
						}
					}
				}
			}
		} else {
			@CutCards(CutCardsProps{Dishes: vDishes, Labels: vLabels})
		}
	}
}

templ registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.html.twig
{#- 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/dish-compare.json
    Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes: layout (table, cards), tone.
    Props (p): id, title, lead, dishes, empty, labels, 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_layout = (p.layout ?? 'table') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_20 -%}
  {%- if og_t(og_eq(og_len(v_dishes), 0)) %}
    {{ include('blocks/empty-state.html.twig', {'p': {'icon': 'scale', 'title': v_empty}}, with_context = false) }}
  {%- elseif og_t(og_eq(v_layout, 'table')) %}
    {%- set c_19 -%}
      {%- set c_18 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_labels, ['caption'])) }}
        {%- endset -%}
        {{ include('compose/TableCaption.html.twig', {'class': 'sr-only', 'children': c_1}, with_context = false) }}
        {%- set c_9 -%}
          {%- set c_8 -%}
            {%- set c_2 -%}
              {{ og_text(og_get(v_labels, ['cut'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2', 'attrs': og_attrs(['scope', 'col']), 'children': c_2}, with_context = false) }}
            {%- set c_3 -%}
              {{ og_text(og_get(v_labels, ['weight'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2', 'attrs': og_attrs(['scope', 'col']), 'children': c_3}, with_context = false) }}
            {%- set c_4 -%}
              {{ og_text(og_get(v_labels, ['minutes'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2', 'attrs': og_attrs(['scope', 'col']), 'children': c_4}, with_context = false) }}
            {%- set c_5 -%}
              {{ og_text(og_get(v_labels, ['heat'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2', 'attrs': og_attrs(['scope', 'col']), 'children': c_5}, with_context = false) }}
            {%- set c_6 -%}
              {{ og_text(og_get(v_labels, ['marinade'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2', 'attrs': og_attrs(['scope', 'col']), 'children': c_6}, with_context = false) }}
            {%- set c_7 -%}
              {{ og_text(og_get(v_labels, ['price'])) }}
            {%- endset -%}
            {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2', 'attrs': og_attrs(['scope', 'col']), 'children': c_7}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/TableRow.html.twig', {'children': c_8}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/TableHead.html.twig', {'children': c_9}, with_context = false) }}
        {%- set c_17 -%}
          {%- for v_d in og_l(v_dishes) %}
            {%- set c_16 -%}
              {%- set c_10 -%}
                {{ og_text(og_get(v_d, ['name'])) }}
              {%- endset -%}
              {{ include('compose/TableHeadCell.html.twig', {'class': 'py-2 font-semibold', 'attrs': og_attrs(['scope', 'row']), 'children': c_10}, with_context = false) }}
              {%- set c_11 -%}
                {{ og_text(og_get(v_d, ['weight'])) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'children': c_11}, with_context = false) }}
              {%- set c_12 -%}
                {{ og_text(og_tpl(og_get(v_labels, ['minutes']), [og_str(og_get(v_d, ['minutes']))])) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'children': c_12}, with_context = false) }}
              {%- set c_13 -%}
                {{ og_text(og_get(v_d, ['tag'])) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'children': c_13}, with_context = false) }}
              {%- set c_14 -%}
                {%- for v_x in og_l(og_get(v_d, ['items'])) %}
                  {{ og_text(v_x) }}
                {%- endfor %}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'children': c_14}, with_context = false) }}
              {%- set c_15 -%}
                {{ og_text(og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))) }}
              {%- endset -%}
              {{ include('compose/TableCell.html.twig', {'class': 'font-semibold', 'children': c_15}, with_context = false) }}
            {%- endset -%}
            {{ include('compose/TableRow.html.twig', {'attrs': og_attrs(['data-slot', 'item']), 'children': c_16}, with_context = false) }}
          {%- endfor %}
        {%- endset -%}
        {{ include('compose/TableBody.html.twig', {'children': c_17}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Table.html.twig', {'class': 'w-full text-sm', 'children': c_18}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Box.html.twig', {'class': 'w-full overflow-x-auto', 'attrs': og_attrs(['data-slot', 'compare-table']), 'children': c_19}, with_context = false) }}
  {%- else %}
    {{ include('blocks/cut-cards.html.twig', {'p': {'dishes': v_dishes, 'labels': v_labels}}, 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_20)}, with_context = false) }}

Twig registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.latte
{* 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/dish-compare.json
    Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes: layout (table, cards), tone.
    Props (p): id, title, lead, dishes, empty, labels, 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_layout = ($p['layout'] ?? 'table')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_20}
  {if og_t(og_eq(og_len($v_dishes), 0))}
    {=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'scale', 'title' => $v_empty]])|noescape}
  {elseif og_t(og_eq($v_layout, 'table'))}
    {capture $c_19}
      {capture $c_18}
        {capture $c_1}
          {=og_text(og_get($v_labels, ['caption']))}
        {/capture}
        {=og_include('compose/TableCaption.latte', ['class' => 'sr-only', 'children' => (string) $c_1])|noescape}
        {capture $c_9}
          {capture $c_8}
            {capture $c_2}
              {=og_text(og_get($v_labels, ['cut']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_2])|noescape}
            {capture $c_3}
              {=og_text(og_get($v_labels, ['weight']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_3])|noescape}
            {capture $c_4}
              {=og_text(og_get($v_labels, ['minutes']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_4])|noescape}
            {capture $c_5}
              {=og_text(og_get($v_labels, ['heat']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_5])|noescape}
            {capture $c_6}
              {=og_text(og_get($v_labels, ['marinade']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_6])|noescape}
            {capture $c_7}
              {=og_text(og_get($v_labels, ['price']))}
            {/capture}
            {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2', 'attrs' => og_attrs(['scope', 'col']), 'children' => (string) $c_7])|noescape}
          {/capture}
          {=og_include('compose/TableRow.latte', ['children' => (string) $c_8])|noescape}
        {/capture}
        {=og_include('compose/TableHead.latte', ['children' => (string) $c_9])|noescape}
        {capture $c_17}
          {foreach og_l($v_dishes) as $v_d}
            {capture $c_16}
              {capture $c_10}
                {=og_text(og_get($v_d, ['name']))}
              {/capture}
              {=og_include('compose/TableHeadCell.latte', ['class' => 'py-2 font-semibold', 'attrs' => og_attrs(['scope', 'row']), 'children' => (string) $c_10])|noescape}
              {capture $c_11}
                {=og_text(og_get($v_d, ['weight']))}
              {/capture}
              {=og_include('compose/TableCell.latte', ['children' => (string) $c_11])|noescape}
              {capture $c_12}
                {=og_text(og_tpl(og_get($v_labels, ['minutes']), [og_str(og_get($v_d, ['minutes']))]))}
              {/capture}
              {=og_include('compose/TableCell.latte', ['children' => (string) $c_12])|noescape}
              {capture $c_13}
                {=og_text(og_get($v_d, ['tag']))}
              {/capture}
              {=og_include('compose/TableCell.latte', ['children' => (string) $c_13])|noescape}
              {capture $c_14}
                {foreach og_l(og_get($v_d, ['items'])) as $v_x}
                  {=og_text($v_x)}
                {/foreach}
              {/capture}
              {=og_include('compose/TableCell.latte', ['children' => (string) $c_14])|noescape}
              {capture $c_15}
                {=og_text(og_money(og_get($v_d, ['price']), og_get($v_d, ['currency'])))}
              {/capture}
              {=og_include('compose/TableCell.latte', ['class' => 'font-semibold', 'children' => (string) $c_15])|noescape}
            {/capture}
            {=og_include('compose/TableRow.latte', ['attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_16])|noescape}
          {/foreach}
        {/capture}
        {=og_include('compose/TableBody.latte', ['children' => (string) $c_17])|noescape}
      {/capture}
      {=og_include('compose/Table.latte', ['class' => 'w-full text-sm', 'children' => (string) $c_18])|noescape}
    {/capture}
    {=og_include('compose/Box.latte', ['class' => 'w-full overflow-x-auto', 'attrs' => og_attrs(['data-slot', 'compare-table']), 'children' => (string) $c_19])|noescape}
  {else}
    {=og_include('blocks/cut-cards.latte', ['p' => ['dishes' => $v_dishes, 'labels' => $v_labels]])|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_20)])|noescape}

Latte registry item (JSON)

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-cdn
npx ui8kit add dish-compare
blocks/dish-compare.html.j2
{#- 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/dish-compare.json
    Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes: layout (table, cards), tone.
    Props (p): id, title, lead, dishes, empty, labels, 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_layout = og_def(p['layout'], 'table') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_20 -%}
  {%- if og_t(og_eq(og_len(v_dishes), 0)) %}
    {{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'scale', 'title': v_empty}}) }}
  {%- elif og_t(og_eq(v_layout, 'table')) %}
    {%- set c_19 -%}
      {%- set c_18 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_labels, ['caption'])) }}
        {%- endset -%}
        {{ og_include('compose/table-caption.html.j2', {'p': {'Class': 'sr-only'}, 'children': c_1}) }}
        {%- set c_9 -%}
          {%- set c_8 -%}
            {%- set c_2 -%}
              {{ og_text(og_get(v_labels, ['cut'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_2}) }}
            {%- set c_3 -%}
              {{ og_text(og_get(v_labels, ['weight'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_3}) }}
            {%- set c_4 -%}
              {{ og_text(og_get(v_labels, ['minutes'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_4}) }}
            {%- set c_5 -%}
              {{ og_text(og_get(v_labels, ['heat'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_5}) }}
            {%- set c_6 -%}
              {{ og_text(og_get(v_labels, ['marinade'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_6}) }}
            {%- set c_7 -%}
              {{ og_text(og_get(v_labels, ['price'])) }}
            {%- endset -%}
            {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2', 'Attrs': og_attrs(['scope', 'col'])}, 'children': c_7}) }}
          {%- endset -%}
          {{ og_include('compose/table-row.html.j2', {'p': {}, 'children': c_8}) }}
        {%- endset -%}
        {{ og_include('compose/table-head.html.j2', {'p': {}, 'children': c_9}) }}
        {%- set c_17 -%}
          {%- for v_d in og_l(v_dishes) %}
            {%- set c_16 -%}
              {%- set c_10 -%}
                {{ og_text(og_get(v_d, ['name'])) }}
              {%- endset -%}
              {{ og_include('compose/table-head-cell.html.j2', {'p': {'Class': 'py-2 font-semibold', 'Attrs': og_attrs(['scope', 'row'])}, 'children': c_10}) }}
              {%- set c_11 -%}
                {{ og_text(og_get(v_d, ['weight'])) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {}, 'children': c_11}) }}
              {%- set c_12 -%}
                {{ og_text(og_tpl(og_get(v_labels, ['minutes']), [og_str(og_get(v_d, ['minutes']))])) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {}, 'children': c_12}) }}
              {%- set c_13 -%}
                {{ og_text(og_get(v_d, ['tag'])) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {}, 'children': c_13}) }}
              {%- set c_14 -%}
                {%- for v_x in og_l(og_get(v_d, ['items'])) %}
                  {{ og_text(v_x) }}
                {%- endfor %}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {}, 'children': c_14}) }}
              {%- set c_15 -%}
                {{ og_text(og_money(og_get(v_d, ['price']), og_get(v_d, ['currency']))) }}
              {%- endset -%}
              {{ og_include('compose/table-cell.html.j2', {'p': {'Class': 'font-semibold'}, 'children': c_15}) }}
            {%- endset -%}
            {{ og_include('compose/table-row.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_16}) }}
          {%- endfor %}
        {%- endset -%}
        {{ og_include('compose/table-body.html.j2', {'p': {}, 'children': c_17}) }}
      {%- endset -%}
      {{ og_include('compose/table.html.j2', {'p': {'Class': 'w-full text-sm'}, 'children': c_18}) }}
    {%- endset -%}
    {{ og_include('compose/box.html.j2', {'p': {'Class': 'w-full overflow-x-auto', 'Attrs': og_attrs(['data-slot', 'compare-table'])}, 'children': c_19}) }}
  {%- else %}
    {{ og_include('blocks/cut-cards.html.j2', {'p': {'dishes': v_dishes, 'labels': v_labels}}) }}
  {%- 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_20)}) }}

Jinja2 registry item (JSON)

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.

Grill cuts side by side: an accessible table (caption, column and row headers) of the cut, weight, cooking time, heat, marinade and price, or one compare card per cut with the same facts as a description list. Axes: layout (table, cards), tone.

Props of DishCompare
PropTypeDefault 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-
layout "table" | "cards""table"
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