Story Tabs
Year tabs over the panel of the chosen year, or the heading beside a picture with arrows and one dot per step. Choosing a step is an event.
Install
npx ui8kit add story-tabsPulls in: box, button, compose, empty-state, group, inline, kit-box, kit-button, kit-text, lucide-icon, media-frame, milestone-timeline, section-frame, stack, story-dots, story-panel, utils
Preview
Five years in four steps
Pick a year to see what changed for the people who use the kit.
Step 3 of 4
Three runtimes
Svelte, React and Vue from the same specs, file for file.
Release
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 story-tabs<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year
with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next
arrows and one dot per step), tone. Choosing a step emits `select`.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { StoryLabels } from "./story-tabs.types";
import type { Milestone } from "./milestone-timeline.types";
export type StoryTabsProps = {
id: string;
title: string;
lead?: string;
badge?: string;
steps: Milestone[];
empty?: string;
active: string;
labels: StoryLabels;
layout?: "years" | "carousel";
tone?: "default" | "muted";
image?: string;
imageAlt?: string;
landmarkLabel?: string;
onselect?: (id: string) => void;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Stack from "../compose/Stack.svelte";
import EmptyState from "../components/empty-state.svelte";
import MediaFrame from "../components/media-frame.svelte";
import SectionFrame from "../components/section-frame.svelte";
import StoryDots from "../components/story-dots.svelte";
import StoryPanel from "../components/story-panel.svelte";
let {
id,
title,
lead = "",
badge = "",
steps,
empty = "",
active,
labels,
layout = "years",
tone = "default",
image,
imageAlt,
landmarkLabel,
onselect,
}: StoryTabsProps = $props();
</script>
{#if ((steps?.length ?? 0) === 0)}
<SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
<EmptyState icon="milestone" title={empty} />
</SectionFrame>
{:else if ((layout as string) === "years")}
<SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
<Box class="grid grid-cols-2 gap-2 sm:grid-cols-4" data-slot="story-tabs">
{#each steps as s (s.id)}
<Button
variant={((s.id === active) ? "default" : "outline")}
size="lg"
type="button"
class="h-auto flex-col items-start gap-0 py-2 text-start"
data-active={((s.id === active) ? "true" : "false")}
onclick={() => onselect?.(s.id)}
>
<Inline class="text-sm font-semibold">
{s.date}
</Inline>
<Inline class="text-xs">
{s.tag}
</Inline>
</Button>
{/each}
</Box>
{#each steps as s, i (s.id)}
{#if (s.id === active)}
<StoryPanel s={s} index={i} total={(steps?.length ?? 0)} labels={labels} />
{/if}
{/each}
</SectionFrame>
{:else}
<SectionFrame
id={id}
title={title}
lead={lead}
heading={{ badge }}
tone={tone}
layout="split"
media={{ show: true }}
landmarkLabel={landmarkLabel}
>
{#snippet aside()}
<Stack gap="4" align="stretch">
<MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
<Group gap="4" align="center" justify="between">
<Button variant="outline" size="sm" layout="icon" type="button" aria-label={labels.previous}>
<LucideIcon name="chevron-left" size={16} />
</Button>
<StoryDots steps={steps} active={active} />
<Button variant="outline" size="sm" layout="icon" type="button" aria-label={labels.next}>
<LucideIcon name="chevron-right" size={16} />
</Button>
</Group>
</Stack>
{/snippet}
</SectionFrame>
{/if}
// 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 StoryLabels = {
step: string;
previous: string;
next: 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 story-tabs// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year
* with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next
* arrows and one dot per step), tone. Choosing a step emits `select`.
*/
import { Fragment, type ReactNode } from "react";
import { Box, Button, Group, Inline, Stack } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { StoryDots } from "../components/story-dots";
import { StoryPanel } from "../components/story-panel";
import type { StoryLabels } from "./story-tabs.types";
import type { Milestone } from "./milestone-timeline.types";
export type StoryTabsProps = {
id: string;
title: string;
lead?: string;
badge?: string;
steps: Milestone[];
empty?: string;
active: string;
labels: StoryLabels;
layout?: "years" | "carousel";
tone?: "default" | "muted";
image?: string;
imageAlt?: string;
landmarkLabel?: string;
onSelect?: (id: string) => void;
};
export function StoryTabs({
id,
title,
lead = "",
badge = "",
steps,
empty = "",
active,
labels,
layout = "years",
tone = "default",
image,
imageAlt,
landmarkLabel,
onSelect,
}: StoryTabsProps) {
return (
<>
{((steps?.length ?? 0) === 0) ? (
<SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
<EmptyState icon="milestone" title={empty} />
</SectionFrame>
) : ((layout as string) === "years") ? (
<SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
<Box className="grid grid-cols-2 gap-2 sm:grid-cols-4" data-slot="story-tabs">
{(steps ?? []).map((s) => (
<Button key={s.id}
variant={((s.id === active) ? "default" : "outline")}
size="lg"
type="button"
className="h-auto flex-col items-start gap-0 py-2 text-start"
data-active={((s.id === active) ? "true" : "false")}
onClick={() => onSelect?.(s.id)}
>
<Inline className="text-sm font-semibold">
{s.date}
</Inline>
<Inline className="text-xs">
{s.tag}
</Inline>
</Button>
))}
</Box>
{(steps ?? []).map((s, i) => (
<Fragment key={s.id}>
{(s.id === active) ? (
<StoryPanel s={s} index={i} total={(steps?.length ?? 0)} labels={labels} />
) : null}
</Fragment>
))}
</SectionFrame>
) : (
<SectionFrame
id={id}
title={title}
lead={lead}
heading={{ badge }}
tone={tone}
layout="split"
media={{ show: true }}
landmarkLabel={landmarkLabel}
aside={(
<Stack gap="4" align="stretch">
<MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
<Group gap="4" align="center" justify="between">
<Button variant="outline" size="sm" layout="icon" type="button" aria-label={labels.previous}>
<LucideIcon name="chevron-left" size={16} />
</Button>
<StoryDots steps={steps} active={active} />
<Button variant="outline" size="sm" layout="icon" type="button" aria-label={labels.next}>
<LucideIcon name="chevron-right" size={16} />
</Button>
</Group>
</Stack>
)}
/>
)}
</>
);
}
// 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 StoryLabels = {
step: string;
previous: string;
next: 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 story-tabs// 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 StoryLabels = {
step: string;
previous: string;
next: 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. -->
<!--
A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year
with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next
arrows and one dot per step), tone. Choosing a step emits `select`.
-->
<script lang="ts">
import type { StoryLabels } from "./story-tabs.types";
import type { Milestone } from "./milestone-timeline.types";
export type StoryTabsProps = {
id: string;
title: string;
lead?: string;
badge?: string;
steps: Milestone[];
empty?: string;
active: string;
labels: StoryLabels;
layout?: "years" | "carousel";
tone?: "default" | "muted";
image?: string;
imageAlt?: string;
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import EmptyState from "../components/empty-state.vue";
import MediaFrame from "../components/media-frame.vue";
import SectionFrame from "../components/section-frame.vue";
import StoryDots from "../components/story-dots.vue";
import StoryPanel from "../components/story-panel.vue";
const {
id,
title,
lead = "",
badge = "",
steps,
empty = "",
active,
labels,
layout = "years",
tone = "default",
image,
imageAlt,
landmarkLabel,
} = defineProps<StoryTabsProps>();
const emit = defineEmits<{ select: [id: string] }>();
</script>
<template>
<SectionFrame v-if="((steps?.length ?? 0) === 0)"
:id="id"
:title="title"
:lead="lead"
:heading="{ badge }"
:tone="tone"
:landmarkLabel="landmarkLabel"
>
<EmptyState icon="milestone" :title="empty" />
</SectionFrame>
<SectionFrame v-else-if="((layout as string) === 'years')"
:id="id"
:title="title"
:lead="lead"
:heading="{ badge }"
:tone="tone"
:landmarkLabel="landmarkLabel"
>
<Box class="grid grid-cols-2 gap-2 sm:grid-cols-4" data-slot="story-tabs">
<Button v-for="s in steps" :key="s.id"
:variant="((s.id === active) ? 'default' : 'outline')"
size="lg"
type="button"
class="h-auto flex-col items-start gap-0 py-2 text-start"
:data-active="((s.id === active) ? 'true' : 'false')"
@click="() => emit('select', s.id)"
>
<Inline class="text-sm font-semibold">
{{ s.date }}
</Inline>
<Inline class="text-xs">
{{ s.tag }}
</Inline>
</Button>
</Box>
<template v-for="(s, i) in steps" :key="s.id">
<StoryPanel v-if="(s.id === active)" :s="s" :index="i" :total="(steps?.length ?? 0)" :labels="labels" />
</template>
</SectionFrame>
<SectionFrame v-else
:id="id"
:title="title"
:lead="lead"
:heading="{ badge }"
:tone="tone"
layout="split"
:media="{ show: true }"
:landmarkLabel="landmarkLabel"
>
<template #aside>
<Stack gap="4" align="stretch">
<MediaFrame :alt="(imageAlt ? imageAlt : title)" :src="image" ratio="4/3" />
<Group gap="4" align="center" justify="between">
<Button variant="outline" size="sm" layout="icon" type="button" :aria-label="labels.previous">
<LucideIcon name="chevron-left" :size="16" />
</Button>
<StoryDots :steps="steps" :active="active" />
<Button variant="outline" size="sm" layout="icon" type="button" :aria-label="labels.next">
<LucideIcon name="chevron-right" :size="16" />
</Button>
</Group>
</Stack>
</template>
</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 story-tabs// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year
* with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next
* arrows and one dot per step), tone. Choosing a step emits `select`.
*/
import { For, type JSX } from "solid-js";
import { Box, Button, Group, Inline, Stack } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { StoryDots } from "../components/story-dots";
import { StoryPanel } from "../components/story-panel";
import type { StoryLabels } from "./story-tabs.types";
import type { Milestone } from "./milestone-timeline.types";
export type StoryTabsProps = {
id: string;
title: string;
lead?: string;
badge?: string;
steps: Milestone[];
empty?: string;
active: string;
labels: StoryLabels;
layout?: "years" | "carousel";
tone?: "default" | "muted";
image?: string;
imageAlt?: string;
landmarkLabel?: string;
onSelect?: (id: string) => void;
};
export function StoryTabs({
id,
title,
lead = "",
badge = "",
steps,
empty = "",
active,
labels,
layout = "years",
tone = "default",
image,
imageAlt,
landmarkLabel,
onSelect,
}: StoryTabsProps) {
return (
<>
{((steps?.length ?? 0) === 0) ? (
<SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
<EmptyState icon="milestone" title={empty} />
</SectionFrame>
) : ((layout as string) === "years") ? (
<SectionFrame id={id} title={title} lead={lead} heading={{ badge }} tone={tone} landmarkLabel={landmarkLabel}>
<Box class="grid grid-cols-2 gap-2 sm:grid-cols-4" data-slot="story-tabs">
<For each={steps ?? []}>{(s) => (
<Button
variant={((s.id === active) ? "default" : "outline")}
size="lg"
type="button"
class="h-auto flex-col items-start gap-0 py-2 text-start"
data-active={((s.id === active) ? "true" : "false")}
onClick={() => onSelect?.(s.id)}
>
<Inline class="text-sm font-semibold">
{s.date}
</Inline>
<Inline class="text-xs">
{s.tag}
</Inline>
</Button>
)}</For>
</Box>
<For each={steps ?? []}>{(s, iOf) => { const i = iOf(); return (
<>
{(s.id === active) ? (
<StoryPanel s={s} index={i} total={(steps?.length ?? 0)} labels={labels} />
) : null}
</>
); }}</For>
</SectionFrame>
) : (
<SectionFrame
id={id}
title={title}
lead={lead}
heading={{ badge }}
tone={tone}
layout="split"
media={{ show: true }}
landmarkLabel={landmarkLabel}
aside={(
<Stack gap="4" align="stretch">
<MediaFrame alt={(imageAlt ? imageAlt : title)} src={image} ratio="4/3" />
<Group gap="4" align="center" justify="between">
<Button variant="outline" size="sm" layout="icon" type="button" aria-label={labels.previous}>
<LucideIcon name="chevron-left" size={16} />
</Button>
<StoryDots steps={steps} active={active} />
<Button variant="outline" size="sm" layout="icon" type="button" aria-label={labels.next}>
<LucideIcon name="chevron-right" size={16} />
</Button>
</Group>
</Stack>
)}
/>
)}
</>
);
}
// 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 StoryLabels = {
step: string;
previous: string;
next: 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 story-tabs// 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/story-tabs.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"
)
// StoryTabsProps are the props of StoryTabs; the values are the JSON shapes of the TypeScript props.
type StoryTabsProps struct {
Id any `json:"id"`
Title any `json:"title"`
Lead any `json:"lead"`
Badge any `json:"badge"`
Steps any `json:"steps"`
Empty any `json:"empty"`
Active any `json:"active"`
Labels any `json:"labels"`
Layout any `json:"layout"`
Tone any `json:"tone"`
Image any `json:"image"`
ImageAlt any `json:"imageAlt"`
LandmarkLabel any `json:"landmarkLabel"`
}
// A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next arrows and one dot per step), tone. Choosing a step emits `select`.
templ StoryTabs(p StoryTabsProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLead := uiutils.Def(p.Lead, "") }}
{{ vBadge := uiutils.Def(p.Badge, "") }}
{{ vSteps := p.Steps }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vActive := p.Active }}
{{ vLabels := p.Labels }}
{{ vLayout := uiutils.Def(p.Layout, "years") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vImage := p.Image }}
{{ vImageAlt := p.ImageAlt }}
{{ vLandmarkLabel := p.LandmarkLabel }}
if uiutils.Eq(uiutils.Len(vSteps), float64(0)) {
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, LandmarkLabel: vLandmarkLabel}) {
@EmptyState(EmptyStateProps{Icon: "milestone", Title: vEmpty})
}
} else if uiutils.Eq(vLayout, "years") {
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, LandmarkLabel: vLandmarkLabel}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "grid grid-cols-2 gap-2 sm:grid-cols-4", Attrs: uiutils.Attrs("data-slot", "story-tabs")}}) {
for _, vS := range uiutils.L(vSteps) {
@compose.Button(compose.ButtonProps{Variant: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vS, "id"), vActive)), "default", "outline")), Size: "lg", ButtonProps: button.ButtonProps{Type: "button", Class: "h-auto flex-col items-start gap-0 py-2 text-start", Attrs: uiutils.Attrs("data-active", uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vS, "id"), vActive)), "true", "false"))}}) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-sm font-semibold"}}) {
{ uiutils.Text(uiutils.Get(vS, "date")) }
}
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "text-xs"}}) {
{ uiutils.Text(uiutils.Get(vS, "tag")) }
}
}
}
}
for vI, vS := range uiutils.L(vSteps) {
if uiutils.Eq(uiutils.Get(vS, "id"), vActive) {
@StoryPanel(StoryPanelProps{S: vS, Index: float64(vI), Total: uiutils.Len(vSteps), Labels: vLabels})
}
}
}
} else {
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Heading: map[string]any{"badge": vBadge}, Tone: vTone, Layout: "split", Media: map[string]any{"show": true}, LandmarkLabel: vLandmarkLabel, Aside: storyTabsFill1(p, vTitle, vSteps, vActive, vLabels, vImage, vImageAlt)})
}
}
templ storyTabsFill1(p StoryTabsProps, vTitle any, vSteps any, vActive any, vLabels any, vImage any, vImageAlt any) {
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{}}) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Cond(uiutils.T(vImageAlt), vImageAlt, vTitle), Src: vImage, Ratio: "4/3"})
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "between", BoxProps: box.BoxProps{}}) {
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{Type: "button", AriaLabel: uiutils.S(uiutils.Get(vLabels, "previous"))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "chevron-left", Size: 16})
}
@StoryDots(StoryDotsProps{Steps: vSteps, Active: vActive})
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{Type: "button", AriaLabel: uiutils.S(uiutils.Get(vLabels, "next"))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "chevron-right", Size: 16})
}
}
}
}
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 story-tabs{#- 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/story-tabs.json
A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next arrows and one dot per step), tone. Choosing a step emits `select`.
Props (p): id, title, lead, badge, steps, empty, active, labels, layout, tone, image, imageAlt, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_lead = (p.lead ?? '') -%}
{%- set v_badge = (p.badge ?? '') -%}
{%- set v_steps = (p.steps ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_active = (p.active ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_layout = (p.layout ?? 'years') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_image = (p.image ?? null) -%}
{%- set v_imageAlt = (p.imageAlt ?? null) -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- if og_t(og_eq(og_len(v_steps), 0)) %}
{%- set c_1 -%}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'milestone', 'title': v_empty}}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_1)}, with_context = false) }}
{%- elseif og_t(og_eq(v_layout, 'years')) %}
{%- set c_6 -%}
{%- set c_5 -%}
{%- for v_s in og_l(v_steps) %}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_s, ['date'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'text-sm font-semibold', 'children': c_2}, with_context = false) }}
{%- set c_3 -%}
{{ og_text(og_get(v_s, ['tag'])) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'text-xs', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': og_s((og_t(og_eq(og_get(v_s, ['id']), v_active)) ? 'default' : 'outline')), 'size': 'lg', 'type': 'button', 'class': 'h-auto flex-col items-start gap-0 py-2 text-start', 'attrs': og_attrs(['data-active', (og_t(og_eq(og_get(v_s, ['id']), v_active)) ? 'true' : 'false')]), 'children': c_4}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'grid grid-cols-2 gap-2 sm:grid-cols-4', 'attrs': og_attrs(['data-slot', 'story-tabs']), 'children': c_5}, with_context = false) }}
{%- for v_s in og_l(v_steps) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_eq(og_get(v_s, ['id']), v_active)) %}
{{ include('blocks/story-panel.html.twig', {'p': {'s': v_s, 'index': v_i, 'total': og_len(v_steps), 'labels': v_labels}}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_6)}, with_context = false) }}
{%- else %}
{%- set f_7 -%}
{%- set c_11 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': (og_t(v_imageAlt) ? v_imageAlt : v_title), 'src': v_image, 'ratio': '4/3'}}, with_context = false) }}
{%- set c_10 -%}
{%- set c_8 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'chevron-left', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'layout': 'icon', 'type': 'button', 'ariaLabel': og_s(og_get(v_labels, ['previous'])), 'children': c_8}, with_context = false) }}
{{ include('blocks/story-dots.html.twig', {'p': {'steps': v_steps, 'active': v_active}}, with_context = false) }}
{%- set c_9 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'chevron-right', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'layout': 'icon', 'type': 'button', 'ariaLabel': og_s(og_get(v_labels, ['next'])), 'children': c_9}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'between', 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'children': c_11}, with_context = false) }}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'layout': 'split', 'media': {'show': true}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_7)}}, with_context = false) }}
{%- endif %}
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 story-tabs{* 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/story-tabs.json
A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next arrows and one dot per step), tone. Choosing a step emits `select`.
Props (p): id, title, lead, badge, steps, empty, active, labels, layout, tone, image, imageAlt, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_lead = ($p['lead'] ?? '')}
{var $v_badge = ($p['badge'] ?? '')}
{var $v_steps = ($p['steps'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_active = ($p['active'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'years')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_image = ($p['image'] ?? null)}
{var $v_imageAlt = ($p['imageAlt'] ?? null)}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{if og_t(og_eq(og_len($v_steps), 0))}
{capture $c_1}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'milestone', 'title' => $v_empty]])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_1)])|noescape}
{elseif og_t(og_eq($v_layout, 'years'))}
{capture $c_6}
{capture $c_5}
{foreach og_l($v_steps) as $v_s}
{capture $c_4}
{capture $c_2}
{=og_text(og_get($v_s, ['date']))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'text-sm font-semibold', 'children' => (string) $c_2])|noescape}
{capture $c_3}
{=og_text(og_get($v_s, ['tag']))}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'text-xs', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => og_s((og_t(og_eq(og_get($v_s, ['id']), $v_active)) ? 'default' : 'outline')), 'size' => 'lg', 'type' => 'button', 'class' => 'h-auto flex-col items-start gap-0 py-2 text-start', 'attrs' => og_attrs(['data-active', (og_t(og_eq(og_get($v_s, ['id']), $v_active)) ? 'true' : 'false')]), 'children' => (string) $c_4])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'grid grid-cols-2 gap-2 sm:grid-cols-4', 'attrs' => og_attrs(['data-slot', 'story-tabs']), 'children' => (string) $c_5])|noescape}
{foreach og_l($v_steps) as $v_s}
{var $v_i = $iterator->counter0}
{if og_t(og_eq(og_get($v_s, ['id']), $v_active))}
{=og_include('blocks/story-panel.latte', ['p' => ['s' => $v_s, 'index' => $v_i, 'total' => og_len($v_steps), 'labels' => $v_labels]])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_6)])|noescape}
{else}
{capture $f_7}
{capture $c_11}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => (og_t($v_imageAlt) ? $v_imageAlt : $v_title), 'src' => $v_image, 'ratio' => '4/3']])|noescape}
{capture $c_10}
{capture $c_8}
{=og_include('icons/LucideIcon.latte', ['name' => 'chevron-left', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'layout' => 'icon', 'type' => 'button', 'ariaLabel' => og_s(og_get($v_labels, ['previous'])), 'children' => (string) $c_8])|noescape}
{=og_include('blocks/story-dots.latte', ['p' => ['steps' => $v_steps, 'active' => $v_active]])|noescape}
{capture $c_9}
{=og_include('icons/LucideIcon.latte', ['name' => 'chevron-right', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'layout' => 'icon', 'type' => 'button', 'ariaLabel' => og_s(og_get($v_labels, ['next'])), 'children' => (string) $c_9])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'between', 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'children' => (string) $c_11])|noescape}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'heading' => ['badge' => $v_badge], 'tone' => $v_tone, 'layout' => 'split', 'media' => ['show' => true], 'landmarkLabel' => $v_landmarkLabel, 'aside' => og_markup($f_7)]])|noescape}
{/if}
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 story-tabs{#- 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/story-tabs.json
A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next arrows and one dot per step), tone. Choosing a step emits `select`.
Props (p): id, title, lead, badge, steps, empty, active, labels, layout, tone, image, imageAlt, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_lead = og_def(p['lead'], '') -%}
{%- set v_badge = og_def(p['badge'], '') -%}
{%- set v_steps = og_def(p['steps'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_active = og_def(p['active'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_layout = og_def(p['layout'], 'years') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_image = og_def(p['image'], none) -%}
{%- set v_imageAlt = og_def(p['imageAlt'], none) -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- if og_t(og_eq(og_len(v_steps), 0)) %}
{%- set c_1 -%}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'milestone', 'title': v_empty}}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_1)}) }}
{%- elif og_t(og_eq(v_layout, 'years')) %}
{%- set c_6 -%}
{%- set c_5 -%}
{%- for v_s in og_l(v_steps) %}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_s, ['date'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-sm font-semibold'}, 'children': c_2}) }}
{%- set c_3 -%}
{{ og_text(og_get(v_s, ['tag'])) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'text-xs'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': og_s(('default' if og_t(og_eq(og_get(v_s, ['id']), v_active)) else 'outline')), 'Size': 'lg', 'Type': 'button', 'Class': 'h-auto flex-col items-start gap-0 py-2 text-start', 'Attrs': og_attrs(['data-active', ('true' if og_t(og_eq(og_get(v_s, ['id']), v_active)) else 'false')])}, 'children': c_4}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'grid grid-cols-2 gap-2 sm:grid-cols-4', 'Attrs': og_attrs(['data-slot', 'story-tabs'])}, 'children': c_5}) }}
{%- for v_s in og_l(v_steps) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_eq(og_get(v_s, ['id']), v_active)) %}
{{ og_include('blocks/story-panel.html.j2', {'p': {'s': v_s, 'index': v_i, 'total': og_len(v_steps), 'labels': v_labels}}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_6)}) }}
{%- else %}
{%- set f_7 -%}
{%- set c_11 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': (v_imageAlt if og_t(v_imageAlt) else v_title), 'src': v_image, 'ratio': '4/3'}}) }}
{%- set c_10 -%}
{%- set c_8 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'chevron-left', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm', 'Layout': 'icon', 'Type': 'button', 'AriaLabel': og_s(og_get(v_labels, ['previous']))}, 'children': c_8}) }}
{{ og_include('blocks/story-dots.html.j2', {'p': {'steps': v_steps, 'active': v_active}}) }}
{%- set c_9 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'chevron-right', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm', 'Layout': 'icon', 'Type': 'button', 'AriaLabel': og_s(og_get(v_labels, ['next']))}, 'children': c_9}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'between'}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch'}, 'children': c_11}) }}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'heading': {'badge': v_badge}, 'tone': v_tone, 'layout': 'split', 'media': {'show': true}, 'landmarkLabel': v_landmarkLabel, 'aside': og_markup(f_7)}}) }}
{%- endif %}
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.
A story in steps (years or slides). Axes: layout (years: a row of year tabs over the panel of the active year with its badge, step, title, text and tag; carousel: the heading beside a picture with previous and next arrows and one dot per step), tone. Choosing a step emits `select`.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| lead | string | "" | |
| badge | string | "" | a short pill above the heading |
| steps (required) | Milestone[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| active (required) | string | - | the id of the step shown |
| labels (required) | StoryLabels | - | template step `Step {0} of {1}`; the accessible names of the arrows |
| layout | "years" | "carousel" | "years" | |
| tone | "default" | "muted" | "default" | |
| image | string | - | address of the picture (an https URL or a path); none: the placeholder |
| imageAlt | string | - | alt text of the picture; none: the title |
| 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 |