number-input.stories.ts


Overview

The number-input.stories.ts file defines Storybook stories for the NumberInput React component. Storybook is a tool for building UI components and pages in isolation, which helps in developing, testing, and documenting components.

This file serves several purposes:


Detailed Explanation

Top-Level Metadata (meta)

Usage Example:

import NumberInput from '@/components/originui/number-input';

const meta: Meta<typeof NumberInput> = {
  title: 'Example/NumberInput',
  component: NumberInput,
  // ... other configurations
};
export default meta;

Stories

Each story defines a particular state or configuration of the NumberInput component with its arguments (args) and documentation (parameters.docs.description.story). They also include tags to categorize them as development stories (['!dev']).


1. Default

<NumberInput
  value={0}
  onChange={(value) => console.log('Value changed:', value)}
/>

2. WithInitialValue

<NumberInput
  value={10}
  onChange={(value) => console.log('Value changed:', value)}
/>

3. CustomHeight

<NumberInput
  value={5}
  height="60px"
  onChange={(value) => console.log('Value changed:', value)}
/>

4. WithCustomClass

<NumberInput
  value={3}
  className="border-blue-500 bg-blue-50"
  onChange={(value) => console.log('Value changed:', value)}
/>

Important Implementation Details


Interaction with Other Parts of the System


Mermaid Diagram - Storybook Story Structure

classDiagram
    class Meta {
        +title: string
        +component: React.ComponentType
        +parameters: object
        +tags: string[]
        +argTypes: object
        +args: object
    }

    class Story {
        +args: object
        +parameters: object
        +tags: string[]
    }

    Meta <|-- Default : extends
    Meta <|-- WithInitialValue : extends
    Meta <|-- CustomHeight : extends
    Meta <|-- WithCustomClass : extends

Summary

The number-input.stories.ts file is a Storybook configuration file that documents and demonstrates the NumberInput component through multiple interactive stories. It provides rich documentation, interactive controls, and action logging to facilitate easy development, testing, and understanding of the component's capabilities and configurations in isolation from the main application.