Credit Packs
One-off packs of credits with a price: tiles in two or four columns, or rows.
Install
npx ui8kit add credit-packsPulls in: badge, box, button, card, card-content, compose, empty-state, grid, kit-box, kit-button, kit-text, section-frame, stack, text, title, utils
Preview
Buy credits
100 credits
$9
500 credits
$39
2,000 credits
$129
10,000 credits
$549
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 credit-packs<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile,
row), tone, density.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Pack } from "./credit-packs.types";
export type CreditPacksProps = {
id: string;
title: string;
packs: Pack[];
empty?: string;
badges: Record<string, string>;
buy: string;
cols?: "2" | "4";
item?: "tile" | "row";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Badge from "../compose/Badge.svelte";
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import Card from "../compose/Card.svelte";
import CardContent from "../compose/CardContent.svelte";
import Grid from "../compose/Grid.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import Title from "../compose/Title.svelte";
import EmptyState from "../components/empty-state.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { at, cn, fitCols, fmtMoney } from "../utils";
let {
id,
title,
packs,
empty = "",
badges,
buy,
cols = "4",
item = "tile",
tone = "default",
density = "default",
landmarkLabel,
}: CreditPacksProps = $props();
</script>
<SectionFrame
id={id}
title={title}
tone={tone}
density={density}
measure={(((item as string) === "row") ? "2xl" : "default")}
landmarkLabel={landmarkLabel}
>
{#if ((packs?.length ?? 0) === 0)}
<EmptyState icon="coins" title={empty} />
{:else}
<Grid
cols={
(item as string) === "row" ? "1"
: fitCols((((cols as string) === "2") ? "1-2" : "1-4"), (packs?.length ?? 0))
}
class="gap-4"
data-slot="items"
>
{#each packs as pack (pack.id)}
<Card
variant="default"
class={cn(
"h-full",
(
(item as string) === "row" ? "gap-4 p-4"
: (density as string) === "compact" ? "gap-4 p-4"
: ""
)
)}
data-badge={pack.badge}
>
<CardContent
class={cn(
"flex h-full gap-4",
(((item as string) === "row") ? "flex-row flex-wrap items-center justify-between" : "flex-col")
)}
>
<Stack gap="2" align="start" class={cn("min-w-0", (((item as string) === "row") ? "flex-1" : ""))}>
{#if (pack.badge || (((item as string) !== "row") && (packs.filter((i) => i["badge"]).length > 0)))}
<Box class="flex min-h-6 items-center" data-slot="badge-slot">
{#if pack.badge}
<Badge variant="default" size="default" class="w-fit shrink-0">
{at(badges, pack.badge)}
</Badge>
{/if}
</Box>
{/if}
<Stack gap="0" class="min-w-0">
<Title as={3} size="xl" weight="bold">
{pack.name}
</Title>
<Text size="2xl" weight="bold">
{fmtMoney(pack.price, pack.currency)}
</Text>
</Stack>
</Stack>
<Button
variant={((pack.badge === "popular") ? "default" : "outline")}
size="sm"
type="button"
class={cn("w-fit shrink-0", (((item as string) === "row") ? "" : "mt-auto"))}
>
{buy}
</Button>
</CardContent>
</Card>
{/each}
</Grid>
{/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 Pack = {
id: string;
name: string;
credits: number;
price: number;
currency: string;
badge: 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 credit-packs// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile,
* row), tone, density.
*/
import { type ReactNode } from "react";
import { Badge, Box, Button, Card, CardContent, Grid, Stack, Text, Title } from "../compose";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { at, cn, fitCols, fmtMoney } from "../utils";
import type { Pack } from "./credit-packs.types";
export type CreditPacksProps = {
id: string;
title: string;
packs: Pack[];
empty?: string;
badges: Record<string, string>;
buy: string;
cols?: "2" | "4";
item?: "tile" | "row";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
export function CreditPacks({
id,
title,
packs,
empty = "",
badges,
buy,
cols = "4",
item = "tile",
tone = "default",
density = "default",
landmarkLabel,
}: CreditPacksProps) {
return (
<SectionFrame
id={id}
title={title}
tone={tone}
density={density}
measure={(((item as string) === "row") ? "2xl" : "default")}
landmarkLabel={landmarkLabel}
>
{((packs?.length ?? 0) === 0) ? (
<EmptyState icon="coins" title={empty} />
) : (
<Grid
cols={
(item as string) === "row" ? "1"
: fitCols((((cols as string) === "2") ? "1-2" : "1-4"), (packs?.length ?? 0))
}
className="gap-4"
data-slot="items"
>
{(packs ?? []).map((pack) => (
<Card key={pack.id}
variant="default"
className={cn(
"h-full",
(
(item as string) === "row" ? "gap-4 p-4"
: (density as string) === "compact" ? "gap-4 p-4"
: ""
)
)}
data-badge={pack.badge}
>
<CardContent
className={cn(
"flex h-full gap-4",
(((item as string) === "row") ? "flex-row flex-wrap items-center justify-between" : "flex-col")
)}
>
<Stack gap="2" align="start" className={cn("min-w-0", (((item as string) === "row") ? "flex-1" : ""))}>
{(pack.badge || (((item as string) !== "row") && (packs.filter((i) => i["badge"]).length > 0))) ? (
<Box className="flex min-h-6 items-center" data-slot="badge-slot">
{pack.badge ? (
<Badge variant="default" size="default" className="w-fit shrink-0">
{at(badges, pack.badge)}
</Badge>
) : null}
</Box>
) : null}
<Stack gap="0" className="min-w-0">
<Title as={3} size="xl" weight="bold">
{pack.name}
</Title>
<Text size="2xl" weight="bold">
{fmtMoney(pack.price, pack.currency)}
</Text>
</Stack>
</Stack>
<Button
variant={((pack.badge === "popular") ? "default" : "outline")}
size="sm"
type="button"
className={cn("w-fit shrink-0", (((item as string) === "row") ? "" : "mt-auto"))}
>
{buy}
</Button>
</CardContent>
</Card>
))}
</Grid>
)}
</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 Pack = {
id: string;
name: string;
credits: number;
price: number;
currency: string;
badge: 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 credit-packs// 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 Pack = {
id: string;
name: string;
credits: number;
price: number;
currency: string;
badge: 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. -->
<!--
Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile,
row), tone, density.
-->
<script lang="ts">
import type { Pack } from "./credit-packs.types";
export type CreditPacksProps = {
id: string;
title: string;
packs: Pack[];
empty?: string;
badges: Record<string, string>;
buy: string;
cols?: "2" | "4";
item?: "tile" | "row";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Card from "../compose/Card.vue";
import CardContent from "../compose/CardContent.vue";
import Grid from "../compose/Grid.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import EmptyState from "../components/empty-state.vue";
import SectionFrame from "../components/section-frame.vue";
import { at, cn, fitCols, fmtMoney } from "../utils";
const {
id,
title,
packs,
empty = "",
badges,
buy,
cols = "4",
item = "tile",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<CreditPacksProps>();
</script>
<template>
<SectionFrame
:id="id"
:title="title"
:tone="tone"
:density="density"
:measure="(((item as string) === 'row') ? '2xl' : 'default')"
:landmarkLabel="landmarkLabel"
>
<EmptyState v-if="((packs?.length ?? 0) === 0)" icon="coins" :title="empty" />
<Grid v-else
:cols="
(item as string) === 'row' ? '1'
: fitCols((((cols as string) === '2') ? '1-2' : '1-4'), (packs?.length ?? 0))
"
class="gap-4"
data-slot="items"
>
<Card v-for="pack in packs" :key="pack.id"
variant="default"
:class="cn(
'h-full',
(
(item as string) === 'row' ? 'gap-4 p-4'
: (density as string) === 'compact' ? 'gap-4 p-4'
: ''
)
)"
:data-badge="pack.badge"
>
<CardContent
:class="cn(
'flex h-full gap-4',
(((item as string) === 'row') ? 'flex-row flex-wrap items-center justify-between' : 'flex-col')
)"
>
<Stack gap="2" align="start" :class="cn('min-w-0', (((item as string) === 'row') ? 'flex-1' : ''))">
<Box
v-if="(pack.badge || (((item as string) !== 'row') && (packs.filter((i) => i['badge']).length > 0)))"
class="flex min-h-6 items-center"
data-slot="badge-slot"
>
<Badge v-if="pack.badge" variant="default" size="default" class="w-fit shrink-0">
{{ at(badges, pack.badge) }}
</Badge>
</Box>
<Stack gap="0" class="min-w-0">
<Title :as="3" size="xl" weight="bold">
{{ pack.name }}
</Title>
<Text size="2xl" weight="bold">
{{ fmtMoney(pack.price, pack.currency) }}
</Text>
</Stack>
</Stack>
<Button
:variant="((pack.badge === 'popular') ? 'default' : 'outline')"
size="sm"
type="button"
:class="cn('w-fit shrink-0', (((item as string) === 'row') ? '' : 'mt-auto'))"
>
{{ buy }}
</Button>
</CardContent>
</Card>
</Grid>
</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 credit-packs// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile,
* row), tone, density.
*/
import { For, type JSX } from "solid-js";
import { Badge, Box, Button, Card, CardContent, Grid, Stack, Text, Title } from "../compose";
import { EmptyState } from "../components/empty-state";
import { SectionFrame } from "../components/section-frame";
import { at, cn, fitCols, fmtMoney } from "../utils";
import type { Pack } from "./credit-packs.types";
export type CreditPacksProps = {
id: string;
title: string;
packs: Pack[];
empty?: string;
badges: Record<string, string>;
buy: string;
cols?: "2" | "4";
item?: "tile" | "row";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
export function CreditPacks({
id,
title,
packs,
empty = "",
badges,
buy,
cols = "4",
item = "tile",
tone = "default",
density = "default",
landmarkLabel,
}: CreditPacksProps) {
return (
<SectionFrame
id={id}
title={title}
tone={tone}
density={density}
measure={(((item as string) === "row") ? "2xl" : "default")}
landmarkLabel={landmarkLabel}
>
{((packs?.length ?? 0) === 0) ? (
<EmptyState icon="coins" title={empty} />
) : (
<Grid
cols={
(item as string) === "row" ? "1"
: fitCols((((cols as string) === "2") ? "1-2" : "1-4"), (packs?.length ?? 0))
}
class="gap-4"
data-slot="items"
>
<For each={packs ?? []}>{(pack) => (
<Card
variant="default"
class={cn(
"h-full",
(
(item as string) === "row" ? "gap-4 p-4"
: (density as string) === "compact" ? "gap-4 p-4"
: ""
)
)}
data-badge={pack.badge}
>
<CardContent
class={cn(
"flex h-full gap-4",
(((item as string) === "row") ? "flex-row flex-wrap items-center justify-between" : "flex-col")
)}
>
<Stack gap="2" align="start" class={cn("min-w-0", (((item as string) === "row") ? "flex-1" : ""))}>
{(pack.badge || (((item as string) !== "row") && (packs.filter((i) => i["badge"]).length > 0))) ? (
<Box class="flex min-h-6 items-center" data-slot="badge-slot">
{pack.badge ? (
<Badge variant="default" size="default" class="w-fit shrink-0">
{at(badges, pack.badge)}
</Badge>
) : null}
</Box>
) : null}
<Stack gap="0" class="min-w-0">
<Title as={3} size="xl" weight="bold">
{pack.name}
</Title>
<Text size="2xl" weight="bold">
{fmtMoney(pack.price, pack.currency)}
</Text>
</Stack>
</Stack>
<Button
variant={((pack.badge === "popular") ? "default" : "outline")}
size="sm"
type="button"
class={cn("w-fit shrink-0", (((item as string) === "row") ? "" : "mt-auto"))}
>
{buy}
</Button>
</CardContent>
</Card>
)}</For>
</Grid>
)}
</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 Pack = {
id: string;
name: string;
credits: number;
price: number;
currency: string;
badge: 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 credit-packs// 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/credit-packs.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"
)
// CreditPacksProps are the props of CreditPacks; the values are the JSON shapes of the TypeScript props.
type CreditPacksProps struct {
Id any `json:"id"`
Title any `json:"title"`
Packs any `json:"packs"`
Empty any `json:"empty"`
Badges any `json:"badges"`
Buy any `json:"buy"`
Cols any `json:"cols"`
Item any `json:"item"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile, row), tone, density.
templ CreditPacks(p CreditPacksProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vPacks := p.Packs }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vBadges := p.Badges }}
{{ vBuy := p.Buy }}
{{ vCols := uiutils.Def(p.Cols, "4") }}
{{ vItem := uiutils.Def(p.Item, "tile") }}
{{ 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: uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "row")), "2xl", "default"), LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Len(vPacks), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "coins", Title: vEmpty})
} else {
@compose.Grid(compose.GridProps{Cols: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "row")), "1", uiutils.FitCols(uiutils.Cond(uiutils.T(uiutils.Eq(vCols, "2")), "1-2", "1-4"), uiutils.Len(vPacks)))), BoxProps: box.BoxProps{Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "items")}}) {
for _, vPack := range uiutils.L(vPacks) {
@compose.Card(compose.CardProps{Variant: "default", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("h-full", uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "row")), "gap-4 p-4", uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "gap-4 p-4", "")))), Attrs: uiutils.Attrs("data-badge", uiutils.Get(vPack, "badge"))}}) {
@compose.CardContent(compose.CardContentProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex h-full gap-4", uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "row")), "flex-row flex-wrap items-center justify-between", "flex-col")))}}) {
@compose.Stack(compose.StackProps{Gap: "2", Align: "start", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("min-w-0", uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "row")), "flex-1", "")))}}) {
if uiutils.T(uiutils.Or(uiutils.Get(vPack, "badge"), uiutils.And(!uiutils.Eq(vItem, "row"), uiutils.Gt(uiutils.Count(vPacks, "badge"), float64(0))))) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex min-h-6 items-center", Attrs: uiutils.Attrs("data-slot", "badge-slot")}}) {
if uiutils.T(uiutils.Get(vPack, "badge")) {
@compose.Badge(compose.BadgeProps{Variant: "default", Size: "default", TextProps: text.TextProps{Class: "w-fit shrink-0"}}) {
{ uiutils.Text(uiutils.At(vBadges, uiutils.Get(vPack, "badge"))) }
}
}
}
}
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: "min-w-0"}}) {
@compose.Title(compose.TitleProps{As: "3", Size: "xl", Weight: "bold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vPack, "name")) }
}
@compose.Text(compose.TextProps{Size: "2xl", Weight: "bold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Money(uiutils.Get(vPack, "price"), uiutils.Get(vPack, "currency"))) }
}
}
}
@compose.Button(compose.ButtonProps{Variant: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vPack, "badge"), "popular")), "default", "outline")), Size: "sm", ButtonProps: button.ButtonProps{Type: "button", Class: uiutils.S(uiutils.Cnv("w-fit shrink-0", uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "row")), "", "mt-auto")))}}) {
{ uiutils.Text(vBuy) }
}
}
}
}
}
}
}
}
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 credit-packs{#- 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/credit-packs.json
Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile, row), tone, density.
Props (p): id, title, packs, empty, badges, buy, cols, item, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_packs = (p.packs ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_badges = (p.badges ?? null) -%}
{%- set v_buy = (p.buy ?? null) -%}
{%- set v_cols = (p.cols ?? '4') -%}
{%- set v_item = (p.item ?? 'tile') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_11 -%}
{%- if og_t(og_eq(og_len(v_packs), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'coins', 'title': v_empty}}, with_context = false) }}
{%- else %}
{%- set c_10 -%}
{%- for v_pack in og_l(v_packs) %}
{%- set c_9 -%}
{%- set c_8 -%}
{%- set c_6 -%}
{%- if og_t(og_or([og_get(v_pack, ['badge']), og_and([not (og_eq(v_item, 'row')), og_gt(og_count(v_packs, 'badge'), 0)])])) %}
{%- set c_2 -%}
{%- if og_t(og_get(v_pack, ['badge'])) %}
{%- set c_1 -%}
{{ og_text(og_at(v_badges, og_get(v_pack, ['badge']))) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'default', 'size': 'default', 'class': 'w-fit shrink-0', 'children': c_1}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex min-h-6 items-center', 'attrs': og_attrs(['data-slot', 'badge-slot']), 'children': c_2}, with_context = false) }}
{%- endif %}
{%- set c_5 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_pack, ['name'])) }}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 3, 'size': 'xl', 'weight': 'bold', 'children': c_3}, with_context = false) }}
{%- set c_4 -%}
{{ og_text(og_money(og_get(v_pack, ['price']), og_get(v_pack, ['currency']))) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': '2xl', 'weight': 'bold', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '0', 'class': 'min-w-0', 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'align': 'start', 'class': og_s(og_cnv(['min-w-0', (og_t(og_eq(v_item, 'row')) ? 'flex-1' : '')])), 'children': c_6}, with_context = false) }}
{%- set c_7 -%}
{{ og_text(v_buy) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': og_s((og_t(og_eq(og_get(v_pack, ['badge']), 'popular')) ? 'default' : 'outline')), 'size': 'sm', 'type': 'button', 'class': og_s(og_cnv(['w-fit shrink-0', (og_t(og_eq(v_item, 'row')) ? '' : 'mt-auto')])), 'children': c_7}, with_context = false) }}
{%- endset -%}
{{ include('compose/CardContent.html.twig', {'class': og_s(og_cnv(['flex h-full gap-4', (og_t(og_eq(v_item, 'row')) ? 'flex-row flex-wrap items-center justify-between' : 'flex-col')])), 'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/Card.html.twig', {'variant': 'default', 'class': og_s(og_cnv(['h-full', (og_t(og_eq(v_item, 'row')) ? 'gap-4 p-4' : (og_t(og_eq(v_density, 'compact')) ? 'gap-4 p-4' : ''))])), 'attrs': og_attrs(['data-badge', og_get(v_pack, ['badge'])]), 'children': c_9}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Grid.html.twig', {'cols': og_s((og_t(og_eq(v_item, 'row')) ? '1' : og_fit_cols((og_t(og_eq(v_cols, '2')) ? '1-2' : '1-4'), og_len(v_packs)))), 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_10}, 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': (og_t(og_eq(v_item, 'row')) ? '2xl' : 'default'), 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(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 credit-packs{* 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/credit-packs.json
Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile, row), tone, density.
Props (p): id, title, packs, empty, badges, buy, cols, item, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_packs = ($p['packs'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_badges = ($p['badges'] ?? null)}
{var $v_buy = ($p['buy'] ?? null)}
{var $v_cols = ($p['cols'] ?? '4')}
{var $v_item = ($p['item'] ?? 'tile')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_11}
{if og_t(og_eq(og_len($v_packs), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'coins', 'title' => $v_empty]])|noescape}
{else}
{capture $c_10}
{foreach og_l($v_packs) as $v_pack}
{capture $c_9}
{capture $c_8}
{capture $c_6}
{if og_t(og_or([og_get($v_pack, ['badge']), og_and([!(og_eq($v_item, 'row')), og_gt(og_count($v_packs, 'badge'), 0)])]))}
{capture $c_2}
{if og_t(og_get($v_pack, ['badge']))}
{capture $c_1}
{=og_text(og_at($v_badges, og_get($v_pack, ['badge'])))}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'default', 'size' => 'default', 'class' => 'w-fit shrink-0', 'children' => (string) $c_1])|noescape}
{/if}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex min-h-6 items-center', 'attrs' => og_attrs(['data-slot', 'badge-slot']), 'children' => (string) $c_2])|noescape}
{/if}
{capture $c_5}
{capture $c_3}
{=og_text(og_get($v_pack, ['name']))}
{/capture}
{=og_include('compose/Title.latte', ['as' => 3, 'size' => 'xl', 'weight' => 'bold', 'children' => (string) $c_3])|noescape}
{capture $c_4}
{=og_text(og_money(og_get($v_pack, ['price']), og_get($v_pack, ['currency'])))}
{/capture}
{=og_include('compose/Text.latte', ['size' => '2xl', 'weight' => 'bold', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '0', 'class' => 'min-w-0', 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'align' => 'start', 'class' => og_s(og_cnv(['min-w-0', (og_t(og_eq($v_item, 'row')) ? 'flex-1' : '')])), 'children' => (string) $c_6])|noescape}
{capture $c_7}
{=og_text($v_buy)}
{/capture}
{=og_include('compose/Button.latte', ['variant' => og_s((og_t(og_eq(og_get($v_pack, ['badge']), 'popular')) ? 'default' : 'outline')), 'size' => 'sm', 'type' => 'button', 'class' => og_s(og_cnv(['w-fit shrink-0', (og_t(og_eq($v_item, 'row')) ? '' : 'mt-auto')])), 'children' => (string) $c_7])|noescape}
{/capture}
{=og_include('compose/CardContent.latte', ['class' => og_s(og_cnv(['flex h-full gap-4', (og_t(og_eq($v_item, 'row')) ? 'flex-row flex-wrap items-center justify-between' : 'flex-col')])), 'children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/Card.latte', ['variant' => 'default', 'class' => og_s(og_cnv(['h-full', (og_t(og_eq($v_item, 'row')) ? 'gap-4 p-4' : (og_t(og_eq($v_density, 'compact')) ? 'gap-4 p-4' : ''))])), 'attrs' => og_attrs(['data-badge', og_get($v_pack, ['badge'])]), 'children' => (string) $c_9])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Grid.latte', ['cols' => og_s((og_t(og_eq($v_item, 'row')) ? '1' : og_fit_cols((og_t(og_eq($v_cols, '2')) ? '1-2' : '1-4'), og_len($v_packs)))), 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_10])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'tone' => $v_tone, 'density' => $v_density, 'measure' => (og_t(og_eq($v_item, 'row')) ? '2xl' : 'default'), 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($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 credit-packs{#- 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/credit-packs.json
Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile, row), tone, density.
Props (p): id, title, packs, empty, badges, buy, cols, item, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_packs = og_def(p['packs'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_badges = og_def(p['badges'], none) -%}
{%- set v_buy = og_def(p['buy'], none) -%}
{%- set v_cols = og_def(p['cols'], '4') -%}
{%- set v_item = og_def(p['item'], 'tile') -%}
{%- 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_11 -%}
{%- if og_t(og_eq(og_len(v_packs), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'coins', 'title': v_empty}}) }}
{%- else %}
{%- set c_10 -%}
{%- for v_pack in og_l(v_packs) %}
{%- set c_9 -%}
{%- set c_8 -%}
{%- set c_6 -%}
{%- if og_t(og_or([og_get(v_pack, ['badge']), og_and([not (og_eq(v_item, 'row')), og_gt(og_count(v_packs, 'badge'), 0)])])) %}
{%- set c_2 -%}
{%- if og_t(og_get(v_pack, ['badge'])) %}
{%- set c_1 -%}
{{ og_text(og_at(v_badges, og_get(v_pack, ['badge']))) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Class': 'w-fit shrink-0'}, 'children': c_1}) }}
{%- endif %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex min-h-6 items-center', 'Attrs': og_attrs(['data-slot', 'badge-slot'])}, 'children': c_2}) }}
{%- endif %}
{%- set c_5 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_pack, ['name'])) }}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': 'xl', 'Weight': 'bold'}, 'children': c_3}) }}
{%- set c_4 -%}
{{ og_text(og_money(og_get(v_pack, ['price']), og_get(v_pack, ['currency']))) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': '2xl', 'Weight': 'bold'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '0', 'Class': 'min-w-0'}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2', 'Align': 'start', 'Class': og_s(og_cnv(['min-w-0', ('flex-1' if og_t(og_eq(v_item, 'row')) else '')]))}, 'children': c_6}) }}
{%- set c_7 -%}
{{ og_text(v_buy) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': og_s(('default' if og_t(og_eq(og_get(v_pack, ['badge']), 'popular')) else 'outline')), 'Size': 'sm', 'Type': 'button', 'Class': og_s(og_cnv(['w-fit shrink-0', ('' if og_t(og_eq(v_item, 'row')) else 'mt-auto')]))}, 'children': c_7}) }}
{%- endset -%}
{{ og_include('compose/card-content.html.j2', {'p': {'Class': og_s(og_cnv(['flex h-full gap-4', ('flex-row flex-wrap items-center justify-between' if og_t(og_eq(v_item, 'row')) else 'flex-col')]))}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/card.html.j2', {'p': {'Variant': 'default', 'Class': og_s(og_cnv(['h-full', ('gap-4 p-4' if og_t(og_eq(v_item, 'row')) else ('gap-4 p-4' if og_t(og_eq(v_density, 'compact')) else ''))])), 'Attrs': og_attrs(['data-badge', og_get(v_pack, ['badge'])])}, 'children': c_9}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(('1' if og_t(og_eq(v_item, 'row')) else og_fit_cols(('1-2' if og_t(og_eq(v_cols, '2')) else '1-4'), og_len(v_packs)))), 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_10}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'tone': v_tone, 'density': v_density, 'measure': ('2xl' if og_t(og_eq(v_item, 'row')) else 'default'), 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(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.
Packs of credits as tiles: the amount, a badge, the price and a buy button. Axes: columns (2, 4), item (tile, row), tone, density.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| packs (required) | Pack[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| badges (required) | Record<string, string> | - | badge word by pack badge (popular, best) |
| buy (required) | string | - | |
| cols | "2" | "4" | "4" | |
| item | "tile" | "row" | "tile" | |
| 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 |