Story Dots
Story Dots component
Install
npx ui8kit add story-dotsPulls in: compose, group, inline, kit-box, kit-text, milestone-timeline, story-tabs, utils
Preview
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-dots<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- One dot per step of StoryTabs; the dot of the active step is filled. -->
<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 StoryDotsProps = {
steps: Milestone[];
active: string;
};
</script>
<script lang="ts">
import Group from "../compose/Group.svelte";
import Inline from "../compose/Inline.svelte";
import { cn } from "../utils";
let { steps, active }: StoryDotsProps = $props();
</script>
<Group gap="2" align="center" data-slot="story-dots">
{#each steps as s (s.id)}
<Inline
class={cn("size-2 rounded-full", ((s.id === active) ? "bg-primary" : "bg-border"))}
data-slot="story-dot"
/>
{/each}
</Group>
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-dots// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** One dot per step of StoryTabs; the dot of the active step is filled. */
import { type ReactNode } from "react";
import { Group, Inline } from "../compose";
import { cn } from "../utils";
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryDotsProps = {
steps: Milestone[];
active: string;
};
export function StoryDots({ steps, active }: StoryDotsProps) {
return (
<Group gap="2" align="center" data-slot="story-dots">
{(steps ?? []).map((s) => (
<Inline key={s.id}
className={cn("size-2 rounded-full", ((s.id === active) ? "bg-primary" : "bg-border"))}
data-slot="story-dot"
/>
))}
</Group>
);
}
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-dots<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- One dot per step of StoryTabs; the dot of the active step is filled. -->
<script lang="ts">
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryDotsProps = {
steps: Milestone[];
active: string;
};
</script>
<script setup lang="ts">
import Group from "../compose/Group.vue";
import Inline from "../compose/Inline.vue";
import { cn } from "../utils";
const { steps, active } = defineProps<StoryDotsProps>();
</script>
<template>
<Group gap="2" align="center" data-slot="story-dots">
<Inline v-for="s in steps" :key="s.id"
:class="cn('size-2 rounded-full', ((s.id === active) ? 'bg-primary' : 'bg-border'))"
data-slot="story-dot"
/>
</Group>
</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-dots// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** One dot per step of StoryTabs; the dot of the active step is filled. */
import { For, type JSX } from "solid-js";
import { Group, Inline } from "../compose";
import { cn } from "../utils";
import type { Milestone } from "../blocks/milestone-timeline.types";
import type { StoryLabels } from "../blocks/story-tabs.types";
export type StoryDotsProps = {
steps: Milestone[];
active: string;
};
export function StoryDots({ steps, active }: StoryDotsProps) {
return (
<Group gap="2" align="center" data-slot="story-dots">
<For each={steps ?? []}>{(s) => (
<Inline
class={cn("size-2 rounded-full", ((s.id === active) ? "bg-primary" : "bg-border"))}
data-slot="story-dot"
/>
)}</For>
</Group>
);
}
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-dots// 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-dots.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"
)
// StoryDotsProps are the props of StoryDots; the values are the JSON shapes of the TypeScript props.
type StoryDotsProps struct {
Steps any `json:"steps"`
Active any `json:"active"`
}
// One dot per step of StoryTabs; the dot of the active step is filled.
templ StoryDots(p StoryDotsProps) {
{{ vSteps := p.Steps }}
{{ vActive := p.Active }}
@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "story-dots")}}) {
for _, vS := range uiutils.L(vSteps) {
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: uiutils.S(uiutils.Cnv("size-2 rounded-full", uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vS, "id"), vActive)), "bg-primary", "bg-border"))), Attrs: uiutils.Attrs("data-slot", "story-dot")}})
}
}
}
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-dots{#- 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-dots.json
One dot per step of StoryTabs; the dot of the active step is filled.
Props (p): steps, active. -#}
{%- set v_steps = (p.steps ?? null) -%}
{%- set v_active = (p.active ?? null) -%}
{%- set c_1 -%}
{%- for v_s in og_l(v_steps) %}
{{ include('compose/Inline.html.twig', {'class': og_s(og_cnv(['size-2 rounded-full', (og_t(og_eq(og_get(v_s, ['id']), v_active)) ? 'bg-primary' : 'bg-border')])), 'attrs': og_attrs(['data-slot', 'story-dot'])}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'attrs': og_attrs(['data-slot', 'story-dots']), 'children': c_1}, 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-dots{* 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-dots.json
One dot per step of StoryTabs; the dot of the active step is filled.
Props (p): steps, active. *}
{var $v_steps = ($p['steps'] ?? null)}
{var $v_active = ($p['active'] ?? null)}
{capture $c_1}
{foreach og_l($v_steps) as $v_s}
{=og_include('compose/Inline.latte', ['class' => og_s(og_cnv(['size-2 rounded-full', (og_t(og_eq(og_get($v_s, ['id']), $v_active)) ? 'bg-primary' : 'bg-border')])), 'attrs' => og_attrs(['data-slot', 'story-dot'])])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'attrs' => og_attrs(['data-slot', 'story-dots']), 'children' => (string) $c_1])|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-dots{#- 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-dots.json
One dot per step of StoryTabs; the dot of the active step is filled.
Props (p): steps, active. -#}
{%- set v_steps = og_def(p['steps'], none) -%}
{%- set v_active = og_def(p['active'], none) -%}
{%- set c_1 -%}
{%- for v_s in og_l(v_steps) %}
{{ og_include('compose/inline.html.j2', {'p': {'Class': og_s(og_cnv(['size-2 rounded-full', ('bg-primary' if og_t(og_eq(og_get(v_s, ['id']), v_active)) else 'bg-border')])), 'Attrs': og_attrs(['data-slot', 'story-dot'])}}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Attrs': og_attrs(['data-slot', 'story-dots'])}, 'children': c_1}) }}
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.
One dot per step of StoryTabs; the dot of the active step is filled.
| Prop | Type | Default | Description |
|---|---|---|---|
| steps (required) | Milestone[] | - | |
| active (required) | string | - |