CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-kadira--storybook

React Storybook: Isolate React Component Development with Hot Reloading.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

story-management.mddocs/

Story Management

Core functionality for creating and organizing component stories. Stories are individual states of components that can be developed and tested in isolation with hot reloading support.

Capabilities

Stories Of

Creates a story collection for a specific component kind, providing a chainable interface for adding individual stories.

/**
 * Creates a story collection for a specific component kind
 * @param kind - The name/category for the component stories
 * @param module - Optional webpack module for hot reloading support
 * @returns Story object with chaining methods
 */
function storiesOf(kind: string, module?: any): Story;

Usage Examples:

import { storiesOf } from '@kadira/storybook';
import Button from '../src/Button';

// Basic story collection
storiesOf('Button', module)
  .add('default', () => <Button>Default</Button>)
  .add('primary', () => <Button primary>Primary</Button>);

// With hot module replacement
storiesOf('Components/Button', module)
  .add('small', () => <Button size="small">Small Button</Button>)
  .add('large', () => <Button size="large">Large Button</Button>);

Add Story

Adds an individual story to a story collection, representing a specific state or variation of the component.

/**
 * Adds an individual story to the collection
 * @param storyName - Name for the story variation
 * @param storyFunction - Function returning the component JSX
 * @returns Story object for method chaining
 */
add(storyName: string, storyFunction: Function): Story;

Usage Examples:

storiesOf('Input', module)
  .add('empty', () => <Input placeholder="Enter text..." />)
  .add('with value', () => <Input value="Hello World" />)
  .add('disabled', () => <Input disabled value="Disabled input" />);

// With actions and props
storiesOf('Form Elements', module)
  .add('interactive input', () => (
    <Input 
      onChange={action('input-changed')}
      onFocus={action('input-focused')}
      placeholder="Type something..."
    />
  ));

Get Storybook

Returns all registered stories in a structured format, useful for programmatic access to the story data.

/**
 * Returns all registered stories in structured format
 * @returns Array of story kinds with their individual stories
 */
function getStorybook(): Array<{
  kind: string;
  stories: Array<{
    name: string;
    render: Function;
  }>;
}>;

Usage Examples:

import { getStorybook } from '@kadira/storybook';

// Get all stories programmatically
const allStories = getStorybook();

// Access story structure
allStories.forEach(storyKind => {
  console.log(`Kind: ${storyKind.kind}`);
  storyKind.stories.forEach(story => {
    console.log(`  Story: ${story.name}`);
    // story.render() returns the component JSX
  });
});

// Example output structure:
// [
//   {
//     kind: "Button",
//     stories: [
//       { name: "default", render: Function },
//       { name: "primary", render: Function }
//     ]
//   }
// ]

Types

interface StoryDecorator {
  /**
   * Decorator function that wraps story components
   * @param story - Function that returns the story component
   * @param context - Story context information
   * @returns JSX element wrapping the story
   */
  (story: Function, context: {kind: string, story: string}): Object;
}

interface Story {
  /** Add a story to this collection */
  add(storyName: string, storyFunction: Function): Story;
  /** Add a decorator to all stories in this collection */
  addDecorator(decorator: StoryDecorator): Story;
  /** The kind/category name for this story collection */
  kind: string;
}

interface StoryData {
  /** Category name for the story group */
  kind: string;
  /** Array of individual stories in this category */
  stories: Array<{
    /** Name of the individual story */
    name: string;
    /** Function that renders the story component */
    render: Function;
  }>;
}

docs

actions-links.md

addons.md

cli-commands.md

configuration.md

decorators.md

index.md

story-management.md

tile.json