Cart List
The lines of a cart as a table or as cards.
Install
npx ui8kit add cart-listPulls in: button, card, card-content, cart-table, compose, empty-state, kit-box, kit-button, kit-text, lucide-icon, media-frame, number-field, section-frame, stack, text, utils
Preview
Your cart
| Product | Quantity | Total | Remove |
|---|---|---|---|
Arc desk lamp Brass | $89 | ||
Field backpack Olive | $129 | ||
Desk mat Charcoal | $70 |
Subtotal $288
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 cart-list<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button.
Axes: layout (table, cards), media (image, none), density, tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { CartLine, CartLabels } from "./cart-list.types";
export type CartListProps = {
id: string;
title: string;
lines: CartLine[];
empty?: string;
labels: CartLabels;
layout?: "table" | "cards";
media?: "image" | "none";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onremove?: (id: string) => void;
};
</script>
<script lang="ts">
import Button from "../compose/Button.svelte";
import Card from "../compose/Card.svelte";
import CardContent from "../compose/CardContent.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import CartTable from "../components/cart-table.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,
lines,
empty = "",
labels,
layout = "table",
media = "image",
tone = "default",
density = "default",
landmarkLabel,
onremove,
}: CartListProps = $props();
</script>
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{#if ((lines?.length ?? 0) === 0)}
<EmptyState icon="shopping-cart" title={empty} />
{:else if ((layout as string) === "table")}
<CartTable
field={tpl("{0}-qty", id)}
lines={lines}
labels={labels}
media={media}
density={density}
onremove={(arg: string) => onremove?.(arg)}
/>
{:else}
<Stack gap="4" align="stretch" data-slot="cart-cards">
{#each lines as line (line.id)}
<Card variant="default">
<CardContent class="flex flex-wrap items-center gap-4">
{#if ((media as string) === "image")}
<MediaFrame alt={line.name} src={line.image} ratio="1/1" class="size-16 shrink-0" />
{/if}
<Stack gap="0" class="min-w-40 flex-1">
<Text size="sm" weight="semibold">
{line.name}
</Text>
<Text size="xs" class="text-muted-foreground">
{line.variant}
</Text>
<Text size="sm">
{fmtMoney(line.price, line.currency)}
</Text>
</Stack>
<NumberField
value={(line.qty == null ? undefined : String(line.qty))}
name={tpl("{0}-qty-{1}", id, line.id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
<Text size="base" weight="bold">
{fmtMoney((line.price * line.qty), line.currency)}
</Text>
<Button variant="ghost" size="sm" layout="icon" aria-label={labels.remove} onclick={() => onremove?.(line.id)}>
<LucideIcon name="x" size={16} />
</Button>
</CardContent>
</Card>
{/each}
</Stack>
{/if}
</SectionFrame>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type CartLine = {
id: string;
name: string;
variant: string;
price: number;
currency: string;
qty: number;
image?: string;
};
export type CartLabels = {
caption: string;
product: string;
price: string;
qty: string;
total: string;
remove: string;
subtotal: string;
checkout: string;
decrease: string;
increase: 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 cart-list// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button.
* Axes: layout (table, cards), media (image, none), density, tone.
*/
import { type ReactNode } from "react";
import { Button, Card, CardContent, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { CartTable } from "../components/cart-table";
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 { CartLine, CartLabels } from "./cart-list.types";
export type CartListProps = {
id: string;
title: string;
lines: CartLine[];
empty?: string;
labels: CartLabels;
layout?: "table" | "cards";
media?: "image" | "none";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onRemove?: (id: string) => void;
};
export function CartList({
id,
title,
lines,
empty = "",
labels,
layout = "table",
media = "image",
tone = "default",
density = "default",
landmarkLabel,
onRemove,
}: CartListProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((lines?.length ?? 0) === 0) ? (
<EmptyState icon="shopping-cart" title={empty} />
) : ((layout as string) === "table") ? (
<CartTable
field={tpl("{0}-qty", id)}
lines={lines}
labels={labels}
media={media}
density={density}
onRemove={(arg: string) => onRemove?.(arg)}
/>
) : (
<Stack gap="4" align="stretch" data-slot="cart-cards">
{(lines ?? []).map((line) => (
<Card key={line.id} variant="default">
<CardContent className="flex flex-wrap items-center gap-4">
{((media as string) === "image") ? (
<MediaFrame alt={line.name} src={line.image} ratio="1/1" className="size-16 shrink-0" />
) : null}
<Stack gap="0" className="min-w-40 flex-1">
<Text size="sm" weight="semibold">
{line.name}
</Text>
<Text size="xs" className="text-muted-foreground">
{line.variant}
</Text>
<Text size="sm">
{fmtMoney(line.price, line.currency)}
</Text>
</Stack>
<NumberField
value={(line.qty == null ? undefined : String(line.qty))}
name={tpl("{0}-qty-{1}", id, line.id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
<Text size="base" weight="bold">
{fmtMoney((line.price * line.qty), line.currency)}
</Text>
<Button variant="ghost" size="sm" layout="icon" aria-label={labels.remove} onClick={() => onRemove?.(line.id)}>
<LucideIcon name="x" size={16} />
</Button>
</CardContent>
</Card>
))}
</Stack>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type CartLine = {
id: string;
name: string;
variant: string;
price: number;
currency: string;
qty: number;
image?: string;
};
export type CartLabels = {
caption: string;
product: string;
price: string;
qty: string;
total: string;
remove: string;
subtotal: string;
checkout: string;
decrease: string;
increase: 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 cart-list// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type CartLine = {
id: string;
name: string;
variant: string;
price: number;
currency: string;
qty: number;
image?: string;
};
export type CartLabels = {
caption: string;
product: string;
price: string;
qty: string;
total: string;
remove: string;
subtotal: string;
checkout: string;
decrease: string;
increase: 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. -->
<!--
The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button.
Axes: layout (table, cards), media (image, none), density, tone.
-->
<script lang="ts">
import type { CartLine, CartLabels } from "./cart-list.types";
export type CartListProps = {
id: string;
title: string;
lines: CartLine[];
empty?: string;
labels: CartLabels;
layout?: "table" | "cards";
media?: "image" | "none";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Button from "../compose/Button.vue";
import Card from "../compose/Card.vue";
import CardContent from "../compose/CardContent.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import CartTable from "../components/cart-table.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,
lines,
empty = "",
labels,
layout = "table",
media = "image",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<CartListProps>();
const emit = defineEmits<{ remove: [id: string] }>();
</script>
<template>
<SectionFrame :id="id" :title="title" :tone="tone" :density="density" :landmarkLabel="landmarkLabel">
<EmptyState v-if="((lines?.length ?? 0) === 0)" icon="shopping-cart" :title="empty" />
<CartTable v-else-if="((layout as string) === 'table')"
:field="tpl('{0}-qty', id)"
:lines="lines"
:labels="labels"
:media="media"
:density="density"
@remove="(arg: string) => emit('remove', arg)"
/>
<Stack v-else gap="4" align="stretch" data-slot="cart-cards">
<Card v-for="line in lines" :key="line.id" variant="default">
<CardContent class="flex flex-wrap items-center gap-4">
<MediaFrame
v-if="((media as string) === 'image')"
:alt="line.name"
:src="line.image"
ratio="1/1"
class="size-16 shrink-0"
/>
<Stack gap="0" class="min-w-40 flex-1">
<Text size="sm" weight="semibold">
{{ line.name }}
</Text>
<Text size="xs" class="text-muted-foreground">
{{ line.variant }}
</Text>
<Text size="sm">
{{ fmtMoney(line.price, line.currency) }}
</Text>
</Stack>
<NumberField
:value="(line.qty == null ? undefined : String(line.qty))"
:name="tpl('{0}-qty-{1}', id, line.id)"
min="1"
:label="labels.qty"
:decrease="labels.decrease"
:increase="labels.increase"
/>
<Text size="base" weight="bold">
{{ fmtMoney((line.price * line.qty), line.currency) }}
</Text>
<Button
variant="ghost"
size="sm"
layout="icon"
:aria-label="labels.remove"
@click="() => emit('remove', line.id)"
>
<LucideIcon name="x" :size="16" />
</Button>
</CardContent>
</Card>
</Stack>
</SectionFrame>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add cart-list// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button.
* Axes: layout (table, cards), media (image, none), density, tone.
*/
import { For, type JSX } from "solid-js";
import { Button, Card, CardContent, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { CartTable } from "../components/cart-table";
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 { CartLine, CartLabels } from "./cart-list.types";
export type CartListProps = {
id: string;
title: string;
lines: CartLine[];
empty?: string;
labels: CartLabels;
layout?: "table" | "cards";
media?: "image" | "none";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
onRemove?: (id: string) => void;
};
export function CartList({
id,
title,
lines,
empty = "",
labels,
layout = "table",
media = "image",
tone = "default",
density = "default",
landmarkLabel,
onRemove,
}: CartListProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((lines?.length ?? 0) === 0) ? (
<EmptyState icon="shopping-cart" title={empty} />
) : ((layout as string) === "table") ? (
<CartTable
field={tpl("{0}-qty", id)}
lines={lines}
labels={labels}
media={media}
density={density}
onRemove={(arg: string) => onRemove?.(arg)}
/>
) : (
<Stack gap="4" align="stretch" data-slot="cart-cards">
<For each={lines ?? []}>{(line) => (
<Card variant="default">
<CardContent class="flex flex-wrap items-center gap-4">
{((media as string) === "image") ? (
<MediaFrame alt={line.name} src={line.image} ratio="1/1" class="size-16 shrink-0" />
) : null}
<Stack gap="0" class="min-w-40 flex-1">
<Text size="sm" weight="semibold">
{line.name}
</Text>
<Text size="xs" class="text-muted-foreground">
{line.variant}
</Text>
<Text size="sm">
{fmtMoney(line.price, line.currency)}
</Text>
</Stack>
<NumberField
value={(line.qty == null ? undefined : String(line.qty))}
name={tpl("{0}-qty-{1}", id, line.id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
<Text size="base" weight="bold">
{fmtMoney((line.price * line.qty), line.currency)}
</Text>
<Button variant="ghost" size="sm" layout="icon" aria-label={labels.remove} onClick={() => onRemove?.(line.id)}>
<LucideIcon name="x" size={16} />
</Button>
</CardContent>
</Card>
)}</For>
</Stack>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type CartLine = {
id: string;
name: string;
variant: string;
price: number;
currency: string;
qty: number;
image?: string;
};
export type CartLabels = {
caption: string;
product: string;
price: string;
qty: string;
total: string;
remove: string;
subtotal: string;
checkout: string;
decrease: string;
increase: 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 cart-list// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/cart-list.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/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// CartListProps are the props of CartList; the values are the JSON shapes of the TypeScript props.
type CartListProps struct {
Id any `json:"id"`
Title any `json:"title"`
Lines any `json:"lines"`
Empty any `json:"empty"`
Labels any `json:"labels"`
Layout any `json:"layout"`
Media any `json:"media"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button. Axes: layout (table, cards), media (image, none), density, tone.
templ CartList(p CartListProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLines := p.Lines }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vLayout := uiutils.Def(p.Layout, "table") }}
{{ vMedia := uiutils.Def(p.Media, "image") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Tone: vTone, Density: vDensity, LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Len(vLines), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "shopping-cart", Title: vEmpty})
} else if uiutils.Eq(vLayout, "table") {
@CartTable(CartTableProps{Field: uiutils.Tpl("{0}-qty", vId), Lines: vLines, Labels: vLabels, Media: vMedia, Density: vDensity})
} else {
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "cart-cards")}}) {
for _, vLine := range uiutils.L(vLines) {
@compose.Card(compose.CardProps{Variant: "default", BoxProps: box.BoxProps{}}) {
@compose.CardContent(compose.CardContentProps{BoxProps: box.BoxProps{Class: "flex flex-wrap items-center gap-4"}}) {
if uiutils.Eq(vMedia, "image") {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vLine, "name"), Src: uiutils.Get(vLine, "image"), Ratio: "1/1", Class: uiutils.Cnv("size-16 shrink-0")})
}
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: "min-w-40 flex-1"}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLine, "name")) }
}
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vLine, "variant")) }
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vLine, "price"), uiutils.Get(vLine, "currency"))) }
}
}
@NumberField(NumberFieldProps{Value: uiutils.Str(uiutils.Get(vLine, "qty")), Name: uiutils.Tpl("{0}-qty-{1}", vId, uiutils.Get(vLine, "id")), Min: "1", Label: uiutils.Get(vLabels, "qty"), Decrease: uiutils.Get(vLabels, "decrease"), Increase: uiutils.Get(vLabels, "increase")})
@compose.Text(compose.TextProps{Size: "base", Weight: "bold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Money(uiutils.Mul(uiutils.Get(vLine, "price"), uiutils.Get(vLine, "qty")), uiutils.Get(vLine, "currency"))) }
}
@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{AriaLabel: uiutils.S(uiutils.Get(vLabels, "remove"))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "x", Size: 16})
}
}
}
}
}
}
}
}
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 cart-list{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/cart-list.json
The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button. Axes: layout (table, cards), media (image, none), density, tone.
Props (p): id, title, lines, empty, labels, layout, media, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_lines = (p.lines ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_layout = (p.layout ?? 'table') -%}
{%- set v_media = (p.media ?? 'image') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_10 -%}
{%- if og_t(og_eq(og_len(v_lines), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'shopping-cart', 'title': v_empty}}, with_context = false) }}
{%- elseif og_t(og_eq(v_layout, 'table')) %}
{{ include('blocks/cart-table.html.twig', {'p': {'field': og_tpl('{0}-qty', [v_id]), 'lines': v_lines, 'labels': v_labels, 'media': v_media, 'density': v_density}}, with_context = false) }}
{%- else %}
{%- set c_9 -%}
{%- for v_line in og_l(v_lines) %}
{%- set c_8 -%}
{%- set c_7 -%}
{%- if og_t(og_eq(v_media, 'image')) %}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_line, ['name']), 'src': og_get(v_line, ['image']), 'ratio': '1/1', 'className': og_cnv(['size-16 shrink-0'])}}, with_context = false) }}
{%- endif %}
{%- set c_4 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_line, ['name'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_get(v_line, ['variant'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
{%- set c_3 -%}
{{ og_text(og_money(og_get(v_line, ['price']), og_get(v_line, ['currency']))) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '0', 'class': 'min-w-40 flex-1', 'children': c_4}, with_context = false) }}
{{ include('blocks/number-field.html.twig', {'p': {'value': og_str(og_get(v_line, ['qty'])), 'name': og_tpl('{0}-qty-{1}', [v_id, og_get(v_line, ['id'])]), 'min': '1', 'label': og_get(v_labels, ['qty']), 'decrease': og_get(v_labels, ['decrease']), 'increase': og_get(v_labels, ['increase'])}}, with_context = false) }}
{%- set c_5 -%}
{{ og_text(og_money(og_mul(og_get(v_line, ['price']), og_get(v_line, ['qty'])), og_get(v_line, ['currency']))) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'base', 'weight': 'bold', 'children': c_5}, with_context = false) }}
{%- set c_6 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'x', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'ghost', 'size': 'sm', 'layout': 'icon', 'ariaLabel': og_s(og_get(v_labels, ['remove'])), 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/CardContent.html.twig', {'class': 'flex flex-wrap items-center gap-4', 'children': c_7}, with_context = false) }}
{%- endset -%}
{{ include('compose/Card.html.twig', {'variant': 'default', 'children': c_8}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'cart-cards']), 'children': c_9}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_10)}, 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 cart-list{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/cart-list.json
The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button. Axes: layout (table, cards), media (image, none), density, tone.
Props (p): id, title, lines, empty, labels, layout, media, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_lines = ($p['lines'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'table')}
{var $v_media = ($p['media'] ?? 'image')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_10}
{if og_t(og_eq(og_len($v_lines), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'shopping-cart', 'title' => $v_empty]])|noescape}
{elseif og_t(og_eq($v_layout, 'table'))}
{=og_include('blocks/cart-table.latte', ['p' => ['field' => og_tpl('{0}-qty', [$v_id]), 'lines' => $v_lines, 'labels' => $v_labels, 'media' => $v_media, 'density' => $v_density]])|noescape}
{else}
{capture $c_9}
{foreach og_l($v_lines) as $v_line}
{capture $c_8}
{capture $c_7}
{if og_t(og_eq($v_media, 'image'))}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_line, ['name']), 'src' => og_get($v_line, ['image']), 'ratio' => '1/1', 'className' => og_cnv(['size-16 shrink-0'])]])|noescape}
{/if}
{capture $c_4}
{capture $c_1}
{=og_text(og_get($v_line, ['name']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_get($v_line, ['variant']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{capture $c_3}
{=og_text(og_money(og_get($v_line, ['price']), og_get($v_line, ['currency'])))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '0', 'class' => 'min-w-40 flex-1', 'children' => (string) $c_4])|noescape}
{=og_include('blocks/number-field.latte', ['p' => ['value' => og_str(og_get($v_line, ['qty'])), 'name' => og_tpl('{0}-qty-{1}', [$v_id, og_get($v_line, ['id'])]), 'min' => '1', 'label' => og_get($v_labels, ['qty']), 'decrease' => og_get($v_labels, ['decrease']), 'increase' => og_get($v_labels, ['increase'])]])|noescape}
{capture $c_5}
{=og_text(og_money(og_mul(og_get($v_line, ['price']), og_get($v_line, ['qty'])), og_get($v_line, ['currency'])))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'base', 'weight' => 'bold', 'children' => (string) $c_5])|noescape}
{capture $c_6}
{=og_include('icons/LucideIcon.latte', ['name' => 'x', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'ghost', 'size' => 'sm', 'layout' => 'icon', 'ariaLabel' => og_s(og_get($v_labels, ['remove'])), 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/CardContent.latte', ['class' => 'flex flex-wrap items-center gap-4', 'children' => (string) $c_7])|noescape}
{/capture}
{=og_include('compose/Card.latte', ['variant' => 'default', 'children' => (string) $c_8])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'cart-cards']), 'children' => (string) $c_9])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'tone' => $v_tone, 'density' => $v_density, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_10)])|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 cart-list{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/cart-list.json
The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button. Axes: layout (table, cards), media (image, none), density, tone.
Props (p): id, title, lines, empty, labels, layout, media, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_lines = og_def(p['lines'], 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_media = og_def(p['media'], 'image') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_10 -%}
{%- if og_t(og_eq(og_len(v_lines), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'shopping-cart', 'title': v_empty}}) }}
{%- elif og_t(og_eq(v_layout, 'table')) %}
{{ og_include('blocks/cart-table.html.j2', {'p': {'field': og_tpl('{0}-qty', [v_id]), 'lines': v_lines, 'labels': v_labels, 'media': v_media, 'density': v_density}}) }}
{%- else %}
{%- set c_9 -%}
{%- for v_line in og_l(v_lines) %}
{%- set c_8 -%}
{%- set c_7 -%}
{%- if og_t(og_eq(v_media, 'image')) %}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_line, ['name']), 'src': og_get(v_line, ['image']), 'ratio': '1/1', 'className': og_cnv(['size-16 shrink-0'])}}) }}
{%- endif %}
{%- set c_4 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_line, ['name'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_get(v_line, ['variant'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
{%- set c_3 -%}
{{ og_text(og_money(og_get(v_line, ['price']), og_get(v_line, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '0', 'Class': 'min-w-40 flex-1'}, 'children': c_4}) }}
{{ og_include('blocks/number-field.html.j2', {'p': {'value': og_str(og_get(v_line, ['qty'])), 'name': og_tpl('{0}-qty-{1}', [v_id, og_get(v_line, ['id'])]), 'min': '1', 'label': og_get(v_labels, ['qty']), 'decrease': og_get(v_labels, ['decrease']), 'increase': og_get(v_labels, ['increase'])}}) }}
{%- set c_5 -%}
{{ og_text(og_money(og_mul(og_get(v_line, ['price']), og_get(v_line, ['qty'])), og_get(v_line, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'base', 'Weight': 'bold'}, 'children': c_5}) }}
{%- set c_6 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'x', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'ghost', 'Size': 'sm', 'Layout': 'icon', 'AriaLabel': og_s(og_get(v_labels, ['remove']))}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/card-content.html.j2', {'p': {'Class': 'flex flex-wrap items-center gap-4'}, 'children': c_7}) }}
{%- endset -%}
{{ og_include('compose/card.html.j2', {'p': {'Variant': 'default'}, 'children': c_8}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'cart-cards'])}, 'children': c_9}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_10)}) }}
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.
The lines of a cart as a table or as cards: product, variant, price, quantity, line total and a remove button. Axes: layout (table, cards), media (image, none), density, tone.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| lines (required) | CartLine[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| labels (required) | CartLabels | - | |
| layout | "table" | "cards" | "table" | |
| media | "image" | "none" | "image" | |
| tone | "default" | "muted" | "default" | |
| density | "default" | "compact" | "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 |