Order Summary
Subtotal, shipping, tax and the total.
Install
npx ui8kit add order-summaryPulls in: box, button, compose, empty-state, inline, kit-box, kit-button, kit-text, list, list-item, section-frame, stack, text, utils
Preview
Order summary
- Subtotal$288
- Shipping$12
- Tax$24
- Total$324
Taxes are calculated at checkout.
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 order-summary<!-- 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 totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout
(card, plain), cta (show, hide), note (show, hide), density, tone.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { SummaryRow, SummaryLabels } from "./order-summary.types";
export type OrderSummaryProps = {
id: string;
title: string;
rows: SummaryRow[];
empty?: string;
labels: SummaryLabels;
layout?: "card" | "plain";
cta?: "show" | "hide";
note?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import Inline from "../compose/Inline.svelte";
import List from "../compose/List.svelte";
import ListItem from "../compose/ListItem.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import EmptyState from "../components/empty-state.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { cn, fmtMoney } from "../utils";
let {
id,
title,
rows,
empty = "",
labels,
layout = "card",
cta = "show",
note = "show",
tone = "default",
density = "default",
landmarkLabel,
}: OrderSummaryProps = $props();
</script>
<SectionFrame id={id} title={title} tone={tone} density={density} measure="md" landmarkLabel={landmarkLabel}>
{#if ((rows?.length ?? 0) === 0)}
<EmptyState icon="receipt" title={empty} />
{:else}
<Box
class={cn(
(((layout as string) === "card") ? "rounded bg-card p-6 inset-ring inset-ring-border" : "")
)}
data-slot="summary"
>
<Stack gap="4" align="stretch">
<List tag="ul" class="flex flex-col gap-4">
{#each rows as row (row.id)}
<ListItem
class={cn(
"flex items-center justify-between gap-4",
(
row.strong ? "border-t border-border pt-4 text-base font-bold"
: "text-sm text-muted-foreground"
)
)}
data-slot="item"
>
<Inline>
{row.label}
</Inline>
<Inline>
{fmtMoney(row.amount, row.currency)}
</Inline>
</ListItem>
{/each}
</List>
{#if ((cta as string) === "show")}
<Button variant="default" size="default" class="w-full">
{labels.checkout}
</Button>
{/if}
{#if ((note as string) === "show")}
<Text size="xs" class="text-muted-foreground">
{labels.note}
</Text>
{/if}
</Stack>
</Box>
{/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 SummaryRow = {
id: string;
label: string;
amount: number;
currency: string;
strong: boolean;
};
export type SummaryLabels = {
checkout: string;
note: 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 order-summary// 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 totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout
* (card, plain), cta (show, hide), note (show, hide), density, tone.
*/
import { type ReactNode } from "react";
import { Box, Button, Inline, List, ListItem, Stack, Text } from "../compose";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { cn, fmtMoney } from "../utils";
import type { SummaryRow, SummaryLabels } from "./order-summary.types";
export type OrderSummaryProps = {
id: string;
title: string;
rows: SummaryRow[];
empty?: string;
labels: SummaryLabels;
layout?: "card" | "plain";
cta?: "show" | "hide";
note?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
export function OrderSummary({
id,
title,
rows,
empty = "",
labels,
layout = "card",
cta = "show",
note = "show",
tone = "default",
density = "default",
landmarkLabel,
}: OrderSummaryProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} measure="md" landmarkLabel={landmarkLabel}>
{((rows?.length ?? 0) === 0) ? (
<EmptyState icon="receipt" title={empty} />
) : (
<Box
className={cn(
(((layout as string) === "card") ? "rounded bg-card p-6 inset-ring inset-ring-border" : "")
)}
data-slot="summary"
>
<Stack gap="4" align="stretch">
<List tag="ul" className="flex flex-col gap-4">
{(rows ?? []).map((row) => (
<ListItem key={row.id}
className={cn(
"flex items-center justify-between gap-4",
(
row.strong ? "border-t border-border pt-4 text-base font-bold"
: "text-sm text-muted-foreground"
)
)}
data-slot="item"
>
<Inline>
{row.label}
</Inline>
<Inline>
{fmtMoney(row.amount, row.currency)}
</Inline>
</ListItem>
))}
</List>
{((cta as string) === "show") ? (
<Button variant="default" size="default" className="w-full">
{labels.checkout}
</Button>
) : null}
{((note as string) === "show") ? (
<Text size="xs" className="text-muted-foreground">
{labels.note}
</Text>
) : null}
</Stack>
</Box>
)}
</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 SummaryRow = {
id: string;
label: string;
amount: number;
currency: string;
strong: boolean;
};
export type SummaryLabels = {
checkout: string;
note: 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 order-summary// 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 SummaryRow = {
id: string;
label: string;
amount: number;
currency: string;
strong: boolean;
};
export type SummaryLabels = {
checkout: string;
note: 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 totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout
(card, plain), cta (show, hide), note (show, hide), density, tone.
-->
<script lang="ts">
import type { SummaryRow, SummaryLabels } from "./order-summary.types";
export type OrderSummaryProps = {
id: string;
title: string;
rows: SummaryRow[];
empty?: string;
labels: SummaryLabels;
layout?: "card" | "plain";
cta?: "show" | "hide";
note?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Inline from "../compose/Inline.vue";
import List from "../compose/List.vue";
import ListItem from "../compose/ListItem.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import EmptyState from "../components/empty-state.vue";
import SectionFrame from "../components/section-frame.vue";
import { cn, fmtMoney } from "../utils";
const {
id,
title,
rows,
empty = "",
labels,
layout = "card",
cta = "show",
note = "show",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<OrderSummaryProps>();
</script>
<template>
<SectionFrame
:id="id"
:title="title"
:tone="tone"
:density="density"
measure="md"
:landmarkLabel="landmarkLabel"
>
<EmptyState v-if="((rows?.length ?? 0) === 0)" icon="receipt" :title="empty" />
<Box v-else
:class="cn(
(((layout as string) === 'card') ? 'rounded bg-card p-6 inset-ring inset-ring-border' : '')
)"
data-slot="summary"
>
<Stack gap="4" align="stretch">
<List tag="ul" class="flex flex-col gap-4">
<ListItem v-for="row in rows" :key="row.id"
:class="cn(
'flex items-center justify-between gap-4',
(
row.strong ? 'border-t border-border pt-4 text-base font-bold'
: 'text-sm text-muted-foreground'
)
)"
data-slot="item"
>
<Inline>
{{ row.label }}
</Inline>
<Inline>
{{ fmtMoney(row.amount, row.currency) }}
</Inline>
</ListItem>
</List>
<Button v-if="((cta as string) === 'show')" variant="default" size="default" class="w-full">
{{ labels.checkout }}
</Button>
<Text v-if="((note as string) === 'show')" size="xs" class="text-muted-foreground">
{{ labels.note }}
</Text>
</Stack>
</Box>
</SectionFrame>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add order-summary// 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 totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout
* (card, plain), cta (show, hide), note (show, hide), density, tone.
*/
import { For, type JSX } from "solid-js";
import { Box, Button, Inline, List, ListItem, Stack, Text } from "../compose";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { cn, fmtMoney } from "../utils";
import type { SummaryRow, SummaryLabels } from "./order-summary.types";
export type OrderSummaryProps = {
id: string;
title: string;
rows: SummaryRow[];
empty?: string;
labels: SummaryLabels;
layout?: "card" | "plain";
cta?: "show" | "hide";
note?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
export function OrderSummary({
id,
title,
rows,
empty = "",
labels,
layout = "card",
cta = "show",
note = "show",
tone = "default",
density = "default",
landmarkLabel,
}: OrderSummaryProps) {
return (
<SectionFrame id={id} title={title} tone={tone} density={density} measure="md" landmarkLabel={landmarkLabel}>
{((rows?.length ?? 0) === 0) ? (
<EmptyState icon="receipt" title={empty} />
) : (
<Box
class={cn(
(((layout as string) === "card") ? "rounded bg-card p-6 inset-ring inset-ring-border" : "")
)}
data-slot="summary"
>
<Stack gap="4" align="stretch">
<List tag="ul" class="flex flex-col gap-4">
<For each={rows ?? []}>{(row) => (
<ListItem
class={cn(
"flex items-center justify-between gap-4",
(
row.strong ? "border-t border-border pt-4 text-base font-bold"
: "text-sm text-muted-foreground"
)
)}
data-slot="item"
>
<Inline>
{row.label}
</Inline>
<Inline>
{fmtMoney(row.amount, row.currency)}
</Inline>
</ListItem>
)}</For>
</List>
{((cta as string) === "show") ? (
<Button variant="default" size="default" class="w-full">
{labels.checkout}
</Button>
) : null}
{((note as string) === "show") ? (
<Text size="xs" class="text-muted-foreground">
{labels.note}
</Text>
) : null}
</Stack>
</Box>
)}
</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 SummaryRow = {
id: string;
label: string;
amount: number;
currency: string;
strong: boolean;
};
export type SummaryLabels = {
checkout: string;
note: 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 order-summary// 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/order-summary.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/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// OrderSummaryProps are the props of OrderSummary; the values are the JSON shapes of the TypeScript props.
type OrderSummaryProps struct {
Id any `json:"id"`
Title any `json:"title"`
Rows any `json:"rows"`
Empty any `json:"empty"`
Labels any `json:"labels"`
Layout any `json:"layout"`
Cta any `json:"cta"`
Note any `json:"note"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// The totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout (card, plain), cta (show, hide), note (show, hide), density, tone.
templ OrderSummary(p OrderSummaryProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vRows := p.Rows }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vLayout := uiutils.Def(p.Layout, "card") }}
{{ vCta := uiutils.Def(p.Cta, "show") }}
{{ vNote := uiutils.Def(p.Note, "show") }}
{{ 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, Measure: "md", LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Len(vRows), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "receipt", Title: vEmpty})
} else {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "card")), "rounded bg-card p-6 inset-ring inset-ring-border", ""))), Attrs: uiutils.Attrs("data-slot", "summary")}}) {
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{}}) {
@compose.List(compose.ListProps{BoxProps: box.BoxProps{Tag: "ul", Class: "flex flex-col gap-4"}}) {
for _, vRow := range uiutils.L(vRows) {
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex items-center justify-between gap-4", uiutils.Cond(uiutils.T(uiutils.Get(vRow, "strong")), "border-t border-border pt-4 text-base font-bold", "text-sm text-muted-foreground"))), Attrs: uiutils.Attrs("data-slot", "item")}}) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vRow, "label")) }
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vRow, "amount"), uiutils.Get(vRow, "currency"))) }
}
}
}
}
if uiutils.Eq(vCta, "show") {
@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Class: "w-full"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "checkout")) }
}
}
if uiutils.Eq(vNote, "show") {
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "note")) }
}
}
}
}
}
}
}
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 order-summary{#- 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/order-summary.json
The totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout (card, plain), cta (show, hide), note (show, hide), density, tone.
Props (p): id, title, rows, empty, labels, layout, cta, note, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_rows = (p.rows ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_layout = (p.layout ?? 'card') -%}
{%- set v_cta = (p.cta ?? 'show') -%}
{%- set v_note = (p.note ?? 'show') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_9 -%}
{%- if og_t(og_eq(og_len(v_rows), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'receipt', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_8 -%}
{%- set c_7 -%}
{%- set c_4 -%}
{%- for v_row in og_l(v_rows) %}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_row, ['label'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_money(og_get(v_row, ['amount']), og_get(v_row, ['currency']))) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'children': c_2}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'class': og_s(og_cnv(['flex items-center justify-between gap-4', (og_t(og_get(v_row, ['strong'])) ? 'border-t border-border pt-4 text-base font-bold' : 'text-sm text-muted-foreground')])), 'attrs': og_attrs(['data-slot', 'item']), 'children': c_3}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/List.html.twig', {'tag': 'ul', 'class': 'flex flex-col gap-4', 'children': c_4}, with_context = false) }}
{%- if og_t(og_eq(v_cta, 'show')) %}
{%- set c_5 -%}
{{ og_text(og_get(v_labels, ['checkout'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'class': 'w-full', 'children': c_5}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_note, 'show')) %}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['note'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_6}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'children': c_7}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s(og_cnv([(og_t(og_eq(v_layout, 'card')) ? 'rounded bg-card p-6 inset-ring inset-ring-border' : '')])), 'attrs': og_attrs(['data-slot', 'summary']), 'children': c_8}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'measure': 'md', 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_9)}, 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 order-summary{* 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/order-summary.json
The totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout (card, plain), cta (show, hide), note (show, hide), density, tone.
Props (p): id, title, rows, empty, labels, layout, cta, note, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_rows = ($p['rows'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'card')}
{var $v_cta = ($p['cta'] ?? 'show')}
{var $v_note = ($p['note'] ?? 'show')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_9}
{if og_t(og_eq(og_len($v_rows), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'receipt', 'title' => $v_empty]])|noescape}
{else}
{capture $c_8}
{capture $c_7}
{capture $c_4}
{foreach og_l($v_rows) as $v_row}
{capture $c_3}
{capture $c_1}
{=og_text(og_get($v_row, ['label']))}
{/capture}
{=og_include('compose/Inline.latte', ['children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_money(og_get($v_row, ['amount']), og_get($v_row, ['currency'])))}
{/capture}
{=og_include('compose/Inline.latte', ['children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['class' => og_s(og_cnv(['flex items-center justify-between gap-4', (og_t(og_get($v_row, ['strong'])) ? 'border-t border-border pt-4 text-base font-bold' : 'text-sm text-muted-foreground')])), 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_3])|noescape}
{/foreach}
{/capture}
{=og_include('compose/List.latte', ['tag' => 'ul', 'class' => 'flex flex-col gap-4', 'children' => (string) $c_4])|noescape}
{if og_t(og_eq($v_cta, 'show'))}
{capture $c_5}
{=og_text(og_get($v_labels, ['checkout']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'class' => 'w-full', 'children' => (string) $c_5])|noescape}
{/if}
{if og_t(og_eq($v_note, 'show'))}
{capture $c_6}
{=og_text(og_get($v_labels, ['note']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_6])|noescape}
{/if}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'children' => (string) $c_7])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s(og_cnv([(og_t(og_eq($v_layout, 'card')) ? 'rounded bg-card p-6 inset-ring inset-ring-border' : '')])), 'attrs' => og_attrs(['data-slot', 'summary']), 'children' => (string) $c_8])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'tone' => $v_tone, 'density' => $v_density, 'measure' => 'md', 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_9)])|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 order-summary{#- 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/order-summary.json
The totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout (card, plain), cta (show, hide), note (show, hide), density, tone.
Props (p): id, title, rows, empty, labels, layout, cta, note, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_rows = og_def(p['rows'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_layout = og_def(p['layout'], 'card') -%}
{%- set v_cta = og_def(p['cta'], 'show') -%}
{%- set v_note = og_def(p['note'], 'show') -%}
{%- 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_9 -%}
{%- if og_t(og_eq(og_len(v_rows), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'receipt', 'title': v_empty}}) }}
{%- else %}
{%- set c_8 -%}
{%- set c_7 -%}
{%- set c_4 -%}
{%- for v_row in og_l(v_rows) %}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_row, ['label'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_money(og_get(v_row, ['amount']), og_get(v_row, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_2}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Class': og_s(og_cnv(['flex items-center justify-between gap-4', ('border-t border-border pt-4 text-base font-bold' if og_t(og_get(v_row, ['strong'])) else 'text-sm text-muted-foreground')])), 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_3}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/list.html.j2', {'p': {'Tag': 'ul', 'Class': 'flex flex-col gap-4'}, 'children': c_4}) }}
{%- if og_t(og_eq(v_cta, 'show')) %}
{%- set c_5 -%}
{{ og_text(og_get(v_labels, ['checkout'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Class': 'w-full'}, 'children': c_5}) }}
{%- endif %}
{%- if og_t(og_eq(v_note, 'show')) %}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['note'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_6}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch'}, 'children': c_7}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv([('rounded bg-card p-6 inset-ring inset-ring-border' if og_t(og_eq(v_layout, 'card')) else '')])), 'Attrs': og_attrs(['data-slot', 'summary'])}, 'children': c_8}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'measure': 'md', 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_9)}) }}
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 totals of an order: subtotal, shipping, tax and the total, with a checkout button and a note. Axes: layout (card, plain), cta (show, hide), note (show, hide), density, tone.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| rows (required) | SummaryRow[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| labels (required) | SummaryLabels | - | |
| layout | "card" | "plain" | "card" | |
| cta | "show" | "hide" | "show" | |
| note | "show" | "hide" | "show" | |
| 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 |