Dish Card
A dish as a card: picture, category, portion/weight, price and an order button. No rating.
Install
npx ui8kit add dish-cardPulls in: badge, block, box, button, card-content, compose, dish-showcase, group, kit-box, kit-button, kit-link, kit-text, link, media-frame, text, title, utils
Preview
bowls
Chicken rice bowl
420 g
Grilled chicken, rice, greens and a sesame dressing.
$11.50
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 dish-card<!-- 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 dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button.
No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records
map from Codex kind `dish`.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { DishLabels } from "./dish-card.types";
import type { Dish } from "./dish-showcase.types";
export type DishCardProps = {
dish: Dish;
labels: DishLabels;
layout?: "vertical" | "horizontal";
media?: "image" | "none";
prices?: "show" | "hide";
action?: "button" | "none";
density?: "default" | "compact";
onadd?: (id: string) => void;
};
</script>
<script lang="ts">
import Badge from "../compose/Badge.svelte";
import Block from "../compose/Block.svelte";
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import CardContent from "../compose/CardContent.svelte";
import Group from "../compose/Group.svelte";
import Link from "../compose/Link.svelte";
import Text from "../compose/Text.svelte";
import Title from "../compose/Title.svelte";
import MediaFrame from "../components/media-frame.svelte";
import { cn, fmtMoney, urlOf } from "../utils";
let {
dish,
labels,
layout = "vertical",
media = "image",
prices = "show",
action = "button",
density = "default",
onadd,
}: DishCardProps = $props();
</script>
<Block
tag="article"
class={cn(
"flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded",
"h-full gap-4 overflow-hidden",
(((layout as string) === "horizontal") ? "flex flex-col sm:flex-row" : "flex flex-col")
)}
data-slot="card"
data-layout={layout}
>
{#if ((media as string) === "image")}
<Box class={cn("relative shrink-0", (((layout as string) === "horizontal") ? "sm:w-48" : ""))}>
<MediaFrame alt={dish.name} src={dish.image} ratio="4/3" class="h-full" />
{#if dish.badge}
<Badge variant="default" size="default" class="absolute left-4 top-4">
{dish.badge}
</Badge>
{/if}
</Box>
{/if}
<CardContent class="flex flex-1 flex-col gap-2">
<Group gap="2" align="center" class="flex-wrap">
<Text size="xs" class="uppercase tracking-wide text-muted-foreground" data-slot="category">
{dish.tag}
</Text>
{#if ((media as string) === "none")}
{#if dish.badge}
<Badge variant="secondary" size="sm">
{dish.badge}
</Badge>
{/if}
{/if}
</Group>
<Title as={3} size="base" weight="bold">
{#if dish.href}
<Link href={urlOf(dish.href)} variant="default" data-slot="open">
{dish.name}
</Link>
{:else}
{dish.name}
{/if}
</Title>
{#if dish.weight}
<Text size="xs" class="text-muted-foreground" data-slot="portion">
{dish.weight}
</Text>
{/if}
{#if ((density as string) === "default")}
<Text size="sm" class="text-muted-foreground">
{dish.summary}
</Text>
{/if}
<Group gap="4" justify="between" class="mt-auto pt-2">
{#if ((prices as string) === "show")}
<Text size="xl" weight="bold" data-slot="price">
{fmtMoney(dish.price, dish.currency)}
</Text>
{/if}
{#if ((action as string) === "button")}
<Button variant="default" size="sm" type="button" onclick={() => onadd?.(dish.id)}>
{labels.add}
</Button>
{/if}
</Group>
</CardContent>
</Block>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishLabels = {
add: string;
};
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add dish-card// 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 dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button.
* No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records
* map from Codex kind `dish`.
*/
import { type ReactNode } from "react";
import { Badge, Block, Box, Button, CardContent, Group, Link, Text, Title } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { cn, fmtMoney, urlOf } from "../utils";
import type { DishLabels } from "./dish-card.types";
import type { Dish } from "./dish-showcase.types";
export type DishCardProps = {
dish: Dish;
labels: DishLabels;
layout?: "vertical" | "horizontal";
media?: "image" | "none";
prices?: "show" | "hide";
action?: "button" | "none";
density?: "default" | "compact";
onAdd?: (id: string) => void;
};
export function DishCard({
dish,
labels,
layout = "vertical",
media = "image",
prices = "show",
action = "button",
density = "default",
onAdd,
}: DishCardProps) {
return (
<Block
tag="article"
className={cn(
"flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded",
"h-full gap-4 overflow-hidden",
(((layout as string) === "horizontal") ? "flex flex-col sm:flex-row" : "flex flex-col")
)}
data-slot="card"
data-layout={layout}
>
{((media as string) === "image") ? (
<Box className={cn("relative shrink-0", (((layout as string) === "horizontal") ? "sm:w-48" : ""))}>
<MediaFrame alt={dish.name} src={dish.image} ratio="4/3" className="h-full" />
{dish.badge ? (
<Badge variant="default" size="default" className="absolute left-4 top-4">
{dish.badge}
</Badge>
) : null}
</Box>
) : null}
<CardContent className="flex flex-1 flex-col gap-2">
<Group gap="2" align="center" className="flex-wrap">
<Text size="xs" className="uppercase tracking-wide text-muted-foreground" data-slot="category">
{dish.tag}
</Text>
{((media as string) === "none") ? (
<>
{dish.badge ? (
<Badge variant="secondary" size="sm">
{dish.badge}
</Badge>
) : null}
</>
) : null}
</Group>
<Title as={3} size="base" weight="bold">
{dish.href ? (
<Link href={urlOf(dish.href)} variant="default" data-slot="open">
{dish.name}
</Link>
) : (
<>
{dish.name}
</>
)}
</Title>
{dish.weight ? (
<Text size="xs" className="text-muted-foreground" data-slot="portion">
{dish.weight}
</Text>
) : null}
{((density as string) === "default") ? (
<Text size="sm" className="text-muted-foreground">
{dish.summary}
</Text>
) : null}
<Group gap="4" justify="between" className="mt-auto pt-2">
{((prices as string) === "show") ? (
<Text size="xl" weight="bold" data-slot="price">
{fmtMoney(dish.price, dish.currency)}
</Text>
) : null}
{((action as string) === "button") ? (
<Button variant="default" size="sm" type="button" onClick={() => onAdd?.(dish.id)}>
{labels.add}
</Button>
) : null}
</Group>
</CardContent>
</Block>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishLabels = {
add: string;
};
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add dish-card// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishLabels = {
add: string;
};
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button.
No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records
map from Codex kind `dish`.
-->
<script lang="ts">
import type { DishLabels } from "./dish-card.types";
import type { Dish } from "./dish-showcase.types";
export type DishCardProps = {
dish: Dish;
labels: DishLabels;
layout?: "vertical" | "horizontal";
media?: "image" | "none";
prices?: "show" | "hide";
action?: "button" | "none";
density?: "default" | "compact";
};
</script>
<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Block from "../compose/Block.vue";
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import CardContent from "../compose/CardContent.vue";
import Group from "../compose/Group.vue";
import Link from "../compose/Link.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import MediaFrame from "../components/media-frame.vue";
import { cn, fmtMoney, urlOf } from "../utils";
const {
dish,
labels,
layout = "vertical",
media = "image",
prices = "show",
action = "button",
density = "default",
} = defineProps<DishCardProps>();
const emit = defineEmits<{ add: [id: string] }>();
</script>
<template>
<Block
tag="article"
:class="cn(
'flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded',
'h-full gap-4 overflow-hidden',
(((layout as string) === 'horizontal') ? 'flex flex-col sm:flex-row' : 'flex flex-col')
)"
data-slot="card"
:data-layout="layout"
>
<Box
v-if="((media as string) === 'image')"
:class="cn('relative shrink-0', (((layout as string) === 'horizontal') ? 'sm:w-48' : ''))"
>
<MediaFrame :alt="dish.name" :src="dish.image" ratio="4/3" class="h-full" />
<Badge v-if="dish.badge" variant="default" size="default" class="absolute left-4 top-4">
{{ dish.badge }}
</Badge>
</Box>
<CardContent class="flex flex-1 flex-col gap-2">
<Group gap="2" align="center" class="flex-wrap">
<Text size="xs" class="uppercase tracking-wide text-muted-foreground" data-slot="category">
{{ dish.tag }}
</Text>
<template v-if="((media as string) === 'none')">
<Badge v-if="dish.badge" variant="secondary" size="sm">
{{ dish.badge }}
</Badge>
</template>
</Group>
<Title :as="3" size="base" weight="bold">
<Link v-if="dish.href" :href="urlOf(dish.href)" variant="default" data-slot="open">
{{ dish.name }}
</Link>
<template v-else>
{{ dish.name }}
</template>
</Title>
<Text v-if="dish.weight" size="xs" class="text-muted-foreground" data-slot="portion">
{{ dish.weight }}
</Text>
<Text v-if="((density as string) === 'default')" size="sm" class="text-muted-foreground">
{{ dish.summary }}
</Text>
<Group gap="4" justify="between" class="mt-auto pt-2">
<Text v-if="((prices as string) === 'show')" size="xl" weight="bold" data-slot="price">
{{ fmtMoney(dish.price, dish.currency) }}
</Text>
<Button
v-if="((action as string) === 'button')"
variant="default"
size="sm"
type="button"
@click="() => emit('add', dish.id)"
>
{{ labels.add }}
</Button>
</Group>
</CardContent>
</Block>
</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 dish-card// 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 dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button.
* No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records
* map from Codex kind `dish`.
*/
import { type JSX } from "solid-js";
import { Badge, Block, Box, Button, CardContent, Group, Link, Text, Title } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { cn, fmtMoney, urlOf } from "../utils";
import type { DishLabels } from "./dish-card.types";
import type { Dish } from "./dish-showcase.types";
export type DishCardProps = {
dish: Dish;
labels: DishLabels;
layout?: "vertical" | "horizontal";
media?: "image" | "none";
prices?: "show" | "hide";
action?: "button" | "none";
density?: "default" | "compact";
onAdd?: (id: string) => void;
};
export function DishCard({
dish,
labels,
layout = "vertical",
media = "image",
prices = "show",
action = "button",
density = "default",
onAdd,
}: DishCardProps) {
return (
<Block
tag="article"
class={cn(
"flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded",
"h-full gap-4 overflow-hidden",
(((layout as string) === "horizontal") ? "flex flex-col sm:flex-row" : "flex flex-col")
)}
data-slot="card"
data-layout={layout}
>
{((media as string) === "image") ? (
<Box class={cn("relative shrink-0", (((layout as string) === "horizontal") ? "sm:w-48" : ""))}>
<MediaFrame alt={dish.name} src={dish.image} ratio="4/3" class="h-full" />
{dish.badge ? (
<Badge variant="default" size="default" class="absolute left-4 top-4">
{dish.badge}
</Badge>
) : null}
</Box>
) : null}
<CardContent class="flex flex-1 flex-col gap-2">
<Group gap="2" align="center" class="flex-wrap">
<Text size="xs" class="uppercase tracking-wide text-muted-foreground" data-slot="category">
{dish.tag}
</Text>
{((media as string) === "none") ? (
<>
{dish.badge ? (
<Badge variant="secondary" size="sm">
{dish.badge}
</Badge>
) : null}
</>
) : null}
</Group>
<Title as={3} size="base" weight="bold">
{dish.href ? (
<Link href={urlOf(dish.href)} variant="default" data-slot="open">
{dish.name}
</Link>
) : (
<>
{dish.name}
</>
)}
</Title>
{dish.weight ? (
<Text size="xs" class="text-muted-foreground" data-slot="portion">
{dish.weight}
</Text>
) : null}
{((density as string) === "default") ? (
<Text size="sm" class="text-muted-foreground">
{dish.summary}
</Text>
) : null}
<Group gap="4" justify="between" class="mt-auto pt-2">
{((prices as string) === "show") ? (
<Text size="xl" weight="bold" data-slot="price">
{fmtMoney(dish.price, dish.currency)}
</Text>
) : null}
{((action as string) === "button") ? (
<Button variant="default" size="sm" type="button" onClick={() => onAdd?.(dish.id)}>
{labels.add}
</Button>
) : null}
</Group>
</CardContent>
</Block>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type DishLabels = {
add: string;
};
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add dish-card// 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-card.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/link"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// DishCardProps are the props of DishCard; the values are the JSON shapes of the TypeScript props.
type DishCardProps struct {
Dish any `json:"dish"`
Labels any `json:"labels"`
Layout any `json:"layout"`
Media any `json:"media"`
Prices any `json:"prices"`
Action any `json:"action"`
Density any `json:"density"`
}
// A dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button. No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records map from Codex kind `dish`.
templ DishCard(p DishCardProps) {
{{ vDish := p.Dish }}
{{ vLabels := p.Labels }}
{{ vLayout := uiutils.Def(p.Layout, "vertical") }}
{{ vMedia := uiutils.Def(p.Media, "image") }}
{{ vPrices := uiutils.Def(p.Prices, "show") }}
{{ vAction := uiutils.Def(p.Action, "button") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "article", Class: uiutils.S(uiutils.Cnv("flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded", "h-full gap-4 overflow-hidden", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "horizontal")), "flex flex-col sm:flex-row", "flex flex-col"))), Attrs: uiutils.Attrs("data-slot", "card", "data-layout", vLayout)}}) {
if uiutils.Eq(vMedia, "image") {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("relative shrink-0", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "horizontal")), "sm:w-48", "")))}}) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vDish, "name"), Src: uiutils.Get(vDish, "image"), Ratio: "4/3", Class: uiutils.Cnv("h-full")})
if uiutils.T(uiutils.Get(vDish, "badge")) {
@compose.Badge(compose.BadgeProps{Variant: "default", Size: "default", TextProps: text.TextProps{Class: "absolute left-4 top-4"}}) {
{ uiutils.Text(uiutils.Get(vDish, "badge")) }
}
}
}
}
@compose.CardContent(compose.CardContentProps{BoxProps: box.BoxProps{Class: "flex flex-1 flex-col gap-2"}}) {
@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Class: "flex-wrap"}}) {
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "uppercase tracking-wide text-muted-foreground", Attrs: uiutils.Attrs("data-slot", "category")}}) {
{ uiutils.Text(uiutils.Get(vDish, "tag")) }
}
if uiutils.Eq(vMedia, "none") {
if uiutils.T(uiutils.Get(vDish, "badge")) {
@compose.Badge(compose.BadgeProps{Variant: "secondary", Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vDish, "badge")) }
}
}
}
}
@compose.Title(compose.TitleProps{As: "3", Size: "base", Weight: "bold", TextProps: text.TextProps{}}) {
if uiutils.T(uiutils.Get(vDish, "href")) {
@compose.Link(compose.LinkProps{Variant: "default", LinkProps: link.LinkProps{Href: uiutils.URL(uiutils.Get(vDish, "href"), false), Attrs: uiutils.Attrs("data-slot", "open")}}) {
{ uiutils.Text(uiutils.Get(vDish, "name")) }
}
} else {
{ uiutils.Text(uiutils.Get(vDish, "name")) }
}
}
if uiutils.T(uiutils.Get(vDish, "weight")) {
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground", Attrs: uiutils.Attrs("data-slot", "portion")}}) {
{ uiutils.Text(uiutils.Get(vDish, "weight")) }
}
}
if uiutils.Eq(vDensity, "default") {
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vDish, "summary")) }
}
}
@compose.Group(compose.GroupProps{Gap: "4", Justify: "between", BoxProps: box.BoxProps{Class: "mt-auto pt-2"}}) {
if uiutils.Eq(vPrices, "show") {
@compose.Text(compose.TextProps{Size: "xl", Weight: "bold", TextProps: text.TextProps{Attrs: uiutils.Attrs("data-slot", "price")}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vDish, "price"), uiutils.Get(vDish, "currency"))) }
}
}
if uiutils.Eq(vAction, "button") {
@compose.Button(compose.ButtonProps{Variant: "default", Size: "sm", ButtonProps: button.ButtonProps{Type: "button"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "add")) }
}
}
}
}
}
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdnnpx ui8kit add dish-card{#- 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-card.json
A dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button. No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records map from Codex kind `dish`.
Props (p): dish, labels, layout, media, prices, action, density. -#}
{%- set v_dish = (p.dish ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_layout = (p.layout ?? 'vertical') -%}
{%- set v_media = (p.media ?? 'image') -%}
{%- set v_prices = (p.prices ?? 'show') -%}
{%- set v_action = (p.action ?? 'button') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set c_14 -%}
{%- if og_t(og_eq(v_media, 'image')) %}
{%- set c_2 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_dish, ['name']), 'src': og_get(v_dish, ['image']), 'ratio': '4/3', 'className': og_cnv(['h-full'])}}, with_context = false) }}
{%- if og_t(og_get(v_dish, ['badge'])) %}
{%- set c_1 -%}
{{ og_text(og_get(v_dish, ['badge'])) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'default', 'size': 'default', 'class': 'absolute left-4 top-4', 'children': c_1}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['relative shrink-0', (og_t(og_eq(v_layout, 'horizontal')) ? 'sm:w-48' : '')])), 'children': c_2}, with_context = false) }}
{%- endif %}
{%- set c_13 -%}
{%- set c_5 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_dish, ['tag'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'uppercase tracking-wide text-muted-foreground', 'attrs': og_attrs(['data-slot', 'category']), 'children': c_3}, with_context = false) }}
{%- if og_t(og_eq(v_media, 'none')) %}
{%- if og_t(og_get(v_dish, ['badge'])) %}
{%- set c_4 -%}
{{ og_text(og_get(v_dish, ['badge'])) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'secondary', 'size': 'sm', 'children': c_4}, with_context = false) }}
{%- endif %}
{%- endif %}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'class': 'flex-wrap', 'children': c_5}, with_context = false) }}
{%- set c_7 -%}
{%- if og_t(og_get(v_dish, ['href'])) %}
{%- set c_6 -%}
{{ og_text(og_get(v_dish, ['name'])) }}
{%- endset -%}
{{ include('compose/Link.html.twig', {'href': og_url(og_s(og_get(v_dish, ['href']))), 'variant': 'default', 'attrs': og_attrs(['data-slot', 'open']), 'children': c_6}, with_context = false) }}
{%- else %}
{{ og_text(og_get(v_dish, ['name'])) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 3, 'size': 'base', 'weight': 'bold', 'children': c_7}, with_context = false) }}
{%- if og_t(og_get(v_dish, ['weight'])) %}
{%- set c_8 -%}
{{ og_text(og_get(v_dish, ['weight'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'attrs': og_attrs(['data-slot', 'portion']), 'children': c_8}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_density, 'default')) %}
{%- set c_9 -%}
{{ og_text(og_get(v_dish, ['summary'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_9}, with_context = false) }}
{%- endif %}
{%- set c_12 -%}
{%- if og_t(og_eq(v_prices, 'show')) %}
{%- set c_10 -%}
{{ og_text(og_money(og_get(v_dish, ['price']), og_get(v_dish, ['currency']))) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xl', 'weight': 'bold', 'attrs': og_attrs(['data-slot', 'price']), 'children': c_10}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_action, 'button')) %}
{%- set c_11 -%}
{{ og_text(og_get(v_labels, ['add'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'sm', 'type': 'button', 'children': c_11}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'justify': 'between', 'class': 'mt-auto pt-2', 'children': c_12}, with_context = false) }}
{%- endset -%}
{{ include('compose/CardContent.html.twig', {'class': 'flex flex-1 flex-col gap-2', 'children': c_13}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'article', 'class': og_s(og_cnv(['flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded', 'h-full gap-4 overflow-hidden', (og_t(og_eq(v_layout, 'horizontal')) ? 'flex flex-col sm:flex-row' : 'flex flex-col')])), 'attrs': og_attrs(['data-slot', 'card', 'data-layout', v_layout]), 'children': c_14}, with_context = false) }}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdnnpx ui8kit add dish-card{* 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-card.json
A dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button. No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records map from Codex kind `dish`.
Props (p): dish, labels, layout, media, prices, action, density. *}
{var $v_dish = ($p['dish'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'vertical')}
{var $v_media = ($p['media'] ?? 'image')}
{var $v_prices = ($p['prices'] ?? 'show')}
{var $v_action = ($p['action'] ?? 'button')}
{var $v_density = ($p['density'] ?? 'default')}
{capture $c_14}
{if og_t(og_eq($v_media, 'image'))}
{capture $c_2}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_dish, ['name']), 'src' => og_get($v_dish, ['image']), 'ratio' => '4/3', 'className' => og_cnv(['h-full'])]])|noescape}
{if og_t(og_get($v_dish, ['badge']))}
{capture $c_1}
{=og_text(og_get($v_dish, ['badge']))}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'default', 'size' => 'default', 'class' => 'absolute left-4 top-4', 'children' => (string) $c_1])|noescape}
{/if}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['relative shrink-0', (og_t(og_eq($v_layout, 'horizontal')) ? 'sm:w-48' : '')])), 'children' => (string) $c_2])|noescape}
{/if}
{capture $c_13}
{capture $c_5}
{capture $c_3}
{=og_text(og_get($v_dish, ['tag']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'uppercase tracking-wide text-muted-foreground', 'attrs' => og_attrs(['data-slot', 'category']), 'children' => (string) $c_3])|noescape}
{if og_t(og_eq($v_media, 'none'))}
{if og_t(og_get($v_dish, ['badge']))}
{capture $c_4}
{=og_text(og_get($v_dish, ['badge']))}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'secondary', 'size' => 'sm', 'children' => (string) $c_4])|noescape}
{/if}
{/if}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'class' => 'flex-wrap', 'children' => (string) $c_5])|noescape}
{capture $c_7}
{if og_t(og_get($v_dish, ['href']))}
{capture $c_6}
{=og_text(og_get($v_dish, ['name']))}
{/capture}
{=og_include('compose/Link.latte', ['href' => og_url(og_s(og_get($v_dish, ['href']))), 'variant' => 'default', 'attrs' => og_attrs(['data-slot', 'open']), 'children' => (string) $c_6])|noescape}
{else}
{=og_text(og_get($v_dish, ['name']))}
{/if}
{/capture}
{=og_include('compose/Title.latte', ['as' => 3, 'size' => 'base', 'weight' => 'bold', 'children' => (string) $c_7])|noescape}
{if og_t(og_get($v_dish, ['weight']))}
{capture $c_8}
{=og_text(og_get($v_dish, ['weight']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'attrs' => og_attrs(['data-slot', 'portion']), 'children' => (string) $c_8])|noescape}
{/if}
{if og_t(og_eq($v_density, 'default'))}
{capture $c_9}
{=og_text(og_get($v_dish, ['summary']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_9])|noescape}
{/if}
{capture $c_12}
{if og_t(og_eq($v_prices, 'show'))}
{capture $c_10}
{=og_text(og_money(og_get($v_dish, ['price']), og_get($v_dish, ['currency'])))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xl', 'weight' => 'bold', 'attrs' => og_attrs(['data-slot', 'price']), 'children' => (string) $c_10])|noescape}
{/if}
{if og_t(og_eq($v_action, 'button'))}
{capture $c_11}
{=og_text(og_get($v_labels, ['add']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'sm', 'type' => 'button', 'children' => (string) $c_11])|noescape}
{/if}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'justify' => 'between', 'class' => 'mt-auto pt-2', 'children' => (string) $c_12])|noescape}
{/capture}
{=og_include('compose/CardContent.latte', ['class' => 'flex flex-1 flex-col gap-2', 'children' => (string) $c_13])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'article', 'class' => og_s(og_cnv(['flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded', 'h-full gap-4 overflow-hidden', (og_t(og_eq($v_layout, 'horizontal')) ? 'flex flex-col sm:flex-row' : 'flex flex-col')])), 'attrs' => og_attrs(['data-slot', 'card', 'data-layout', $v_layout]), 'children' => (string) $c_14])|noescape}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdnnpx ui8kit add dish-card{#- 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-card.json
A dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button. No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records map from Codex kind `dish`.
Props (p): dish, labels, layout, media, prices, action, density. -#}
{%- set v_dish = og_def(p['dish'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_layout = og_def(p['layout'], 'vertical') -%}
{%- set v_media = og_def(p['media'], 'image') -%}
{%- set v_prices = og_def(p['prices'], 'show') -%}
{%- set v_action = og_def(p['action'], 'button') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set c_14 -%}
{%- if og_t(og_eq(v_media, 'image')) %}
{%- set c_2 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_dish, ['name']), 'src': og_get(v_dish, ['image']), 'ratio': '4/3', 'className': og_cnv(['h-full'])}}) }}
{%- if og_t(og_get(v_dish, ['badge'])) %}
{%- set c_1 -%}
{{ og_text(og_get(v_dish, ['badge'])) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Class': 'absolute left-4 top-4'}, 'children': c_1}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['relative shrink-0', ('sm:w-48' if og_t(og_eq(v_layout, 'horizontal')) else '')]))}, 'children': c_2}) }}
{%- endif %}
{%- set c_13 -%}
{%- set c_5 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_dish, ['tag'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'uppercase tracking-wide text-muted-foreground', 'Attrs': og_attrs(['data-slot', 'category'])}, 'children': c_3}) }}
{%- if og_t(og_eq(v_media, 'none')) %}
{%- if og_t(og_get(v_dish, ['badge'])) %}
{%- set c_4 -%}
{{ og_text(og_get(v_dish, ['badge'])) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'secondary', 'Size': 'sm'}, 'children': c_4}) }}
{%- endif %}
{%- endif %}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Class': 'flex-wrap'}, 'children': c_5}) }}
{%- set c_7 -%}
{%- if og_t(og_get(v_dish, ['href'])) %}
{%- set c_6 -%}
{{ og_text(og_get(v_dish, ['name'])) }}
{%- endset -%}
{{ og_include('compose/link.html.j2', {'p': {'Href': og_url(og_s(og_get(v_dish, ['href']))), 'Variant': 'default', 'Attrs': og_attrs(['data-slot', 'open'])}, 'children': c_6}) }}
{%- else %}
{{ og_text(og_get(v_dish, ['name'])) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': 'base', 'Weight': 'bold'}, 'children': c_7}) }}
{%- if og_t(og_get(v_dish, ['weight'])) %}
{%- set c_8 -%}
{{ og_text(og_get(v_dish, ['weight'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground', 'Attrs': og_attrs(['data-slot', 'portion'])}, 'children': c_8}) }}
{%- endif %}
{%- if og_t(og_eq(v_density, 'default')) %}
{%- set c_9 -%}
{{ og_text(og_get(v_dish, ['summary'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_9}) }}
{%- endif %}
{%- set c_12 -%}
{%- if og_t(og_eq(v_prices, 'show')) %}
{%- set c_10 -%}
{{ og_text(og_money(og_get(v_dish, ['price']), og_get(v_dish, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xl', 'Weight': 'bold', 'Attrs': og_attrs(['data-slot', 'price'])}, 'children': c_10}) }}
{%- endif %}
{%- if og_t(og_eq(v_action, 'button')) %}
{%- set c_11 -%}
{{ og_text(og_get(v_labels, ['add'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'sm', 'Type': 'button'}, 'children': c_11}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Justify': 'between', 'Class': 'mt-auto pt-2'}, 'children': c_12}) }}
{%- endset -%}
{{ og_include('compose/card-content.html.j2', {'p': {'Class': 'flex flex-1 flex-col gap-2'}, 'children': c_13}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'article', 'Class': og_s(og_cnv(['flex flex-col gap-8 bg-card p-6 text-card-foreground inset-ring inset-ring-border rounded', 'h-full gap-4 overflow-hidden', ('flex flex-col sm:flex-row' if og_t(og_eq(v_layout, 'horizontal')) else 'flex flex-col')])), 'Attrs': og_attrs(['data-slot', 'card', 'data-layout', v_layout])}, 'children': c_14}) }}
Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
A dish as a card: picture, optional badge, category, name, portion/weight, summary, price and an order button. No rating. Axes: layout (vertical, horizontal), media (image, none), density, action (button, none). Records map from Codex kind `dish`.
| Prop | Type | Default | Description |
|---|---|---|---|
| dish (required) | Dish | - | |
| labels (required) | DishLabels | - | |
| layout | "vertical" | "horizontal" | "vertical" | |
| media | "image" | "none" | "image" | |
| prices | "show" | "hide" | "show" | |
| action | "button" | "none" | "button" | |
| density | "default" | "compact" | "default" |