Story Panel
Story Panel component
Install
npx ui8kit add story-panelPulls in: badge, box, compose, group, kit-box, kit-text, milestone-timeline, stack, story-tabs, text, title, utils
Preview
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-panel<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag
in a muted box.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryPanelProps = {
s: Milestone;
index: number;
total: number;
labels: StoryLabels;
};
</script>
<script lang="ts">
import Badge from "../compose/Badge.svelte";
import Box from "../compose/Box.svelte";
import Group from "../compose/Group.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import Title from "../compose/Title.svelte";
import { tpl } from "../utils";
let { s, index, total, labels }: StoryPanelProps = $props();
</script>
<Stack gap="4" align="stretch" class="rounded bg-card inset-ring inset-ring-border p-6" data-slot="story-panel">
<Group gap="2" align="center">
<Badge variant="secondary" size="sm">
{s.date}
</Badge>
<Text size="xs" class="text-muted-foreground">
{tpl(labels.step, ((index + 1) == null ? undefined : String((index + 1))), (total == null ? undefined : String(total)))}
</Text>
</Group>
<Title as={3} size="xl" weight="semibold">
{s.title}
</Title>
<Text size="sm" class="text-muted-foreground">
{s.text}
</Text>
<Box class="rounded bg-muted p-4">
<Text size="sm" weight="semibold">
{s.tag}
</Text>
</Box>
</Stack>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add story-panel// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag
* in a muted box.
*/
import { type ReactNode } from "react";
import { Badge, Box, Group, Stack, Text, Title } from "../compose";
import { tpl } from "../utils";
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryPanelProps = {
s: Milestone;
index: number;
total: number;
labels: StoryLabels;
};
export function StoryPanel({ s, index, total, labels }: StoryPanelProps) {
return (
<Stack
gap="4"
align="stretch"
className="rounded bg-card inset-ring inset-ring-border p-6"
data-slot="story-panel"
>
<Group gap="2" align="center">
<Badge variant="secondary" size="sm">
{s.date}
</Badge>
<Text size="xs" className="text-muted-foreground">
{tpl(labels.step, ((index + 1) == null ? undefined : String((index + 1))), (total == null ? undefined : String(total)))}
</Text>
</Group>
<Title as={3} size="xl" weight="semibold">
{s.title}
</Title>
<Text size="sm" className="text-muted-foreground">
{s.text}
</Text>
<Box className="rounded bg-muted p-4">
<Text size="sm" weight="semibold">
{s.tag}
</Text>
</Box>
</Stack>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add story-panel<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag
in a muted box.
-->
<script lang="ts">
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryPanelProps = {
s: Milestone;
index: number;
total: number;
labels: StoryLabels;
};
</script>
<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Box from "../compose/Box.vue";
import Group from "../compose/Group.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import Title from "../compose/Title.vue";
import { tpl } from "../utils";
const { s, index, total, labels } = defineProps<StoryPanelProps>();
</script>
<template>
<Stack gap="4" align="stretch" class="rounded bg-card inset-ring inset-ring-border p-6" data-slot="story-panel">
<Group gap="2" align="center">
<Badge variant="secondary" size="sm">
{{ s.date }}
</Badge>
<Text size="xs" class="text-muted-foreground">
{{ tpl(labels.step, ((index + 1) == null ? undefined : String((index + 1))), (total == null ? undefined : String(total))) }}
</Text>
</Group>
<Title :as="3" size="xl" weight="semibold">
{{ s.title }}
</Title>
<Text size="sm" class="text-muted-foreground">
{{ s.text }}
</Text>
<Box class="rounded bg-muted p-4">
<Text size="sm" weight="semibold">
{{ s.tag }}
</Text>
</Box>
</Stack>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add story-panel// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag
* in a muted box.
*/
import { type JSX } from "solid-js";
import { Badge, Box, Group, Stack, Text, Title } from "../compose";
import { tpl } from "../utils";
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryPanelProps = {
s: Milestone;
index: number;
total: number;
labels: StoryLabels;
};
export function StoryPanel({ s, index, total, labels }: StoryPanelProps) {
return (
<Stack gap="4" align="stretch" class="rounded bg-card inset-ring inset-ring-border p-6" data-slot="story-panel">
<Group gap="2" align="center">
<Badge variant="secondary" size="sm">
{s.date}
</Badge>
<Text size="xs" class="text-muted-foreground">
{tpl(labels.step, ((index + 1) == null ? undefined : String((index + 1))), (total == null ? undefined : String(total)))}
</Text>
</Group>
<Title as={3} size="xl" weight="semibold">
{s.title}
</Title>
<Text size="sm" class="text-muted-foreground">
{s.text}
</Text>
<Box class="rounded bg-muted p-4">
<Text size="sm" weight="semibold">
{s.tag}
</Text>
</Box>
</Stack>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add story-panel// 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-panel.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/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// StoryPanelProps are the props of StoryPanel; the values are the JSON shapes of the TypeScript props.
type StoryPanelProps struct {
S any `json:"s"`
Index any `json:"index"`
Total any `json:"total"`
Labels any `json:"labels"`
}
// The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag in a muted box.
templ StoryPanel(p StoryPanelProps) {
{{ vS := p.S }}
{{ vIndex := p.Index }}
{{ vTotal := p.Total }}
{{ vLabels := p.Labels }}
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Class: "rounded bg-card inset-ring inset-ring-border p-6", Attrs: uiutils.Attrs("data-slot", "story-panel")}}) {
@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{}}) {
@compose.Badge(compose.BadgeProps{Variant: "secondary", Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vS, "date")) }
}
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Tpl(uiutils.Get(vLabels, "step"), uiutils.Str(uiutils.Add(vIndex, float64(1))), uiutils.Str(vTotal))) }
}
}
@compose.Title(compose.TitleProps{As: "3", Size: "xl", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vS, "title")) }
}
@compose.Text(compose.TextProps{Size: "sm", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vS, "text")) }
}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "rounded bg-muted p-4"}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vS, "tag")) }
}
}
}
}
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-panel{#- 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-panel.json
The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag in a muted box.
Props (p): s, index, total, labels. -#}
{%- set v_s = (p.s ?? null) -%}
{%- set v_index = (p.index ?? null) -%}
{%- set v_total = (p.total ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set c_8 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_s, ['date'])) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'secondary', 'size': 'sm', 'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_tpl(og_get(v_labels, ['step']), [og_str(og_add(v_index, 1)), og_str(v_total)])) }}
{%- 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': '2', 'align': 'center', 'children': c_3}, with_context = false) }}
{%- set c_4 -%}
{{ og_text(og_get(v_s, ['title'])) }}
{%- endset -%}
{{ include('compose/Title.html.twig', {'as': 3, 'size': 'xl', 'weight': 'semibold', 'children': c_4}, with_context = false) }}
{%- set c_5 -%}
{{ og_text(og_get(v_s, ['text'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'class': 'text-muted-foreground', 'children': c_5}, with_context = false) }}
{%- set c_7 -%}
{%- set c_6 -%}
{{ og_text(og_get(v_s, ['tag'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'rounded bg-muted p-4', 'children': c_7}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'class': 'rounded bg-card inset-ring inset-ring-border p-6', 'attrs': og_attrs(['data-slot', 'story-panel']), 'children': c_8}, 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 story-panel{* 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-panel.json
The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag in a muted box.
Props (p): s, index, total, labels. *}
{var $v_s = ($p['s'] ?? null)}
{var $v_index = ($p['index'] ?? null)}
{var $v_total = ($p['total'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{capture $c_8}
{capture $c_3}
{capture $c_1}
{=og_text(og_get($v_s, ['date']))}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'secondary', 'size' => 'sm', 'children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_tpl(og_get($v_labels, ['step']), [og_str(og_add($v_index, 1)), og_str($v_total)]))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'children' => (string) $c_3])|noescape}
{capture $c_4}
{=og_text(og_get($v_s, ['title']))}
{/capture}
{=og_include('compose/Title.latte', ['as' => 3, 'size' => 'xl', 'weight' => 'semibold', 'children' => (string) $c_4])|noescape}
{capture $c_5}
{=og_text(og_get($v_s, ['text']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'class' => 'text-muted-foreground', 'children' => (string) $c_5])|noescape}
{capture $c_7}
{capture $c_6}
{=og_text(og_get($v_s, ['tag']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'rounded bg-muted p-4', 'children' => (string) $c_7])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'class' => 'rounded bg-card inset-ring inset-ring-border p-6', 'attrs' => og_attrs(['data-slot', 'story-panel']), 'children' => (string) $c_8])|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 story-panel{#- 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-panel.json
The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag in a muted box.
Props (p): s, index, total, labels. -#}
{%- set v_s = og_def(p['s'], none) -%}
{%- set v_index = og_def(p['index'], none) -%}
{%- set v_total = og_def(p['total'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set c_8 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_get(v_s, ['date'])) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'secondary', 'Size': 'sm'}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_tpl(og_get(v_labels, ['step']), [og_str(og_add(v_index, 1)), og_str(v_total)])) }}
{%- 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': '2', 'Align': 'center'}, 'children': c_3}) }}
{%- set c_4 -%}
{{ og_text(og_get(v_s, ['title'])) }}
{%- endset -%}
{{ og_include('compose/title.html.j2', {'p': {'As': 3, 'Size': 'xl', 'Weight': 'semibold'}, 'children': c_4}) }}
{%- set c_5 -%}
{{ og_text(og_get(v_s, ['text'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Class': 'text-muted-foreground'}, 'children': c_5}) }}
{%- set c_7 -%}
{%- set c_6 -%}
{{ og_text(og_get(v_s, ['tag'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'rounded bg-muted p-4'}, 'children': c_7}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Class': 'rounded bg-card inset-ring inset-ring-border p-6', 'Attrs': og_attrs(['data-slot', 'story-panel'])}, 'children': c_8}) }}
Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
The panel of the active step of StoryTabs: the year badge and the step count, the title, the text and the tag in a muted box.
| Prop | Type | Default | Description |
|---|---|---|---|
| s (required) | Milestone | - | |
| index (required) | number | - | position of the step, from 0 |
| total (required) | number | - | |
| labels (required) | StoryLabels | - |