mcpField
S
storybook

storybook

github.com/exceptionless開発2.5k60 回インストール1 日前に更新
リポジトリ

storybook について

storybook は、Storybook の起動と Svelte コンポーネントのストーリー作成を支援するプロジェクト向けスキルです。ストーリーファイルの配置、メタデータやコントロールの設定、自動ドキュメント、スニペットによる構成を説明します。

主な機能

  1. 01npm スクリプトで Storybook を起動
  2. 02Svelte ストーリーをコンポーネントと同じ場所に配置
  3. 03defineMeta によるストーリー設定
  4. 04argTypes によるコントロール設定
  5. 05autodocs タグの有効化
  6. 06スニペットによるストーリー構成

活用シーン

  1. 01コンポーネントの Storybook を起動
  2. 02Svelte コンポーネントのストーリー作成
  3. 03ストーリーへのプロパティコントロール追加
  4. 04複雑なコンテンツ構成の文書化

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/exceptionless/exceptionless --skill storybook

インストール後、Claude Code で/storybookを入力して読み込まれたか確認します。

詳細

Storybook

ドキュメント: storybook.js.org

Storybook の実行

npm run storybook

ファイルの配置場所

ストーリーはコンポーネントと同じ場所に *.stories.svelte として配置します。

基本的なストーリーパターン

stack-status-badge.stories.svelte より:

<script module lang="ts">
    import { defineMeta } from '@storybook/addon-svelte-csf';

    import { StackStatus } from '../models';
    import StackStatusBadge from './stack-status-badge.svelte';

    const { Story } = defineMeta({
        argTypes: {
            status: {
                control: { type: 'select' },
                options: [StackStatus.Open, StackStatus.Fixed, StackStatus.Regressed]
            }
        },
        component: StackStatusBadge,
        tags: ['autodocs'],
        title: 'Components/Stacks/StackStatusBadge'
    });
</script>

<Story name="Open" args={{ status: StackStatus.Open }} />
<Story name="Fixed" args={{ status: StackStatus.Fixed }} />
<Story name="Regressed" args={{ status: StackStatus.Regressed }} />

スニペットを使ったストーリー

notification.stories.svelte より:

<script module lang="ts">
    import { Button } from '$comp/ui/button';
    import CheckCircle from '@lucide/svelte/icons/check-circle';
    import Ban from '@lucide/svelte/icons/ban';
    import { defineMeta } from '@storybook/addon-svelte-csf';

    import NotificationDescription from './notification-description.svelte';
    import NotificationTitle from './notification-title.svelte';
    import Notification from './notification.svelte';

    const { Story } = defineMeta({
        component: Notification,
        tags: ['autodocs'],
        title: 'Components/Shared/Notification'
    });
</script>

<Story name="Success">
    <Notification variant="success">
        {#snippet icon()}<CheckCircle />{/snippet}
        <NotificationTitle>Operation completed successfully!</NotificationTitle>
        <NotificationDescription>Your changes have been saved.</NotificationDescription>
    </Notification>
</Story>

<Story name="Destructive">
    <Notification variant="destructive">
        {#snippet icon()}<Ban />{/snippet}
        <NotificationTitle>Something went wrong</NotificationTitle>
        <NotificationDescription>An error occurred. Please try again.</NotificationDescription>
    </Notification>
</Story>

<Story name="With Action">
    <Notification variant="information">
        {#snippet action()}
            <Button variant="outline" size="sm">Take Action</Button>
        {/snippet}
        <NotificationTitle>Action required</NotificationTitle>
        <NotificationDescription>Click the button to proceed.</NotificationDescription>
    </Notification>
</Story>

主なパターン

  • defineMeta:Story コンポーネントを返します。component、title、tags を設定します
  • tags: ['autodocs']:ドキュメントページを自動生成します
  • argTypes:props のコントロール(select、text、boolean など)を設定します
  • シンプルな args:<Story name="Open" args={{ status: 'open' }} />
  • カスタムコンテンツ:複雑な構成には、スニペットを使って children を使用します
  • タイトル階層:整理するには / を使用します(例:Components/Shared/Notification)

コメント