Cart Drawer
The cart drawer in its open state, filled or empty.
Install
npx ui8kit add cart-drawerPulls in: block, box, button, cart-list, compose, container, drawer-lines, empty-state, group, kit-box, kit-button, kit-text, lucide-icon, order-summary, title, utils
Preview
Cart
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 cart-drawer<!-- 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 cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity
field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way
back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { DrawerLabels } from "./cart-drawer.types";
import type { CartLine, CartLabels } from "./cart-list.types";
import type { SummaryRow } from "./order-summary.types";
export type CartDrawerProps = {
id: string;
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
state?: "filled" | "empty";
media?: "image" | "none";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Block from "../compose/Block.svelte";
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import Container from "../compose/Container.svelte";
import Group from "../compose/Group.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Title from "../compose/Title.svelte";
import DrawerLines from "../components/drawer-lines.svelte";
import EmptyState from "../components/empty-state.svelte";
import { tpl } from "../utils";
let {
id,
lines,
rows,
labels,
drawer,
state = "filled",
media = "image",
landmarkLabel,
}: CartDrawerProps = $props();
</script>
<Block tag="section" class="py-8" aria-label={(landmarkLabel ?? drawer.title)} data-slot="section">
<Container class="mx-auto w-full max-w-6xl px-4" data-slot="container">
<Box class="flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border">
<Box class="hidden flex-1 flex-col gap-4 p-8 sm:flex" aria-hidden="true">
<Box class="h-8 w-48 rounded bg-background" />
<Box class="h-40 rounded bg-background" />
<Box class="h-40 rounded bg-background" />
</Box>
<Box
class="flex w-full flex-col bg-background shadow-lg sm:max-w-sm"
role="group"
aria-label={drawer.title}
data-slot="drawer"
>
<Group gap="4" align="center" justify="between" class="border-b border-border p-4">
<Title as={2} size="lg" weight="semibold">
{drawer.title}
</Title>
<Button variant="ghost" size="sm" layout="icon" aria-label={drawer.close}>
<LucideIcon name="x" size={16} />
</Button>
</Group>
{#if (((state as string) === "empty") || ((lines?.length ?? 0) === 0))}
<Box class="flex flex-1 flex-col justify-center p-4" data-slot="empty">
<EmptyState icon="shopping-bag" title={drawer.empty} text={drawer.emptyText}>
{#snippet action()}
<Button variant="outline" size="default">
{drawer.browse}
</Button>
{/snippet}
</EmptyState>
</Box>
{:else}
<DrawerLines field={tpl("{0}-qty", id)} lines={lines} rows={rows} labels={labels} drawer={drawer} media={media} />
{/if}
</Box>
</Box>
</Container>
</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 DrawerLabels = {
title: string;
close: string;
progress: string;
empty: string;
emptyText: string;
browse: 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-drawer// 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 cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity
* field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way
* back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
*/
import { type ReactNode } from "react";
import { Block, Box, Button, Container, Group, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { DrawerLines } from "../components/drawer-lines";
import { EmptyState } from "../components/empty-state";
import { tpl } from "../utils";
import type { DrawerLabels } from "./cart-drawer.types";
import type { CartLine, CartLabels } from "./cart-list.types";
import type { SummaryRow } from "./order-summary.types";
export type CartDrawerProps = {
id: string;
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
state?: "filled" | "empty";
media?: "image" | "none";
landmarkLabel?: string;
};
export function CartDrawer({
id,
lines,
rows,
labels,
drawer,
state = "filled",
media = "image",
landmarkLabel,
}: CartDrawerProps) {
return (
<Block tag="section" className="py-8" aria-label={(landmarkLabel ?? drawer.title)} data-slot="section">
<Container className="mx-auto w-full max-w-6xl px-4" data-slot="container">
<Box className="flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border">
<Box className="hidden flex-1 flex-col gap-4 p-8 sm:flex" aria-hidden="true">
<Box className="h-8 w-48 rounded bg-background" />
<Box className="h-40 rounded bg-background" />
<Box className="h-40 rounded bg-background" />
</Box>
<Box
className="flex w-full flex-col bg-background shadow-lg sm:max-w-sm"
role="group"
aria-label={drawer.title}
data-slot="drawer"
>
<Group gap="4" align="center" justify="between" className="border-b border-border p-4">
<Title as={2} size="lg" weight="semibold">
{drawer.title}
</Title>
<Button variant="ghost" size="sm" layout="icon" aria-label={drawer.close}>
<LucideIcon name="x" size={16} />
</Button>
</Group>
{(((state as string) === "empty") || ((lines?.length ?? 0) === 0)) ? (
<Box className="flex flex-1 flex-col justify-center p-4" data-slot="empty">
<EmptyState
icon="shopping-bag"
title={drawer.empty}
text={drawer.emptyText}
action={(
<Button variant="outline" size="default">
{drawer.browse}
</Button>
)}
/>
</Box>
) : (
<DrawerLines field={tpl("{0}-qty", id)} lines={lines} rows={rows} labels={labels} drawer={drawer} media={media} />
)}
</Box>
</Box>
</Container>
</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 DrawerLabels = {
title: string;
close: string;
progress: string;
empty: string;
emptyText: string;
browse: 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-drawer// 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 DrawerLabels = {
title: string;
close: string;
progress: string;
empty: string;
emptyText: string;
browse: 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 cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity
field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way
back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
-->
<script lang="ts">
import type { DrawerLabels } from "./cart-drawer.types";
import type { CartLine, CartLabels } from "./cart-list.types";
import type { SummaryRow } from "./order-summary.types";
export type CartDrawerProps = {
id: string;
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
state?: "filled" | "empty";
media?: "image" | "none";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Block from "../compose/Block.vue";
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Container from "../compose/Container.vue";
import Group from "../compose/Group.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Title from "../compose/Title.vue";
import DrawerLines from "../components/drawer-lines.vue";
import EmptyState from "../components/empty-state.vue";
import { tpl } from "../utils";
const {
id,
lines,
rows,
labels,
drawer,
state = "filled",
media = "image",
landmarkLabel,
} = defineProps<CartDrawerProps>();
</script>
<template>
<Block tag="section" class="py-8" :aria-label="(landmarkLabel ?? drawer.title)" data-slot="section">
<Container class="mx-auto w-full max-w-6xl px-4" data-slot="container">
<Box class="flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border">
<Box class="hidden flex-1 flex-col gap-4 p-8 sm:flex" aria-hidden="true">
<Box class="h-8 w-48 rounded bg-background" />
<Box class="h-40 rounded bg-background" />
<Box class="h-40 rounded bg-background" />
</Box>
<Box
class="flex w-full flex-col bg-background shadow-lg sm:max-w-sm"
role="group"
:aria-label="drawer.title"
data-slot="drawer"
>
<Group gap="4" align="center" justify="between" class="border-b border-border p-4">
<Title :as="2" size="lg" weight="semibold">
{{ drawer.title }}
</Title>
<Button variant="ghost" size="sm" layout="icon" :aria-label="drawer.close">
<LucideIcon name="x" :size="16" />
</Button>
</Group>
<Box
v-if="(((state as string) === 'empty') || ((lines?.length ?? 0) === 0))"
class="flex flex-1 flex-col justify-center p-4"
data-slot="empty"
>
<EmptyState icon="shopping-bag" :title="drawer.empty" :text="drawer.emptyText">
<template #action>
<Button variant="outline" size="default">
{{ drawer.browse }}
</Button>
</template>
</EmptyState>
</Box>
<DrawerLines v-else
:field="tpl('{0}-qty', id)"
:lines="lines"
:rows="rows"
:labels="labels"
:drawer="drawer"
:media="media"
/>
</Box>
</Box>
</Container>
</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 cart-drawer// 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 cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity
* field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way
* back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
*/
import { type JSX } from "solid-js";
import { Block, Box, Button, Container, Group, Title } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { DrawerLines } from "../components/drawer-lines";
import { EmptyState } from "../components/empty-state";
import { tpl } from "../utils";
import type { DrawerLabels } from "./cart-drawer.types";
import type { CartLine, CartLabels } from "./cart-list.types";
import type { SummaryRow } from "./order-summary.types";
export type CartDrawerProps = {
id: string;
lines: CartLine[];
rows: SummaryRow[];
labels: CartLabels;
drawer: DrawerLabels;
state?: "filled" | "empty";
media?: "image" | "none";
landmarkLabel?: string;
};
export function CartDrawer({
id,
lines,
rows,
labels,
drawer,
state = "filled",
media = "image",
landmarkLabel,
}: CartDrawerProps) {
return (
<Block tag="section" class="py-8" aria-label={(landmarkLabel ?? drawer.title)} data-slot="section">
<Container class="mx-auto w-full max-w-6xl px-4" data-slot="container">
<Box class="flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border">
<Box class="hidden flex-1 flex-col gap-4 p-8 sm:flex" aria-hidden="true">
<Box class="h-8 w-48 rounded bg-background" />
<Box class="h-40 rounded bg-background" />
<Box class="h-40 rounded bg-background" />
</Box>
<Box
class="flex w-full flex-col bg-background shadow-lg sm:max-w-sm"
role="group"
aria-label={drawer.title}
data-slot="drawer"
>
<Group gap="4" align="center" justify="between" class="border-b border-border p-4">
<Title as={2} size="lg" weight="semibold">
{drawer.title}
</Title>
<Button variant="ghost" size="sm" layout="icon" aria-label={drawer.close}>
<LucideIcon name="x" size={16} />
</Button>
</Group>
{(((state as string) === "empty") || ((lines?.length ?? 0) === 0)) ? (
<Box class="flex flex-1 flex-col justify-center p-4" data-slot="empty">
<EmptyState
icon="shopping-bag"
title={drawer.empty}
text={drawer.emptyText}
action={(
<Button variant="outline" size="default">
{drawer.browse}
</Button>
)}
/>
</Box>
) : (
<DrawerLines field={tpl("{0}-qty", id)} lines={lines} rows={rows} labels={labels} drawer={drawer} media={media} />
)}
</Box>
</Box>
</Container>
</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 DrawerLabels = {
title: string;
close: string;
progress: string;
empty: string;
emptyText: string;
browse: 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-drawer// 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-drawer.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"
)
// CartDrawerProps are the props of CartDrawer; the values are the JSON shapes of the TypeScript props.
type CartDrawerProps struct {
Id any `json:"id"`
Lines any `json:"lines"`
Rows any `json:"rows"`
Labels any `json:"labels"`
Drawer any `json:"drawer"`
State any `json:"state"`
Media any `json:"media"`
LandmarkLabel any `json:"landmarkLabel"`
}
// The cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
templ CartDrawer(p CartDrawerProps) {
{{ vId := p.Id }}
{{ vLines := p.Lines }}
{{ vRows := p.Rows }}
{{ vLabels := p.Labels }}
{{ vDrawer := p.Drawer }}
{{ vState := uiutils.Def(p.State, "filled") }}
{{ vMedia := uiutils.Def(p.Media, "image") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "section", Class: "py-8", Attrs: uiutils.Attrs("aria-label", uiutils.Coalesce(vLandmarkLabel, uiutils.Get(vDrawer, "title")), "data-slot", "section")}}) {
@compose.Container(compose.ContainerProps{BoxProps: box.BoxProps{Class: "mx-auto w-full max-w-6xl px-4", Attrs: uiutils.Attrs("data-slot", "container")}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border"}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "hidden flex-1 flex-col gap-4 p-8 sm:flex", Attrs: uiutils.Attrs("aria-hidden", "true")}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "h-8 w-48 rounded bg-background"}})
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "h-40 rounded bg-background"}})
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "h-40 rounded bg-background"}})
}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex w-full flex-col bg-background shadow-lg sm:max-w-sm", Attrs: uiutils.Attrs("role", "group", "aria-label", uiutils.Get(vDrawer, "title"), "data-slot", "drawer")}}) {
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "between", BoxProps: box.BoxProps{Class: "border-b border-border p-4"}}) {
@compose.Title(compose.TitleProps{As: "2", Size: "lg", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vDrawer, "title")) }
}
@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{AriaLabel: uiutils.S(uiutils.Get(vDrawer, "close"))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "x", Size: 16})
}
}
if uiutils.T(uiutils.Or(uiutils.Eq(vState, "empty"), uiutils.Eq(uiutils.Len(vLines), float64(0)))) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex flex-1 flex-col justify-center p-4", Attrs: uiutils.Attrs("data-slot", "empty")}}) {
@EmptyState(EmptyStateProps{Icon: "shopping-bag", Title: uiutils.Get(vDrawer, "empty"), Text: uiutils.Get(vDrawer, "emptyText"), Action: cartDrawerFill1(p, vDrawer)})
}
} else {
@DrawerLines(DrawerLinesProps{Field: uiutils.Tpl("{0}-qty", vId), Lines: vLines, Rows: vRows, Labels: vLabels, Drawer: vDrawer, Media: vMedia})
}
}
}
}
}
}
templ cartDrawerFill1(p CartDrawerProps, vDrawer any) {
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "default", ButtonProps: button.ButtonProps{}}) {
{ uiutils.Text(uiutils.Get(vDrawer, "browse")) }
}
}
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-drawer{#- 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-drawer.json
The cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
Props (p): id, lines, rows, labels, drawer, state, media, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- 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_state = (p.state ?? 'filled') -%}
{%- set v_media = (p.media ?? 'image') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_11 -%}
{%- set c_10 -%}
{%- set c_9 -%}
{%- set c_1 -%}
{{ include('compose/Box.html.twig', {'class': 'h-8 w-48 rounded bg-background'}, with_context = false) }}
{{ include('compose/Box.html.twig', {'class': 'h-40 rounded bg-background'}, with_context = false) }}
{{ include('compose/Box.html.twig', {'class': 'h-40 rounded bg-background'}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'hidden flex-1 flex-col gap-4 p-8 sm:flex', 'attrs': og_attrs(['aria-hidden', 'true']), 'children': c_1}, with_context = false) }}
{%- set c_8 -%}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_drawer, ['title'])) }}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 2, 'size': 'lg', 'weight': 'semibold', 'children': c_2}, with_context = false) }}
{%- set c_3 -%}
{{ 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_drawer, ['close'])), 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'between', 'class': 'border-b border-border p-4', 'children': c_4}, with_context = false) }}
{%- if og_t(og_or([og_eq(v_state, 'empty'), og_eq(og_len(v_lines), 0)])) %}
{%- set c_7 -%}
{%- set f_5 -%}
{%- set c_6 -%}
{{ og_text(og_get(v_drawer, ['browse'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'default', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'shopping-bag', 'title': og_get(v_drawer, ['empty']), 'text': og_get(v_drawer, ['emptyText']), 'action': og_markup(f_5)}}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex flex-1 flex-col justify-center p-4', 'attrs': og_attrs(['data-slot', 'empty']), 'children': c_7}, with_context = false) }}
{%- else %}
{{ include('blocks/drawer-lines.html.twig', {'p': {'field': og_tpl('{0}-qty', [v_id]), 'lines': v_lines, 'rows': v_rows, 'labels': v_labels, 'drawer': v_drawer, 'media': v_media}}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex w-full flex-col bg-background shadow-lg sm:max-w-sm', 'attrs': og_attrs(['role', 'group', 'aria-label', og_get(v_drawer, ['title']), 'data-slot', 'drawer']), 'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border', 'children': c_9}, with_context = false) }}
{%- endset -%}
{{ include('compose/Container.html.twig', {'class': 'mx-auto w-full max-w-6xl px-4', 'attrs': og_attrs(['data-slot', 'container']), 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'section', 'class': 'py-8', 'attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, og_get(v_drawer, ['title'])]), 'data-slot', 'section']), 'children': c_11}, 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-drawer{* 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-drawer.json
The cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
Props (p): id, lines, rows, labels, drawer, state, media, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{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_state = ($p['state'] ?? 'filled')}
{var $v_media = ($p['media'] ?? 'image')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_11}
{capture $c_10}
{capture $c_9}
{capture $c_1}
{=og_include('compose/Box.latte', ['class' => 'h-8 w-48 rounded bg-background'])|noescape}
{=og_include('compose/Box.latte', ['class' => 'h-40 rounded bg-background'])|noescape}
{=og_include('compose/Box.latte', ['class' => 'h-40 rounded bg-background'])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'hidden flex-1 flex-col gap-4 p-8 sm:flex', 'attrs' => og_attrs(['aria-hidden', 'true']), 'children' => (string) $c_1])|noescape}
{capture $c_8}
{capture $c_4}
{capture $c_2}
{=og_text(og_get($v_drawer, ['title']))}
{/capture}
{=og_include('compose/Title.latte', ['as' => 2, 'size' => 'lg', 'weight' => 'semibold', 'children' => (string) $c_2])|noescape}
{capture $c_3}
{=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_drawer, ['close'])), 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'between', 'class' => 'border-b border-border p-4', 'children' => (string) $c_4])|noescape}
{if og_t(og_or([og_eq($v_state, 'empty'), og_eq(og_len($v_lines), 0)]))}
{capture $c_7}
{capture $f_5}
{capture $c_6}
{=og_text(og_get($v_drawer, ['browse']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'default', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'shopping-bag', 'title' => og_get($v_drawer, ['empty']), 'text' => og_get($v_drawer, ['emptyText']), 'action' => og_markup($f_5)]])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex flex-1 flex-col justify-center p-4', 'attrs' => og_attrs(['data-slot', 'empty']), 'children' => (string) $c_7])|noescape}
{else}
{=og_include('blocks/drawer-lines.latte', ['p' => ['field' => og_tpl('{0}-qty', [$v_id]), 'lines' => $v_lines, 'rows' => $v_rows, 'labels' => $v_labels, 'drawer' => $v_drawer, 'media' => $v_media]])|noescape}
{/if}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex w-full flex-col bg-background shadow-lg sm:max-w-sm', 'attrs' => og_attrs(['role', 'group', 'aria-label', og_get($v_drawer, ['title']), 'data-slot', 'drawer']), 'children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border', 'children' => (string) $c_9])|noescape}
{/capture}
{=og_include('compose/Container.latte', ['class' => 'mx-auto w-full max-w-6xl px-4', 'attrs' => og_attrs(['data-slot', 'container']), 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'section', 'class' => 'py-8', 'attrs' => og_attrs(['aria-label', og_coalesce([$v_landmarkLabel, og_get($v_drawer, ['title'])]), 'data-slot', 'section']), 'children' => (string) $c_11])|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-drawer{#- 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-drawer.json
The cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
Props (p): id, lines, rows, labels, drawer, state, media, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- 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_state = og_def(p['state'], 'filled') -%}
{%- set v_media = og_def(p['media'], 'image') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_11 -%}
{%- set c_10 -%}
{%- set c_9 -%}
{%- set c_1 -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'h-8 w-48 rounded bg-background'}}) }}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'h-40 rounded bg-background'}}) }}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'h-40 rounded bg-background'}}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'hidden flex-1 flex-col gap-4 p-8 sm:flex', 'Attrs': og_attrs(['aria-hidden', 'true'])}, 'children': c_1}) }}
{%- set c_8 -%}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_drawer, ['title'])) }}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 2, 'Size': 'lg', 'Weight': 'semibold'}, 'children': c_2}) }}
{%- set c_3 -%}
{{ 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_drawer, ['close']))}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'between', 'Class': 'border-b border-border p-4'}, 'children': c_4}) }}
{%- if og_t(og_or([og_eq(v_state, 'empty'), og_eq(og_len(v_lines), 0)])) %}
{%- set c_7 -%}
{%- set f_5 -%}
{%- set c_6 -%}
{{ og_text(og_get(v_drawer, ['browse'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'default'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'shopping-bag', 'title': og_get(v_drawer, ['empty']), 'text': og_get(v_drawer, ['emptyText']), 'action': og_markup(f_5)}}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex flex-1 flex-col justify-center p-4', 'Attrs': og_attrs(['data-slot', 'empty'])}, 'children': c_7}) }}
{%- else %}
{{ og_include('blocks/drawer-lines.html.j2', {'p': {'field': og_tpl('{0}-qty', [v_id]), 'lines': v_lines, 'rows': v_rows, 'labels': v_labels, 'drawer': v_drawer, 'media': v_media}}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex w-full flex-col bg-background shadow-lg sm:max-w-sm', 'Attrs': og_attrs(['role', 'group', 'aria-label', og_get(v_drawer, ['title']), 'data-slot', 'drawer'])}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex min-h-160 overflow-hidden rounded bg-muted inset-ring inset-ring-border'}, 'children': c_9}) }}
{%- endset -%}
{{ og_include('compose/container.html.j2', {'p': {'Class': 'mx-auto w-full max-w-6xl px-4', 'Attrs': og_attrs(['data-slot', 'container'])}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'section', 'Class': 'py-8', 'Attrs': og_attrs(['aria-label', og_coalesce([v_landmarkLabel, og_get(v_drawer, ['title'])]), 'data-slot', 'section'])}, 'children': c_11}) }}
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 cart drawer in its open state, over a faded page: the head with a close button, the lines with a quantity field, the free-delivery bar, the totals and the button. The empty state shows an icon, a line and the way back. Static markup: opening and closing are the page's. Axes: state (filled, empty), media (image, none).
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| lines (required) | CartLine[] | - | |
| rows (required) | SummaryRow[] | - | |
| labels (required) | CartLabels | - | |
| drawer (required) | DrawerLabels | - | labels of the drawer |
| state | "filled" | "empty" | "filled" | |
| media | "image" | "none" | "image" | |
| 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 |