Drawer Lines
Drawer Lines component
Install
npx ui8kit add drawer-linesPulls in: button, cart-drawer, cart-list, compose, group, inline, kit-box, kit-button, kit-progress, kit-text, list, list-item, media-frame, number-field, order-summary, progress, stack, text, utils
Preview
Arc desk lamp
$89Brass
Field backpack
$129Olive
Desk mat
$70Charcoal
Add $12 more for free express delivery
- Subtotal$288
- Total$324
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 drawer-lines<!-- 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 filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal
and total and the button.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { CartLine, CartLabels } from "../blocks/cart-list.types";
import type { SummaryRow } from "../blocks/order-summary.types";
import type { DrawerLabels } from "../blocks/cart-drawer.types";
export type DrawerLinesProps = {
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
media?: "image" | "none";
field?: string;
};
</script>
<script lang="ts">
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import List from "../compose/List.svelte";
import ListItem from "../compose/ListItem.svelte";
import Progress from "../compose/Progress.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import MediaFrame from "../components/media-frame.svelte";
import NumberField from "../components/number-field.svelte";
import { fmtMoney, tpl } from "../utils";
let { lines, rows, labels, drawer, media = "image", field = "qty" }: DrawerLinesProps = $props();
</script>
<Stack gap="4" align="stretch" class="flex-1 p-4" data-slot="lines">
{#each lines as line (line.id)}
<Group gap="4" align="start" data-slot="item">
{#if ((media as string) === "image")}
<MediaFrame alt={line.name} src={line.image} ratio="1/1" class="size-16 shrink-0" />
{/if}
<Stack gap="2" align="stretch" class="flex-1">
<Group gap="2" justify="between" align="start">
<Text size="sm" weight="semibold">
{line.name}
</Text>
<Inline class="text-sm font-medium">
{fmtMoney((line.price * line.qty), line.currency)}
</Inline>
</Group>
<Text size="xs" class="text-muted-foreground">
{line.variant}
</Text>
<NumberField
value={(line.qty == null ? undefined : String(line.qty))}
name={tpl("{0}-{1}", field, line.id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
</Stack>
</Group>
{/each}
</Stack>
<Stack gap="4" align="stretch" class="border-t border-border p-4" data-slot="drawer-lines">
<Stack gap="2" align="stretch" class="rounded bg-muted p-4" data-slot="progress">
<Text size="sm">
{drawer.progress}
</Text>
<Progress value="96" max="100" aria-label={drawer.progress} />
</Stack>
<List tag="ul" class="flex flex-col gap-2">
{#each rows as row, i (row.id)}
{#if (row.strong ? true : (i === 0))}
<ListItem
class={
row.strong ? "flex justify-between text-base font-bold"
: "flex justify-between text-sm text-muted-foreground"
}
data-slot="summary-row"
>
<Inline>
{row.label}
</Inline>
<Inline>
{fmtMoney(row.amount, row.currency)}
</Inline>
</ListItem>
{/if}
{/each}
</List>
<Button variant="default" size="lg" class="w-full">
{labels.checkout}
</Button>
</Stack>
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 drawer-lines// 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 filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal
* and total and the button.
*/
import { Fragment, type ReactNode } from "react";
import { Button, Group, Inline, List, ListItem, Progress, Stack, Text } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { NumberField } from "../components/number-field";
import { fmtMoney, tpl } from "../utils";
import type { CartLine, CartLabels } from "../blocks/cart-list.types";
import type { SummaryRow } from "../blocks/order-summary.types";
import type { DrawerLabels } from "../blocks/cart-drawer.types";
export type DrawerLinesProps = {
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
media?: "image" | "none";
field?: string;
};
export function DrawerLines({
lines,
rows,
labels,
drawer,
media = "image",
field = "qty",
}: DrawerLinesProps) {
return (
<>
<Stack gap="4" align="stretch" className="flex-1 p-4" data-slot="lines">
{(lines ?? []).map((line) => (
<Group key={line.id} gap="4" align="start" data-slot="item">
{((media as string) === "image") ? (
<MediaFrame alt={line.name} src={line.image} ratio="1/1" className="size-16 shrink-0" />
) : null}
<Stack gap="2" align="stretch" className="flex-1">
<Group gap="2" justify="between" align="start">
<Text size="sm" weight="semibold">
{line.name}
</Text>
<Inline className="text-sm font-medium">
{fmtMoney((line.price * line.qty), line.currency)}
</Inline>
</Group>
<Text size="xs" className="text-muted-foreground">
{line.variant}
</Text>
<NumberField
value={(line.qty == null ? undefined : String(line.qty))}
name={tpl("{0}-{1}", field, line.id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
</Stack>
</Group>
))}
</Stack>
<Stack gap="4" align="stretch" className="border-t border-border p-4" data-slot="drawer-lines">
<Stack gap="2" align="stretch" className="rounded bg-muted p-4" data-slot="progress">
<Text size="sm">
{drawer.progress}
</Text>
<Progress value="96" max="100" aria-label={drawer.progress} />
</Stack>
<List tag="ul" className="flex flex-col gap-2">
{(rows ?? []).map((row, i) => (
<Fragment key={row.id}>
{(row.strong ? true : (i === 0)) ? (
<ListItem
className={
row.strong ? "flex justify-between text-base font-bold"
: "flex justify-between text-sm text-muted-foreground"
}
data-slot="summary-row"
>
<Inline>
{row.label}
</Inline>
<Inline>
{fmtMoney(row.amount, row.currency)}
</Inline>
</ListItem>
) : null}
</Fragment>
))}
</List>
<Button variant="default" size="lg" className="w-full">
{labels.checkout}
</Button>
</Stack>
</>
);
}
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 drawer-lines<!-- 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 filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal
and total and the button.
-->
<script lang="ts">
import type { CartLine, CartLabels } from "../blocks/cart-list.types";
import type { SummaryRow } from "../blocks/order-summary.types";
import type { DrawerLabels } from "../blocks/cart-drawer.types";
export type DrawerLinesProps = {
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
media?: "image" | "none";
field?: string;
};
</script>
<script setup lang="ts">
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import List from "../compose/List.vue";
import ListItem from "../compose/ListItem.vue";
import Progress from "../compose/Progress.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import MediaFrame from "../components/media-frame.vue";
import NumberField from "../components/number-field.vue";
import { fmtMoney, tpl } from "../utils";
const { lines, rows, labels, drawer, media = "image", field = "qty" } = defineProps<DrawerLinesProps>();
</script>
<template>
<Stack gap="4" align="stretch" class="flex-1 p-4" data-slot="lines">
<Group v-for="line in lines" :key="line.id" gap="4" align="start" data-slot="item">
<MediaFrame
v-if="((media as string) === 'image')"
:alt="line.name"
:src="line.image"
ratio="1/1"
class="size-16 shrink-0"
/>
<Stack gap="2" align="stretch" class="flex-1">
<Group gap="2" justify="between" align="start">
<Text size="sm" weight="semibold">
{{ line.name }}
</Text>
<Inline class="text-sm font-medium">
{{ fmtMoney((line.price * line.qty), line.currency) }}
</Inline>
</Group>
<Text size="xs" class="text-muted-foreground">
{{ line.variant }}
</Text>
<NumberField
:value="(line.qty == null ? undefined : String(line.qty))"
:name="tpl('{0}-{1}', field, line.id)"
min="1"
:label="labels.qty"
:decrease="labels.decrease"
:increase="labels.increase"
/>
</Stack>
</Group>
</Stack>
<Stack gap="4" align="stretch" class="border-t border-border p-4" data-slot="drawer-lines">
<Stack gap="2" align="stretch" class="rounded bg-muted p-4" data-slot="progress">
<Text size="sm">
{{ drawer.progress }}
</Text>
<Progress value="96" max="100" :aria-label="drawer.progress" />
</Stack>
<List tag="ul" class="flex flex-col gap-2">
<template v-for="(row, i) in rows" :key="row.id">
<ListItem v-if="(row.strong ? true : (i === 0))"
:class="
row.strong ? 'flex justify-between text-base font-bold'
: 'flex justify-between text-sm text-muted-foreground'
"
data-slot="summary-row"
>
<Inline>
{{ row.label }}
</Inline>
<Inline>
{{ fmtMoney(row.amount, row.currency) }}
</Inline>
</ListItem>
</template>
</List>
<Button variant="default" size="lg" class="w-full">
{{ labels.checkout }}
</Button>
</Stack>
</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 drawer-lines// 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 filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal
* and total and the button.
*/
import { For, type JSX } from "solid-js";
import { Button, Group, Inline, List, ListItem, Progress, Stack, Text } from "../compose";
import { MediaFrame } from "../components/media-frame";
import { NumberField } from "../components/number-field";
import { fmtMoney, tpl } from "../utils";
import type { CartLine, CartLabels } from "../blocks/cart-list.types";
import type { SummaryRow } from "../blocks/order-summary.types";
import type { DrawerLabels } from "../blocks/cart-drawer.types";
export type DrawerLinesProps = {
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
media?: "image" | "none";
field?: string;
};
export function DrawerLines({
lines,
rows,
labels,
drawer,
media = "image",
field = "qty",
}: DrawerLinesProps) {
return (
<>
<Stack gap="4" align="stretch" class="flex-1 p-4" data-slot="lines">
<For each={lines ?? []}>{(line) => (
<Group gap="4" align="start" data-slot="item">
{((media as string) === "image") ? (
<MediaFrame alt={line.name} src={line.image} ratio="1/1" class="size-16 shrink-0" />
) : null}
<Stack gap="2" align="stretch" class="flex-1">
<Group gap="2" justify="between" align="start">
<Text size="sm" weight="semibold">
{line.name}
</Text>
<Inline class="text-sm font-medium">
{fmtMoney((line.price * line.qty), line.currency)}
</Inline>
</Group>
<Text size="xs" class="text-muted-foreground">
{line.variant}
</Text>
<NumberField
value={(line.qty == null ? undefined : String(line.qty))}
name={tpl("{0}-{1}", field, line.id)}
min="1"
label={labels.qty}
decrease={labels.decrease}
increase={labels.increase}
/>
</Stack>
</Group>
)}</For>
</Stack>
<Stack gap="4" align="stretch" class="border-t border-border p-4" data-slot="drawer-lines">
<Stack gap="2" align="stretch" class="rounded bg-muted p-4" data-slot="progress">
<Text size="sm">
{drawer.progress}
</Text>
<Progress value="96" max="100" aria-label={drawer.progress} />
</Stack>
<List tag="ul" class="flex flex-col gap-2">
<For each={rows ?? []}>{(row, iOf) => { const i = iOf(); return (
<>
{(row.strong ? true : (i === 0)) ? (
<ListItem
class={
row.strong ? "flex justify-between text-base font-bold"
: "flex justify-between text-sm text-muted-foreground"
}
data-slot="summary-row"
>
<Inline>
{row.label}
</Inline>
<Inline>
{fmtMoney(row.amount, row.currency)}
</Inline>
</ListItem>
) : null}
</>
); }}</For>
</List>
<Button variant="default" size="lg" class="w-full">
{labels.checkout}
</Button>
</Stack>
</>
);
}
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 drawer-lines// 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/drawer-lines.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/progress"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// DrawerLinesProps are the props of DrawerLines; the values are the JSON shapes of the TypeScript props.
type DrawerLinesProps struct {
Lines any `json:"lines"`
Rows any `json:"rows"`
Labels any `json:"labels"`
Drawer any `json:"drawer"`
Media any `json:"media"`
Field any `json:"field"`
}
// The filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal and total and the button.
templ DrawerLines(p DrawerLinesProps) {
{{ vLines := p.Lines }}
{{ vRows := p.Rows }}
{{ vLabels := p.Labels }}
{{ vDrawer := p.Drawer }}
{{ vMedia := uiutils.Def(p.Media, "image") }}
{{ vField := uiutils.Def(p.Field, "qty") }}
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Class: "flex-1 p-4", Attrs: uiutils.Attrs("data-slot", "lines")}}) {
for _, vLine := range uiutils.L(vLines) {
@compose.Group(compose.GroupProps{Gap: "4", Align: "start", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "item")}}) {
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: "2", Align: "stretch", BoxProps: box.BoxProps{Class: "flex-1"}}) {
@compose.Group(compose.GroupProps{Gap: "2", Justify: "between", Align: "start", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLine, "name")) }
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-sm font-medium"}}) {
{ uiutils.Text(uiutils.Money(uiutils.Mul(uiutils.Get(vLine, "price"), uiutils.Get(vLine, "qty")), uiutils.Get(vLine, "currency"))) }
}
}
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vLine, "variant")) }
}
@NumberField(NumberFieldProps{Value: uiutils.Str(uiutils.Get(vLine, "qty")), Name: uiutils.Tpl("{0}-{1}", vField, uiutils.Get(vLine, "id")), Min: "1", Label: uiutils.Get(vLabels, "qty"), Decrease: uiutils.Get(vLabels, "decrease"), Increase: uiutils.Get(vLabels, "increase")})
}
}
}
}
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Class: "border-t border-border p-4", Attrs: uiutils.Attrs("data-slot", "drawer-lines")}}) {
@compose.Stack(compose.StackProps{Gap: "2", Align: "stretch", BoxProps: box.BoxProps{Class: "rounded bg-muted p-4", Attrs: uiutils.Attrs("data-slot", "progress")}}) {
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vDrawer, "progress")) }
}
@compose.Progress(compose.ProgressProps{ProgressProps: progress.ProgressProps{Value: uiutils.SP("96"), Max: "100", Attrs: uiutils.Attrs("aria-label", uiutils.Get(vDrawer, "progress"))}})
}
@compose.List(compose.ListProps{BoxProps: box.BoxProps{Tag: "ul", Class: "flex flex-col gap-2"}}) {
for vI, vRow := range uiutils.L(vRows) {
if uiutils.T(uiutils.Cond(uiutils.T(uiutils.Get(vRow, "strong")), true, uiutils.Eq(float64(vI), float64(0)))) {
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Get(vRow, "strong")), "flex justify-between text-base font-bold", "flex justify-between text-sm text-muted-foreground")), Attrs: uiutils.Attrs("data-slot", "summary-row")}}) {
@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"))) }
}
}
}
}
}
@compose.Button(compose.ButtonProps{Variant: "default", Size: "lg", ButtonProps: button.ButtonProps{Class: "w-full"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "checkout")) }
}
}
}
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 drawer-lines{#- 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/drawer-lines.json
The filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal and total and the button.
Props (p): lines, rows, labels, drawer, media, field. -#}
{%- set v_lines = (p.lines ?? null) -%}
{%- set v_rows = (p.rows ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_drawer = (p.drawer ?? null) -%}
{%- set v_media = (p.media ?? 'image') -%}
{%- set v_field = (p.field ?? 'qty') -%}
{%- set c_7 -%}
{%- for v_line in og_l(v_lines) %}
{%- set c_6 -%}
{%- 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_5 -%}
{%- set c_3 -%}
{%- 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_money(og_mul(og_get(v_line, ['price']), og_get(v_line, ['qty'])), og_get(v_line, ['currency']))) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'text-sm font-medium', 'children': c_2}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'justify': 'between', 'align': 'start', 'children': c_3}, with_context = false) }}
{%- set c_4 -%}
{{ og_text(og_get(v_line, ['variant'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', '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}-{1}', [v_field, 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) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'align': 'stretch', 'class': 'flex-1', 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'start', 'attrs': og_attrs(['data-slot', 'item']), 'children': c_6}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'class': 'flex-1 p-4', 'attrs': og_attrs(['data-slot', 'lines']), 'children': c_7}, with_context = false) }}
{%- set c_15 -%}
{%- set c_9 -%}
{%- set c_8 -%}
{{ og_text(og_get(v_drawer, ['progress'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'children': c_8}, with_context = false) }}
{{ include('compose/Progress.html.twig', {'value': '96', 'max': '100', 'attrs': og_attrs(['aria-label', og_get(v_drawer, ['progress'])])}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'align': 'stretch', 'class': 'rounded bg-muted p-4', 'attrs': og_attrs(['data-slot', 'progress']), 'children': c_9}, with_context = false) }}
{%- set c_13 -%}
{%- for v_row in og_l(v_rows) %}
{%- set v_i = loop.index0 -%}
{%- if og_t((og_t(og_get(v_row, ['strong'])) ? true : og_eq(v_i, 0))) %}
{%- set c_12 -%}
{%- set c_10 -%}
{{ og_text(og_get(v_row, ['label'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'children': c_10}, with_context = false) }}
{%- set c_11 -%}
{{ og_text(og_money(og_get(v_row, ['amount']), og_get(v_row, ['currency']))) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'children': c_11}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'class': og_s((og_t(og_get(v_row, ['strong'])) ? 'flex justify-between text-base font-bold' : 'flex justify-between text-sm text-muted-foreground')), 'attrs': og_attrs(['data-slot', 'summary-row']), 'children': c_12}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('compose/List.html.twig', {'tag': 'ul', 'class': 'flex flex-col gap-2', 'children': c_13}, with_context = false) }}
{%- set c_14 -%}
{{ og_text(og_get(v_labels, ['checkout'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'lg', 'class': 'w-full', 'children': c_14}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'class': 'border-t border-border p-4', 'attrs': og_attrs(['data-slot', 'drawer-lines']), 'children': c_15}, 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 drawer-lines{* 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/drawer-lines.json
The filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal and total and the button.
Props (p): lines, rows, labels, drawer, media, field. *}
{var $v_lines = ($p['lines'] ?? null)}
{var $v_rows = ($p['rows'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_drawer = ($p['drawer'] ?? null)}
{var $v_media = ($p['media'] ?? 'image')}
{var $v_field = ($p['field'] ?? 'qty')}
{capture $c_7}
{foreach og_l($v_lines) as $v_line}
{capture $c_6}
{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_5}
{capture $c_3}
{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_money(og_mul(og_get($v_line, ['price']), og_get($v_line, ['qty'])), og_get($v_line, ['currency'])))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'text-sm font-medium', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'justify' => 'between', 'align' => 'start', 'children' => (string) $c_3])|noescape}
{capture $c_4}
{=og_text(og_get($v_line, ['variant']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_4])|noescape}
{=og_include('blocks/number-field.latte', ['p' => ['value' => og_str(og_get($v_line, ['qty'])), 'name' => og_tpl('{0}-{1}', [$v_field, 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}
{=og_include('compose/Stack.latte', ['gap' => '2', 'align' => 'stretch', 'class' => 'flex-1', 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'start', 'attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_6])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'class' => 'flex-1 p-4', 'attrs' => og_attrs(['data-slot', 'lines']), 'children' => (string) $c_7])|noescape}
{capture $c_15}
{capture $c_9}
{capture $c_8}
{=og_text(og_get($v_drawer, ['progress']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'children' => (string) $c_8])|noescape}
{=og_include('compose/Progress.latte', ['value' => '96', 'max' => '100', 'attrs' => og_attrs(['aria-label', og_get($v_drawer, ['progress'])])])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'align' => 'stretch', 'class' => 'rounded bg-muted p-4', 'attrs' => og_attrs(['data-slot', 'progress']), 'children' => (string) $c_9])|noescape}
{capture $c_13}
{foreach og_l($v_rows) as $v_row}
{var $v_i = $iterator->counter0}
{if og_t((og_t(og_get($v_row, ['strong'])) ? true : og_eq($v_i, 0)))}
{capture $c_12}
{capture $c_10}
{=og_text(og_get($v_row, ['label']))}
{/capture}
{=og_include('compose/Inline.latte', ['children' => (string) $c_10])|noescape}
{capture $c_11}
{=og_text(og_money(og_get($v_row, ['amount']), og_get($v_row, ['currency'])))}
{/capture}
{=og_include('compose/Inline.latte', ['children' => (string) $c_11])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['class' => og_s((og_t(og_get($v_row, ['strong'])) ? 'flex justify-between text-base font-bold' : 'flex justify-between text-sm text-muted-foreground')), 'attrs' => og_attrs(['data-slot', 'summary-row']), 'children' => (string) $c_12])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('compose/List.latte', ['tag' => 'ul', 'class' => 'flex flex-col gap-2', 'children' => (string) $c_13])|noescape}
{capture $c_14}
{=og_text(og_get($v_labels, ['checkout']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'lg', 'class' => 'w-full', 'children' => (string) $c_14])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'class' => 'border-t border-border p-4', 'attrs' => og_attrs(['data-slot', 'drawer-lines']), 'children' => (string) $c_15])|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 drawer-lines{#- 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/drawer-lines.json
The filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal and total and the button.
Props (p): lines, rows, labels, drawer, media, field. -#}
{%- set v_lines = og_def(p['lines'], none) -%}
{%- set v_rows = og_def(p['rows'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_drawer = og_def(p['drawer'], none) -%}
{%- set v_media = og_def(p['media'], 'image') -%}
{%- set v_field = og_def(p['field'], 'qty') -%}
{%- set c_7 -%}
{%- for v_line in og_l(v_lines) %}
{%- set c_6 -%}
{%- 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_5 -%}
{%- set c_3 -%}
{%- 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_money(og_mul(og_get(v_line, ['price']), og_get(v_line, ['qty'])), og_get(v_line, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-sm font-medium'}, 'children': c_2}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Justify': 'between', 'Align': 'start'}, 'children': c_3}) }}
{%- set c_4 -%}
{{ og_text(og_get(v_line, ['variant'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_4}) }}
{{ og_include('blocks/number-field.html.j2', {'p': {'value': og_str(og_get(v_line, ['qty'])), 'name': og_tpl('{0}-{1}', [v_field, 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'])}}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': 'stretch', 'Class': 'flex-1'}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'start', 'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_6}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Class': 'flex-1 p-4', 'Attrs': og_attrs(['data-slot', 'lines'])}, 'children': c_7}) }}
{%- set c_15 -%}
{%- set c_9 -%}
{%- set c_8 -%}
{{ og_text(og_get(v_drawer, ['progress'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm'}, 'children': c_8}) }}
{{ og_include('compose/progress.html.j2', {'p': {'Value': '96', 'Max': '100', 'Attrs': og_attrs(['aria-label', og_get(v_drawer, ['progress'])])}}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': 'stretch', 'Class': 'rounded bg-muted p-4', 'Attrs': og_attrs(['data-slot', 'progress'])}, 'children': c_9}) }}
{%- set c_13 -%}
{%- for v_row in og_l(v_rows) %}
{%- set v_i = loop.index0 -%}
{%- if og_t((true if og_t(og_get(v_row, ['strong'])) else og_eq(v_i, 0))) %}
{%- set c_12 -%}
{%- set c_10 -%}
{{ og_text(og_get(v_row, ['label'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_10}) }}
{%- set c_11 -%}
{{ og_text(og_money(og_get(v_row, ['amount']), og_get(v_row, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_11}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Class': og_s(('flex justify-between text-base font-bold' if og_t(og_get(v_row, ['strong'])) else 'flex justify-between text-sm text-muted-foreground')), 'Attrs': og_attrs(['data-slot', 'summary-row'])}, 'children': c_12}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/list.html.j2', {'p': {'Tag': 'ul', 'Class': 'flex flex-col gap-2'}, 'children': c_13}) }}
{%- set c_14 -%}
{{ og_text(og_get(v_labels, ['checkout'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'lg', 'Class': 'w-full'}, 'children': c_14}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Class': 'border-t border-border p-4', 'Attrs': og_attrs(['data-slot', 'drawer-lines'])}, 'children': c_15}) }}
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 filled body of the CartDrawer: the lines with a quantity field, then the free-delivery bar, the subtotal and total and the button.
| Prop | Type | Default | Description |
|---|---|---|---|
| lines (required) | CartLine[] | - | |
| rows (required) | SummaryRow[] | - | |
| labels (required) | CartLabels | - | |
| drawer (required) | DrawerLabels | - | |
| media | "image" | "none" | "image" | |
| field | string | "qty" | prefix of the quantity field names (one name per line: <field>-<line id>) |