diff --git a/web/.storybook/preview.ts b/web/.storybook/preview.ts index 67dfee662..07fc69ec7 100644 --- a/web/.storybook/preview.ts +++ b/web/.storybook/preview.ts @@ -1,3 +1,4 @@ +import '@/locales/config'; import type { Preview } from '@storybook/react-webpack5'; import { createElement } from 'react'; import { TooltipProvider } from '../src/components/ui/tooltip'; diff --git a/web/src/base.ts b/web/src/base.ts deleted file mode 100644 index b453ca483..000000000 --- a/web/src/base.ts +++ /dev/null @@ -1,48 +0,0 @@ -import isObject from 'lodash/isObject'; -import { DvaModel } from 'umi'; -import { BaseState } from './interfaces/common'; - -type State = Record; -type DvaModelKey = keyof DvaModel; - -export const modelExtend = ( - baseModel: Partial>, - extendModel: DvaModel, -): DvaModel => { - return Object.keys(extendModel).reduce>((pre, cur) => { - const baseValue = baseModel[cur as DvaModelKey]; - const value = extendModel[cur as DvaModelKey]; - - if (isObject(value) && isObject(baseValue) && typeof value !== 'string') { - const key = cur as Exclude, 'namespace'>; - - pre[key] = { - ...baseValue, - ...value, - } as any; - } else { - pre[cur as DvaModelKey] = value as any; - } - - return pre; - }, {} as DvaModel); -}; - -export const paginationModel: Partial> = { - state: { - searchString: '', - pagination: { - total: 0, - current: 1, - pageSize: 10, - }, - }, - reducers: { - setSearchString(state, { payload }) { - return { ...state, searchString: payload }; - }, - setPagination(state, { payload }) { - return { ...state, pagination: { ...state.pagination, ...payload } }; - }, - }, -}; diff --git a/web/src/stories/avatar-upload.stories.ts b/web/src/stories/avatar-upload.stories.ts index e50156ace..7bfc07d0b 100644 --- a/web/src/stories/avatar-upload.stories.ts +++ b/web/src/stories/avatar-upload.stories.ts @@ -41,7 +41,6 @@ function MyComponent() { \`\`\` ### Features -- Supports image upload with drag & drop - Image preview with hover effects - Remove button to clear selected image - Base64 encoding for easy handling diff --git a/web/src/stories/button.css b/web/src/stories/button.css deleted file mode 100644 index 4e3620b0d..000000000 --- a/web/src/stories/button.css +++ /dev/null @@ -1,30 +0,0 @@ -.storybook-button { - display: inline-block; - cursor: pointer; - border: 0; - border-radius: 3em; - font-weight: 700; - line-height: 1; - font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} -.storybook-button--primary { - background-color: #555ab9; - color: white; -} -.storybook-button--secondary { - box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset; - background-color: transparent; - color: #333; -} -.storybook-button--small { - padding: 10px 16px; - font-size: 12px; -} -.storybook-button--medium { - padding: 11px 20px; - font-size: 14px; -} -.storybook-button--large { - padding: 12px 24px; - font-size: 16px; -} diff --git a/web/src/stories/button.stories.ts b/web/src/stories/button.stories.ts deleted file mode 100644 index 298f5378a..000000000 --- a/web/src/stories/button.stories.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react-webpack5'; - -import { fn } from 'storybook/test'; - -import { Button } from './button'; - -// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export -const meta = { - title: 'Example/Button', - component: Button, - parameters: { - // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout - layout: 'centered', - }, - // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs - tags: ['autodocs'], - // More on argTypes: https://storybook.js.org/docs/api/argtypes - argTypes: { - backgroundColor: { control: 'color' }, - }, - // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args - args: { onClick: fn() }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -export const Primary: Story = { - args: { - primary: true, - label: 'Button', - }, -}; - -export const Secondary: Story = { - args: { - label: 'Button', - }, -}; - -export const Large: Story = { - args: { - size: 'large', - label: 'Button', - }, -}; - -export const Small: Story = { - args: { - size: 'small', - label: 'Button', - }, -}; diff --git a/web/src/stories/button.tsx b/web/src/stories/button.tsx deleted file mode 100644 index aceb67c36..000000000 --- a/web/src/stories/button.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import './button.css'; - -export interface ButtonProps { - /** Is this the principal call to action on the page? */ - primary?: boolean; - /** What background color to use */ - backgroundColor?: string; - /** How large should the button be? */ - size?: 'small' | 'medium' | 'large'; - /** Button contents */ - label: string; - /** Optional click handler */ - onClick?: () => void; -} - -/** Primary UI component for user interaction */ -export const Button = ({ - primary = false, - size = 'medium', - backgroundColor, - label, - ...props -}: ButtonProps) => { - const mode = primary - ? 'storybook-button--primary' - : 'storybook-button--secondary'; - return ( - - ); -}; diff --git a/web/src/stories/configure.mdx b/web/src/stories/configure.mdx deleted file mode 100644 index dca091c16..000000000 --- a/web/src/stories/configure.mdx +++ /dev/null @@ -1,364 +0,0 @@ -import { Meta } from "@storybook/addon-docs/blocks"; - -import Github from "./assets/github.svg"; -import Discord from "./assets/discord.svg"; -import Youtube from "./assets/youtube.svg"; -import Tutorials from "./assets/tutorials.svg"; -import Styling from "./assets/styling.png"; -import Context from "./assets/context.png"; -import Assets from "./assets/assets.png"; -import Docs from "./assets/docs.png"; -import Share from "./assets/share.png"; -import FigmaPlugin from "./assets/figma-plugin.png"; -import Testing from "./assets/testing.png"; -import Accessibility from "./assets/accessibility.png"; -import Theming from "./assets/theming.png"; -import AddonLibrary from "./assets/addon-library.png"; - -export const RightArrow = () => - - - - - -
-
- # Configure your project - - Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community. -
-
-
- A wall of logos representing different styling technologies -

Add styling and CSS

-

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

- Learn more -
-
- An abstraction representing the composition of data for a component -

Provide context and mocking

-

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

- Learn more -
-
- A representation of typography and image assets -
-

Load assets and resources

-

To link static files (like fonts) to your projects and stories, use the - `staticDirs` configuration option to specify folders to load when - starting Storybook.

- Learn more -
-
-
-
-
-
- # Do more with Storybook - - Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs. -
- -
-
-
- A screenshot showing the autodocs tag being set, pointing a docs page being generated -

Autodocs

-

Auto-generate living, - interactive reference documentation from your components and stories.

- Learn more -
-
- A browser window showing a Storybook being published to a chromatic.com URL -

Publish to Chromatic

-

Publish your Storybook to review and collaborate with your entire team.

- Learn more -
-
- Windows showing the Storybook plugin in Figma -

Figma Plugin

-

Embed your stories into Figma to cross-reference the design and live - implementation in one place.

- Learn more -
-
- Screenshot of tests passing and failing -

Testing

-

Use stories to test a component in all its variations, no matter how - complex.

- Learn more -
-
- Screenshot of accessibility tests passing and failing -

Accessibility

-

Automatically test your components for a11y issues as you develop.

- Learn more -
-
- Screenshot of Storybook in light and dark mode -

Theming

-

Theme Storybook's UI to personalize it to your project.

- Learn more -
-
-
-
-
-
-

Addons

-

Integrate your tools with Storybook to connect workflows.

- Discover all addons -
-
- Integrate your tools with Storybook to connect workflows. -
-
- -
-
- Github logo - Join our contributors building the future of UI development. - - Star on GitHub -
-
- Discord logo -
- Get support and chat with frontend developers. - - Join Discord server -
-
-
- Youtube logo -
- Watch tutorials, feature previews and interviews. - - Watch on YouTube -
-
-
- A book -

Follow guided walkthroughs on for key workflows.

- - Discover tutorials -
-
- - diff --git a/web/src/stories/header.css b/web/src/stories/header.css deleted file mode 100644 index 5efd46c26..000000000 --- a/web/src/stories/header.css +++ /dev/null @@ -1,32 +0,0 @@ -.storybook-header { - display: flex; - justify-content: space-between; - align-items: center; - border-bottom: 1px solid rgba(0, 0, 0, 0.1); - padding: 15px 20px; - font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -.storybook-header svg { - display: inline-block; - vertical-align: top; -} - -.storybook-header h1 { - display: inline-block; - vertical-align: top; - margin: 6px 0 6px 10px; - font-weight: 700; - font-size: 20px; - line-height: 1; -} - -.storybook-header button + button { - margin-left: 10px; -} - -.storybook-header .welcome { - margin-right: 10px; - color: #333; - font-size: 14px; -} diff --git a/web/src/stories/header.stories.ts b/web/src/stories/header.stories.ts deleted file mode 100644 index 76224ef01..000000000 --- a/web/src/stories/header.stories.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react-webpack5'; - -import { fn } from 'storybook/test'; - -import { Header } from './header'; - -const meta = { - title: 'Example/Header', - component: Header, - // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs - tags: ['autodocs'], - parameters: { - // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout - layout: 'fullscreen', - }, - args: { - onLogin: fn(), - onLogout: fn(), - onCreateAccount: fn(), - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -export const LoggedIn: Story = { - args: { - user: { - name: 'Jane Doe', - }, - }, -}; - -export const LoggedOut: Story = {}; diff --git a/web/src/stories/header.tsx b/web/src/stories/header.tsx deleted file mode 100644 index 64dc234e0..000000000 --- a/web/src/stories/header.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Button } from './button'; -import './header.css'; - -type User = { - name: string; -}; - -export interface HeaderProps { - user?: User; - onLogin?: () => void; - onLogout?: () => void; - onCreateAccount?: () => void; -} - -export const Header = ({ - user, - onLogin, - onLogout, - onCreateAccount, -}: HeaderProps) => ( -
-
-
- - - - - - - -

Acme

-
-
- {user ? ( - <> - - Welcome, {user.name}! - -
-
-
-); diff --git a/web/src/stories/number-input.stories.ts b/web/src/stories/number-input.stories.ts new file mode 100644 index 000000000..e892cec84 --- /dev/null +++ b/web/src/stories/number-input.stories.ts @@ -0,0 +1,184 @@ +import type { Meta, StoryObj } from '@storybook/react-webpack5'; + +import { fn } from 'storybook/test'; + +import NumberInput from '@/components/originui/number-input'; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta = { + title: 'Example/NumberInput', + component: NumberInput, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: 'centered', + docs: { + description: { + component: ` +## NumberInput Component + +NumberInput is a numeric input component with increment/decrement buttons. It provides a user-friendly interface for entering numeric values with built-in validation and keyboard controls. + +### Import Path +\`\`\`typescript +import NumberInput from '@/components/originui/number-input'; +\`\`\` + +### Basic Usage +\`\`\`tsx +import { useState } from 'react'; +import NumberInput from '@/components/originui/number-input'; + +function MyComponent() { + const [value, setValue] = useState(0); + + return ( + setValue(newValue)} + /> + ); +} +\`\`\` + +### Features +- Increment/decrement buttons for easy value adjustment +- Keyboard input validation (only allows numeric input) +- Customizable height and styling +- Non-negative number validation +- Responsive design with Tailwind CSS + `, + }, + }, + }, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], + // More on argTypes: https://storybook.js.org/docs/api/argtypes + argTypes: { + value: { + description: 'The current numeric value', + control: { type: 'number' }, + }, + onChange: { + description: 'Callback function called when value changes', + control: false, + }, + height: { + description: 'Custom height for the input component', + control: { type: 'text' }, + }, + className: { + description: 'Additional CSS classes for styling', + control: { type: 'text' }, + }, + }, + // Use `fn` to spy on the onChange arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args + args: { onChange: fn() }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const Default: Story = { + args: { + value: 0, + }, + parameters: { + docs: { + description: { + story: ` +### Default Number Input + +Shows the basic number input with default styling and zero value. + +\`\`\`tsx + console.log('Value changed:', value)} +/> +\`\`\` + `, + }, + }, + }, + tags: ['!dev'], +}; + +export const WithInitialValue: Story = { + args: { + value: 10, + }, + parameters: { + docs: { + description: { + story: ` +### With Initial Value + +Shows the number input with a predefined initial value. + +\`\`\`tsx + console.log('Value changed:', value)} +/> +\`\`\` + `, + }, + }, + }, + tags: ['!dev'], +}; + +export const CustomHeight: Story = { + args: { + value: 5, + height: '60px', + }, + parameters: { + docs: { + description: { + story: ` +### Custom Height + +Shows the number input with custom height styling. + +\`\`\`tsx + console.log('Value changed:', value)} +/> +\`\`\` + `, + }, + }, + }, + tags: ['!dev'], +}; + +export const WithCustomClass: Story = { + args: { + value: 3, + className: 'border-blue-500 bg-blue-50', + }, + parameters: { + docs: { + description: { + story: ` +### With Custom Styling + +Shows the number input with custom CSS classes for styling. + +\`\`\`tsx + console.log('Value changed:', value)} +/> +\`\`\` + `, + }, + }, + }, + tags: ['!dev'], +}; diff --git a/web/src/stories/page.css b/web/src/stories/page.css deleted file mode 100644 index 77c81d2d5..000000000 --- a/web/src/stories/page.css +++ /dev/null @@ -1,68 +0,0 @@ -.storybook-page { - margin: 0 auto; - padding: 48px 20px; - max-width: 600px; - color: #333; - font-size: 14px; - line-height: 24px; - font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; -} - -.storybook-page h2 { - display: inline-block; - vertical-align: top; - margin: 0 0 4px; - font-weight: 700; - font-size: 32px; - line-height: 1; -} - -.storybook-page p { - margin: 1em 0; -} - -.storybook-page a { - color: inherit; -} - -.storybook-page ul { - margin: 1em 0; - padding-left: 30px; -} - -.storybook-page li { - margin-bottom: 8px; -} - -.storybook-page .tip { - display: inline-block; - vertical-align: top; - margin-right: 10px; - border-radius: 1em; - background: #e7fdd8; - padding: 4px 12px; - color: #357a14; - font-weight: 700; - font-size: 11px; - line-height: 12px; -} - -.storybook-page .tip-wrapper { - margin-top: 40px; - margin-bottom: 40px; - font-size: 13px; - line-height: 20px; -} - -.storybook-page .tip-wrapper svg { - display: inline-block; - vertical-align: top; - margin-top: 3px; - margin-right: 4px; - width: 12px; - height: 12px; -} - -.storybook-page .tip-wrapper svg path { - fill: #1ea7fd; -} diff --git a/web/src/stories/page.stories.ts b/web/src/stories/page.stories.ts deleted file mode 100644 index 7dc5f3c93..000000000 --- a/web/src/stories/page.stories.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react-webpack5'; - -import { expect, userEvent, within } from 'storybook/test'; - -import { Page } from './page'; - -const meta = { - title: 'Example/Page', - component: Page, - parameters: { - // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout - layout: 'fullscreen', - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -export const LoggedOut: Story = {}; - -// More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing -export const LoggedIn: Story = { - play: async ({ canvasElement }) => { - const canvas = within(canvasElement); - const loginButton = canvas.getByRole('button', { name: /Log in/i }); - await expect(loginButton).toBeInTheDocument(); - await userEvent.click(loginButton); - await expect(loginButton).not.toBeInTheDocument(); - - const logoutButton = canvas.getByRole('button', { name: /Log out/i }); - await expect(logoutButton).toBeInTheDocument(); - }, -}; diff --git a/web/src/stories/page.tsx b/web/src/stories/page.tsx deleted file mode 100644 index 963b7f04b..000000000 --- a/web/src/stories/page.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import React from 'react'; - -import { Header } from './header'; -import './page.css'; - -type User = { - name: string; -}; - -export const Page: React.FC = () => { - const [user, setUser] = React.useState(); - - return ( -
-
setUser({ name: 'Jane Doe' })} - onLogout={() => setUser(undefined)} - onCreateAccount={() => setUser({ name: 'Jane Doe' })} - /> - -
-

Pages in Storybook

-

- We recommend building UIs with a{' '} - - component-driven - {' '} - process starting with atomic components and ending with pages. -

-

- Render pages with mock data. This makes it easy to build and review - page states without needing to navigate to them in your app. Here are - some handy patterns for managing page data in Storybook: -

-
    -
  • - Use a higher-level connected component. Storybook helps you compose - such data from the "args" of child component stories -
  • -
  • - Assemble data in the page component from your services. You can mock - these services out using Storybook. -
  • -
-

- Get a guided tutorial on component-driven development at{' '} - - Storybook tutorials - - . Read more in the{' '} - - docs - - . -

-
- Tip Adjust the width of the canvas with - the{' '} - - - - - - Viewports addon in the toolbar -
-
-
- ); -}; diff --git a/web/src/stories/rename-dialog.stories.tsx b/web/src/stories/rename-dialog.stories.tsx new file mode 100644 index 000000000..572ecad0d --- /dev/null +++ b/web/src/stories/rename-dialog.stories.tsx @@ -0,0 +1,258 @@ +import type { Meta, StoryObj } from '@storybook/react-webpack5'; +import { useState } from 'react'; +import { fn } from 'storybook/test'; + +import { RenameDialog } from '@/components/rename-dialog'; +import { Button } from '@/components/ui/button'; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta = { + title: 'Example/RenameDialog', + component: RenameDialog, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: 'centered', + docs: { + description: { + component: ` +## Component Description + +RenameDialog is a modal dialog component for renaming items. It provides a form with input validation and loading states, commonly used in chat applications for renaming conversations or creating new ones. + +### Features +- Modal dialog with form input +- Loading state support +- Customizable title +- Initial name pre-filling +- Form validation and submission + +### Import Path +\`\`\`tsx +import { RenameDialog } from '@/components/rename-dialog'; +\`\`\` + +### Basic Usage +\`\`\`tsx +import { RenameDialog } from '@/components/rename-dialog'; +import { Button } from '@/components/ui/button'; +import { useState } from 'react'; + +function MyComponent() { + const [visible, setVisible] = useState(false); + const [loading, setLoading] = useState(false); + + return ( +
+ + {visible && ( + setVisible(false)} + onOk={async (name) => { + setLoading(true); + // Handle save logic + console.log('New name:', name); + setLoading(false); + setVisible(false); + }} + initialName="" + loading={loading} + /> + )} +
+ ); +} +\`\`\` + `, + }, + }, + }, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], + // More on argTypes: https://storybook.js.org/docs/api/argtypes + argTypes: { + initialName: { + control: 'text', + description: 'Initial name value for the input field', + }, + title: { + control: 'text', + description: 'Custom title for the dialog', + }, + loading: { + control: 'boolean', + description: 'Loading state of the save button', + }, + }, + // Use `fn` to spy on the args, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args + args: { + hideModal: fn(), + onOk: fn(), + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +// Story components to handle useState hooks +const DefaultStoryComponent = (args: any) => { + const [visible, setVisible] = useState(false); + + return ( +
+ + {visible && ( + setVisible(false)} + onOk={(name) => { + args.onOk?.(name); + setVisible(false); + }} + /> + )} +
+ ); +}; + +const WithInitialNameStoryComponent = (args: any) => { + const [visible, setVisible] = useState(false); + + return ( +
+ + {visible && ( + setVisible(false)} + onOk={(name) => { + args.onOk?.(name); + setVisible(false); + }} + /> + )} +
+ ); +}; + +const CreateNewChatStoryComponent = (args: any) => { + const [visible, setVisible] = useState(false); + + return ( +
+ + {visible && ( + setVisible(false)} + onOk={(name) => { + args.onOk?.(name); + setVisible(false); + }} + /> + )} +
+ ); +}; + +const LoadingStateStoryComponent = (args: any) => { + const [visible, setVisible] = useState(false); + + return ( +
+ + {visible && ( + setVisible(false)} + onOk={(name) => { + args.onOk?.(name); + }} + /> + )} +
+ ); +}; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const Default: Story = { + render: (args) => , + args: { + initialName: '', + loading: false, + }, + parameters: { + docs: { + description: { + story: ` +### Default Rename Dialog + +Basic rename dialog without initial name value. Click the button to open the dialog. + `, + }, + }, + }, +}; + +export const WithInitialName: Story = { + render: (args) => , + args: { + initialName: 'My Chat Session', + loading: false, + }, + parameters: { + docs: { + description: { + story: ` +### Rename Dialog with Initial Name + +Rename dialog pre-filled with an existing name for editing. Click the button to open the dialog. + `, + }, + }, + }, +}; + +export const CreateNewChat: Story = { + render: (args) => , + args: { + initialName: '', + title: 'Create Chat', + loading: false, + }, + parameters: { + docs: { + description: { + story: ` +### Create New Chat Dialog + +Dialog for creating a new chat with custom title. Click the button to open the dialog. + `, + }, + }, + }, +}; + +export const LoadingState: Story = { + render: (args) => , + args: { + initialName: 'Saving changes...', + loading: true, + }, + parameters: { + docs: { + description: { + story: ` +### Loading State + +Dialog showing loading state during save operation. The dialog remains open while loading. + `, + }, + }, + }, +}; diff --git a/web/src/stories/spin.stories.ts b/web/src/stories/spin.stories.ts new file mode 100644 index 000000000..ececf3c67 --- /dev/null +++ b/web/src/stories/spin.stories.ts @@ -0,0 +1,98 @@ +import type { Meta, StoryObj } from '@storybook/react-webpack5'; + +import { Spin } from '@/components/ui/spin'; + +// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export +const meta = { + title: 'Example/Spin', + component: Spin, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: 'centered', + docs: { + description: { + component: ` +## Spin Component + +Spin is a loading spinner component that can be used to indicate loading states. It supports different sizes and can wrap other content to create loading overlays. + +### Import Path +\`\`\`typescript +import { Spin } from '@/components/ui/spin'; +\`\`\` + +### Basic Usage +\`\`\`tsx +import { Spin } from '@/components/ui/spin'; + +function MyComponent() { + return ( + +
Your content here
+
+ ); +} +\`\`\` + +### Features +- Three different sizes: small, default, and large +- Can wrap content to create loading overlays +- Smooth animation with CSS transitions +- Customizable styling with className prop +- Built with Tailwind CSS + `, + }, + }, + }, + // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs + tags: ['autodocs'], + // More on argTypes: https://storybook.js.org/docs/api/argtypes + argTypes: { + spinning: { + description: 'Whether the spinner is active', + control: { type: 'boolean' }, + }, + size: { + description: 'Size of the spinner', + control: { type: 'select' }, + options: ['small', 'default', 'large'], + }, + className: { + description: 'Additional CSS classes for styling', + control: { type: 'text' }, + }, + children: { + description: 'Content to be wrapped by the spinner', + control: false, + }, + }, + // Use `fn` to spy on any callbacks + args: {}, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args +export const Default: Story = { + args: { + spinning: true, + size: 'default', + }, + parameters: { + docs: { + description: { + story: ` +### Default Spinner + +Shows the basic spinner with default size and active state. + +\`\`\`tsx + +\`\`\` + `, + }, + }, + }, + tags: ['!dev'], +};