Skip to content
ui8kit

component / components

Slot Grid

Slot Grid component

Install

npx ui8kit add slot-grid

Pulls in: box, compose, group, inline, kit-box, kit-label, kit-radio, kit-text, label, radio, stack, text, utils

Preview

Today, 8 October

2 windows left

Tomorrow, 9 October

6 windows

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-cdn
npx ui8kit add slot-grid
components/slot-grid.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck
  through. One radio group (`name`) across all days. Static markup.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Day } from "./slot-grid.types";

  export type SlotGridProps = {
    days: Day[];
    name: string;
    item?: "card" | "plain";
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Group from "../compose/Group.svelte";
  import Inline from "../compose/Inline.svelte";
  import Label from "../compose/Label.svelte";
  import Radio from "../compose/Radio.svelte";
  import Stack from "../compose/Stack.svelte";
  import Text from "../compose/Text.svelte";
  import { cn, tpl } from "../utils";

  let { days, name, item = "card" }: SlotGridProps = $props();
</script>

<Stack gap="4" align="stretch" data-slot="days">
  {#each days as d (d.id)}
    <Stack
      gap="4"
      class={
        (item as string) === "card" ? "rounded bg-card inset-ring inset-ring-border p-4"
        : "border-b border-border pb-4"
      }
      data-slot="day"
    >
      <Group gap="4" align="baseline" justify="between" class="flex-wrap">
        <Text size="sm" weight="semibold">
          {d.title}
        </Text>
        <Text size="xs" class="text-muted-foreground">
          {d.note}
        </Text>
      </Group>
      <Box class="grid grid-cols-2 gap-2 sm:grid-cols-3">
        {#each d.slots as s (s)}
          <Label
            class={"flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
              "has-checked:inset-ring-foreground"}
            data-slot="slots-row"
          >
            <Radio name={name} value={tpl("{0} {1}", d.id, s)} />
            <Inline>
              {s}
            </Inline>
          </Label>
        {/each}
        {#each d.closed as s (s)}
          <Label
            class={cn(
              "flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
                "has-checked:inset-ring-foreground",
              "text-muted-foreground line-through"
            )}
            data-slot="closed-row"
          >
            <Radio name={name} value={tpl("{0} {1}", d.id, s)} disabled={true} />
            <Inline>
              {s}
            </Inline>
          </Label>
        {/each}
      </Box>
    </Stack>
  {/each}
</Stack>
components/slot-grid.types.ts
// 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 Day = {
  id: string;
  title: string;
  note: string;
  slots: string[];
  closed: string[];
};

Svelte registry item (JSON)

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-cdn
npx ui8kit add slot-grid
components/slot-grid.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck
 * through. One radio group (`name`) across all days. Static markup.
 */
import { type ReactNode } from "react";
import { Box, Group, Inline, Label, Radio, Stack, Text } from "../compose";
import { cn, tpl } from "../utils";
import type { Day } from "./slot-grid.types";

export type SlotGridProps = {
  days: Day[];
  name: string;
  item?: "card" | "plain";
};

export function SlotGrid({ days, name, item = "card" }: SlotGridProps) {
  return (
    <Stack gap="4" align="stretch" data-slot="days">
      {(days ?? []).map((d) => (
        <Stack key={d.id}
          gap="4"
          className={
            (item as string) === "card" ? "rounded bg-card inset-ring inset-ring-border p-4"
            : "border-b border-border pb-4"
          }
          data-slot="day"
        >
          <Group gap="4" align="baseline" justify="between" className="flex-wrap">
            <Text size="sm" weight="semibold">
              {d.title}
            </Text>
            <Text size="xs" className="text-muted-foreground">
              {d.note}
            </Text>
          </Group>
          <Box className="grid grid-cols-2 gap-2 sm:grid-cols-3">
            {(d.slots ?? []).map((s) => (
              <Label key={s}
                className={"flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
                  "has-checked:inset-ring-foreground"}
                data-slot="slots-row"
              >
                <Radio name={name} value={tpl("{0} {1}", d.id, s)} />
                <Inline>
                  {s}
                </Inline>
              </Label>
            ))}
            {(d.closed ?? []).map((s) => (
              <Label key={s}
                className={cn(
                  "flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
                    "has-checked:inset-ring-foreground",
                  "text-muted-foreground line-through"
                )}
                data-slot="closed-row"
              >
                <Radio name={name} value={tpl("{0} {1}", d.id, s)} disabled={true} />
                <Inline>
                  {s}
                </Inline>
              </Label>
            ))}
          </Box>
        </Stack>
      ))}
    </Stack>
  );
}
components/slot-grid.types.ts
// 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 Day = {
  id: string;
  title: string;
  note: string;
  slots: string[];
  closed: string[];
};

React registry item (JSON)

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-cdn
npx ui8kit add slot-grid
components/slot-grid.types.ts
// 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 Day = {
  id: string;
  title: string;
  note: string;
  slots: string[];
  closed: string[];
};
components/slot-grid.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck
  through. One radio group (`name`) across all days. Static markup.
-->
<script lang="ts">
import type { Day } from "./slot-grid.types";

export type SlotGridProps = {
  days: Day[];
  name: string;
  item?: "card" | "plain";
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import Label from "../compose/Label.vue";
import Radio from "../compose/Radio.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import { cn, tpl } from "../utils";

const { days, name, item = "card" } = defineProps<SlotGridProps>();
</script>

<template>
  <Stack gap="4" align="stretch" data-slot="days">
    <Stack v-for="d in days" :key="d.id"
      gap="4"
      :class="
        (item as string) === 'card' ? 'rounded bg-card inset-ring inset-ring-border p-4'
        : 'border-b border-border pb-4'
      "
      data-slot="day"
    >
      <Group gap="4" align="baseline" justify="between" class="flex-wrap">
        <Text size="sm" weight="semibold">
          {{ d.title }}
        </Text>
        <Text size="xs" class="text-muted-foreground">
          {{ d.note }}
        </Text>
      </Group>
      <Box class="grid grid-cols-2 gap-2 sm:grid-cols-3">
        <Label v-for="s in d.slots" :key="s"
          :class="'flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted ' +
            'has-checked:inset-ring-foreground'"
          data-slot="slots-row"
        >
          <Radio :name="name" :value="tpl('{0} {1}', d.id, s)" />
          <Inline>
            {{ s }}
          </Inline>
        </Label>
        <Label v-for="s in d.closed" :key="s"
          :class="cn(
            'flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted ' +
              'has-checked:inset-ring-foreground',
            'text-muted-foreground line-through'
          )"
          data-slot="closed-row"
        >
          <Radio :name="name" :value="tpl('{0} {1}', d.id, s)" :disabled="true" />
          <Inline>
            {{ s }}
          </Inline>
        </Label>
      </Box>
    </Stack>
  </Stack>
</template>

Vue registry item (JSON)

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-cdn
npx ui8kit add slot-grid
components/slot-grid.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck
 * through. One radio group (`name`) across all days. Static markup.
 */
import { For, type JSX } from "solid-js";
import { Box, Group, Inline, Label, Radio, Stack, Text } from "../compose";
import { cn, tpl } from "../utils";
import type { Day } from "./slot-grid.types";

export type SlotGridProps = {
  days: Day[];
  name: string;
  item?: "card" | "plain";
};

export function SlotGrid({ days, name, item = "card" }: SlotGridProps) {
  return (
    <Stack gap="4" align="stretch" data-slot="days">
      <For each={days ?? []}>{(d) => (
        <Stack
          gap="4"
          class={
            (item as string) === "card" ? "rounded bg-card inset-ring inset-ring-border p-4"
            : "border-b border-border pb-4"
          }
          data-slot="day"
        >
          <Group gap="4" align="baseline" justify="between" class="flex-wrap">
            <Text size="sm" weight="semibold">
              {d.title}
            </Text>
            <Text size="xs" class="text-muted-foreground">
              {d.note}
            </Text>
          </Group>
          <Box class="grid grid-cols-2 gap-2 sm:grid-cols-3">
            <For each={d.slots ?? []}>{(s) => (
              <Label
                class={"flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
                  "has-checked:inset-ring-foreground"}
                data-slot="slots-row"
              >
                <Radio name={name} value={tpl("{0} {1}", d.id, s)} />
                <Inline>
                  {s}
                </Inline>
              </Label>
            )}</For>
            <For each={d.closed ?? []}>{(s) => (
              <Label
                class={cn(
                  "flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted " +
                    "has-checked:inset-ring-foreground",
                  "text-muted-foreground line-through"
                )}
                data-slot="closed-row"
              >
                <Radio name={name} value={tpl("{0} {1}", d.id, s)} disabled={true} />
                <Inline>
                  {s}
                </Inline>
              </Label>
            )}</For>
          </Box>
        </Stack>
      )}</For>
    </Stack>
  );
}
components/slot-grid.types.ts
// 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 Day = {
  id: string;
  title: string;
  note: string;
  slots: string[];
  closed: string[];
};

Solid registry item (JSON)

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-cdn
npx ui8kit add slot-grid
blocks/slot-grid.templ
// 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/slot-grid.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	"github.com/ui8kit/codegen/generated/templ/ui/label"
	"github.com/ui8kit/codegen/generated/templ/ui/radio"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// SlotGridProps are the props of SlotGrid; the values are the JSON shapes of the TypeScript props.
type SlotGridProps struct {
	Days any `json:"days"`
	Name any `json:"name"`
	Item any `json:"item"`
}

// Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck through. One radio group (`name`) across all days. Static markup.
templ SlotGrid(p SlotGridProps) {
	{{ vDays := p.Days }}
	{{ vName := p.Name }}
	{{ vItem := uiutils.Def(p.Item, "card") }}
	@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "days")}}) {
		for _, vD := range uiutils.L(vDays) {
			@compose.Stack(compose.StackProps{Gap: "4", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vItem, "card")), "rounded bg-card inset-ring inset-ring-border p-4", "border-b border-border pb-4")), Attrs: uiutils.Attrs("data-slot", "day")}}) {
				@compose.Group(compose.GroupProps{Gap: "4", Align: "baseline", Justify: "between", BoxProps: box.BoxProps{Class: "flex-wrap"}}) {
					@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
						{ uiutils.Text(uiutils.Get(vD, "title")) }
					}
					@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
						{ uiutils.Text(uiutils.Get(vD, "note")) }
					}
				}
				@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "grid grid-cols-2 gap-2 sm:grid-cols-3"}}) {
					for _, vS := range uiutils.L(uiutils.Get(vD, "slots")) {
						@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{Class: "flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground", Attrs: uiutils.Attrs("data-slot", "slots-row")}}) {
							@compose.Radio(compose.RadioProps{RadioProps: radio.RadioProps{Name: uiutils.S(vName), Value: uiutils.SP(uiutils.Tpl("{0} {1}", uiutils.Get(vD, "id"), vS))}})
							@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
								{ uiutils.Text(vS) }
							}
						}
					}
					for _, vS := range uiutils.L(uiutils.Get(vD, "closed")) {
						@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{Class: uiutils.S(uiutils.Cnv("flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground", "text-muted-foreground line-through")), Attrs: uiutils.Attrs("data-slot", "closed-row")}}) {
							@compose.Radio(compose.RadioProps{RadioProps: radio.RadioProps{Name: uiutils.S(vName), Value: uiutils.SP(uiutils.Tpl("{0} {1}", uiutils.Get(vD, "id"), vS)), Disabled: true}})
							@compose.Inline(compose.InlineProps{TextProps: text.TextProps{}}) {
								{ uiutils.Text(vS) }
							}
						}
					}
				}
			}
		}
	}
}

templ registry item (JSON)

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-cdn
npx ui8kit add slot-grid
blocks/slot-grid.html.twig
{#- 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/slot-grid.json
    Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck through. One radio group (`name`) across all days. Static markup.
    Props (p): days, name, item. -#}
{%- set v_days = (p.days ?? null) -%}
{%- set v_name = (p.name ?? null) -%}
{%- set v_item = (p.item ?? 'card') -%}
{%- set c_10 -%}
  {%- for v_d in og_l(v_days) %}
    {%- set c_9 -%}
      {%- set c_3 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_d, ['title'])) }}
        {%- endset -%}
        {{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
        {%- set c_2 -%}
          {{ og_text(og_get(v_d, ['note'])) }}
        {%- endset -%}
        {{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
      {%- endset -%}
      {{ include('compose/Group.html.twig', {'gap': '4', 'align': 'baseline', 'justify': 'between', 'class': 'flex-wrap', 'children': c_3}, with_context = false) }}
      {%- set c_8 -%}
        {%- for v_s in og_l(og_get(v_d, ['slots'])) %}
          {%- set c_5 -%}
            {{ include('compose/Radio.html.twig', {'name': og_s(v_name), 'value': og_s(og_tpl('{0} {1}', [og_get(v_d, ['id']), v_s]))}, with_context = false) }}
            {%- set c_4 -%}
              {{ og_text(v_s) }}
            {%- endset -%}
            {{ include('compose/Inline.html.twig', {'children': c_4}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/Label.html.twig', {'class': 'flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'attrs': og_attrs(['data-slot', 'slots-row']), 'children': c_5}, with_context = false) }}
        {%- endfor %}
        {%- for v_s in og_l(og_get(v_d, ['closed'])) %}
          {%- set c_7 -%}
            {{ include('compose/Radio.html.twig', {'name': og_s(v_name), 'value': og_s(og_tpl('{0} {1}', [og_get(v_d, ['id']), v_s])), 'disabled': true}, with_context = false) }}
            {%- set c_6 -%}
              {{ og_text(v_s) }}
            {%- endset -%}
            {{ include('compose/Inline.html.twig', {'children': c_6}, with_context = false) }}
          {%- endset -%}
          {{ include('compose/Label.html.twig', {'class': og_s(og_cnv(['flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'text-muted-foreground line-through'])), 'attrs': og_attrs(['data-slot', 'closed-row']), 'children': c_7}, with_context = false) }}
        {%- endfor %}
      {%- endset -%}
      {{ include('compose/Box.html.twig', {'class': 'grid grid-cols-2 gap-2 sm:grid-cols-3', 'children': c_8}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Stack.html.twig', {'gap': '4', 'class': og_s((og_t(og_eq(v_item, 'card')) ? 'rounded bg-card inset-ring inset-ring-border p-4' : 'border-b border-border pb-4')), 'attrs': og_attrs(['data-slot', 'day']), 'children': c_9}, with_context = false) }}
  {%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'days']), 'children': c_10}, with_context = false) }}

Twig registry item (JSON)

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-cdn
npx ui8kit add slot-grid
blocks/slot-grid.latte
{* 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/slot-grid.json
    Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck through. One radio group (`name`) across all days. Static markup.
    Props (p): days, name, item. *}
{var $v_days = ($p['days'] ?? null)}
{var $v_name = ($p['name'] ?? null)}
{var $v_item = ($p['item'] ?? 'card')}
{capture $c_10}
  {foreach og_l($v_days) as $v_d}
    {capture $c_9}
      {capture $c_3}
        {capture $c_1}
          {=og_text(og_get($v_d, ['title']))}
        {/capture}
        {=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
        {capture $c_2}
          {=og_text(og_get($v_d, ['note']))}
        {/capture}
        {=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
      {/capture}
      {=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'baseline', 'justify' => 'between', 'class' => 'flex-wrap', 'children' => (string) $c_3])|noescape}
      {capture $c_8}
        {foreach og_l(og_get($v_d, ['slots'])) as $v_s}
          {capture $c_5}
            {=og_include('compose/Radio.latte', ['name' => og_s($v_name), 'value' => og_s(og_tpl('{0} {1}', [og_get($v_d, ['id']), $v_s]))])|noescape}
            {capture $c_4}
              {=og_text($v_s)}
            {/capture}
            {=og_include('compose/Inline.latte', ['children' => (string) $c_4])|noescape}
          {/capture}
          {=og_include('compose/Label.latte', ['class' => 'flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'attrs' => og_attrs(['data-slot', 'slots-row']), 'children' => (string) $c_5])|noescape}
        {/foreach}
        {foreach og_l(og_get($v_d, ['closed'])) as $v_s}
          {capture $c_7}
            {=og_include('compose/Radio.latte', ['name' => og_s($v_name), 'value' => og_s(og_tpl('{0} {1}', [og_get($v_d, ['id']), $v_s])), 'disabled' => true])|noescape}
            {capture $c_6}
              {=og_text($v_s)}
            {/capture}
            {=og_include('compose/Inline.latte', ['children' => (string) $c_6])|noescape}
          {/capture}
          {=og_include('compose/Label.latte', ['class' => og_s(og_cnv(['flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'text-muted-foreground line-through'])), 'attrs' => og_attrs(['data-slot', 'closed-row']), 'children' => (string) $c_7])|noescape}
        {/foreach}
      {/capture}
      {=og_include('compose/Box.latte', ['class' => 'grid grid-cols-2 gap-2 sm:grid-cols-3', 'children' => (string) $c_8])|noescape}
    {/capture}
    {=og_include('compose/Stack.latte', ['gap' => '4', 'class' => og_s((og_t(og_eq($v_item, 'card')) ? 'rounded bg-card inset-ring inset-ring-border p-4' : 'border-b border-border pb-4')), 'attrs' => og_attrs(['data-slot', 'day']), 'children' => (string) $c_9])|noescape}
  {/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'days']), 'children' => (string) $c_10])|noescape}

Latte registry item (JSON)

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-cdn
npx ui8kit add slot-grid
blocks/slot-grid.html.j2
{#- 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/slot-grid.json
    Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck through. One radio group (`name`) across all days. Static markup.
    Props (p): days, name, item. -#}
{%- set v_days = og_def(p['days'], none) -%}
{%- set v_name = og_def(p['name'], none) -%}
{%- set v_item = og_def(p['item'], 'card') -%}
{%- set c_10 -%}
  {%- for v_d in og_l(v_days) %}
    {%- set c_9 -%}
      {%- set c_3 -%}
        {%- set c_1 -%}
          {{ og_text(og_get(v_d, ['title'])) }}
        {%- endset -%}
        {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_1}) }}
        {%- set c_2 -%}
          {{ og_text(og_get(v_d, ['note'])) }}
        {%- endset -%}
        {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
      {%- endset -%}
      {{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'baseline', 'Justify': 'between', 'Class': 'flex-wrap'}, 'children': c_3}) }}
      {%- set c_8 -%}
        {%- for v_s in og_l(og_get(v_d, ['slots'])) %}
          {%- set c_5 -%}
            {{ og_include('compose/radio.html.j2', {'p': {'Name': og_s(v_name), 'Value': og_s(og_tpl('{0} {1}', [og_get(v_d, ['id']), v_s]))}}) }}
            {%- set c_4 -%}
              {{ og_text(v_s) }}
            {%- endset -%}
            {{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_4}) }}
          {%- endset -%}
          {{ og_include('compose/label.html.j2', {'p': {'Class': 'flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'Attrs': og_attrs(['data-slot', 'slots-row'])}, 'children': c_5}) }}
        {%- endfor %}
        {%- for v_s in og_l(og_get(v_d, ['closed'])) %}
          {%- set c_7 -%}
            {{ og_include('compose/radio.html.j2', {'p': {'Name': og_s(v_name), 'Value': og_s(og_tpl('{0} {1}', [og_get(v_d, ['id']), v_s])), 'Disabled': true}}) }}
            {%- set c_6 -%}
              {{ og_text(v_s) }}
            {%- endset -%}
            {{ og_include('compose/inline.html.j2', {'p': {}, 'children': c_6}) }}
          {%- endset -%}
          {{ og_include('compose/label.html.j2', {'p': {'Class': og_s(og_cnv(['flex items-center gap-2 rounded px-4 py-2 text-sm inset-ring inset-ring-border has-checked:bg-muted has-checked:inset-ring-foreground', 'text-muted-foreground line-through'])), 'Attrs': og_attrs(['data-slot', 'closed-row'])}, 'children': c_7}) }}
        {%- endfor %}
      {%- endset -%}
      {{ og_include('compose/box.html.j2', {'p': {'Class': 'grid grid-cols-2 gap-2 sm:grid-cols-3'}, 'children': c_8}) }}
    {%- endset -%}
    {{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Class': og_s(('rounded bg-card inset-ring inset-ring-border p-4' if og_t(og_eq(v_item, 'card')) else 'border-b border-border pb-4')), 'Attrs': og_attrs(['data-slot', 'day'])}, 'children': c_9}) }}
  {%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'days'])}, 'children': c_10}) }}

Jinja2 registry item (JSON)

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.

Delivery windows by day: each day lists its windows as radio chips; closed windows are disabled and struck through. One radio group (`name`) across all days. Static markup.

Props of SlotGrid
PropTypeDefault Description
days (required)Day[]-
name (required)string-name of the radio group
item "card" | "plain""card"card: each day in a card; plain: days divided by a line

Used in