import { useState } from "react"; import { Collapse } from "./index"; import { DocsPage } from "@shared/stories/DocsTemplate"; import type { Meta, StoryObj } from "@storybook/react"; const meta: Meta = { title: "Components/Collapse", component: Collapse, tags: ["autodocs"], parameters: { layout: "centered", docs: { page: DocsPage, description: { component: "A collapsible component with smooth height and opacity transitions. Used to show/hide content with animations.", }, }, }, argTypes: { open: { control: { type: "boolean" }, description: "Whether the collapse is open", }, children: { control: { type: "text" }, description: "Content to collapse/expand", }, }, args: { open: true, children: "This is collapsible content that can be shown or hidden.", }, }; export default meta; type Story = StoryObj; // Open collapse export const Open: Story = { args: { open: true, children: (

This content is visible because the collapse is open.

), }, }; // Closed collapse export const Closed: Story = { args: { open: false, children: (

This content is hidden because the collapse is closed.

), }, }; // With content export const WithContent: Story = { args: { open: true, children: (

Collapsible Section

This collapse contains multiple elements and demonstrates how it handles different content types.

  • Item 1
  • Item 2
  • Item 3
), }, }; // Interactive collapse export const Interactive: Story = { render: () => { const [open, setOpen] = useState(false); return (

This content can be toggled by clicking the button above. The collapse animates smoothly between open and closed states.

); }, parameters: { docs: { description: { story: "Interactive collapse that can be toggled. Notice the smooth height and opacity transitions.", }, }, }, }; // Long content export const LongContent: Story = { args: { open: true, children: (

Long Content Section

This collapse demonstrates how it handles longer content. The height will adjust automatically based on the content size.

Paragraph 1: Additional content to show height adjustment.

Paragraph 2: More content to demonstrate the collapse behavior.

Paragraph 3: Even more content to show how the component adapts.

), }, }; // Transition states export const TransitionStates: Story = { render: () => { const [open, setOpen] = useState(true); return (

Watch the smooth transition as this content opens and closes. The collapse uses both height and opacity animations for a polished effect.

); }, parameters: { docs: { description: { story: "Demonstrates the smooth transition animations when opening and closing.", }, }, }, }; // All variants showcase export const AllVariants: Story = { render: () => { const [open1, setOpen1] = useState(true); const [open2, setOpen2] = useState(false); return (

Open State

This collapse is open.

Closed State

This collapse is closed.

Interactive Examples

Interactive collapse 1

Interactive collapse 2

); }, parameters: { docs: { description: { story: "Showcase of all collapse states and interactive examples.", }, }, }, };