Skip to content
ui8kit

component / components

Story Dots

Story Dots component

Install

npx ui8kit add story-dots

Pulls 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-cdn
npx ui8kit add story-dots
components/story-dots.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. -->
<!-- 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>

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 story-dots
components/story-dots.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.
/** 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>
  );
}

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 story-dots
components/story-dots.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. -->
<!-- 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>

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 story-dots
components/story-dots.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.
/** 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>
  );
}

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 story-dots
blocks/story-dots.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/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")}})
		}
	}
}

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 story-dots
blocks/story-dots.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/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) }}

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 story-dots
blocks/story-dots.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/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}

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 story-dots
blocks/story-dots.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/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}) }}

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.

One dot per step of StoryTabs; the dot of the active step is filled.

Props of StoryDots
PropTypeDefault Description
steps (required)Milestone[]-
active (required)string-

Used in