import type { Meta, StoryObj } from '@storybook/react'; import { action } from 'storybook/actions'; import React from 'react'; import { Panel } from '../Panel'; import { PanelSection } from '../PanelSection'; import { Callout } from '../../Callout'; import { Input } from '../../Input'; import { SnapshotContainer } from '../../../test-utils/SnapshotsContainer'; const meta: Meta = { title: 'Data display/Panel', component: Panel, args: { title: 'Panel', children:
Content
, onClose: (e) => { action('onClose')(e); }, }, }; export default meta; type Story = StoryObj; export const Default: Story = {}; export const SidePanel: Story = { args: { DO_NOT_USE_isSidePanel: true, title: 'Panel with header', header:
Header
, footer:
Footer
, children: ( <>
This is a collapsible section.
I should be at the bottom near the footer
), }, }; export const WithHeader: Story = { args: { title: 'Panel with header', header:
Header
, }, }; export const WithFooter: Story = { args: { title: 'Panel with footer', footer:
Footer
, }, }; export const WithFooterSummary: Story = { args: { title: 'Panel with footer summary', footerSummary: { isCollapsible: true, title: 'This section is a collapsible footer section', content: (
This is a collapsible footer content.
), }, }, }; export const WithFooterSummaryAndFooter: Story = { args: { title: 'Panel with footer summmary and footer', footerSummary: { isCollapsible: true, title: 'This section is a collapsible footer section', content: (
This is a collapsible footer content.
), }, footer:
Footer
, }, }; export const WithNonCollapsibleFooterAccordionAndFooter: Story = { args: { title: 'Panel with non collapsible footer', footerSummary: { isCollapsible: false, title: 'This section is a non-collapsible footer section', content: (
This is a footer summary content.
), }, footer:
Footer
, }, }; export const WithEditablePanelSection: Story = { args: { title: 'Panel with editable panel section', children: (

This section is being edited.

} cancelTranslation="Cancel" saveTranslation="Save changes" onSave={() => { action('onSave')(); }} onCancel={() => { action('onCancel')(); }} > This is an editable section
), }, }; export const WithEditablePanelSectionAndErrorHandling: Story = { args: { title: 'Panel with editable panel section and error handling', children: (

This section will throw an error when edited.

} cancelTranslation="Cancel" saveTranslation="Save changes" renderError={() => (
)} onSave={() => { throw new Error('error'); }} onCancel={() => { action('onCancel')(); }} > This is an editable section throwing an error when edited.
), }, }; export const WithEditablePanelSectionAndSaveDisabled: Story = { args: { title: 'Panel with editable panel and save disabled', children: (

This section is being edited but the save changes button is disabled.

} cancelTranslation="Cancel" saveTranslation="Save changes" disableSave onSave={() => { action('onSave')(); }} onCancel={() => { action('onCancel')(); }} > This is an editable section but the save changes button will be disabled.
), }, }; export const WithCollapsiblePanelSection: Story = { args: { title: 'Panel with collapsisble panel section', children: (
This is a collapsible section.
), }, }; /* This stories is to make sure null & components who render null do not create multiple separator */ export const WithMultiplePanelSections: Story = { render: (args) => { const ComponentRenderingNull = () => { const checkNull = true; if (checkNull) return null; return ; }; return (
This is the first section.
{null} {null}
This is the second section.
{null}
This is the third and final section.
{null}
); }, }; export const Snapshot: Story = { parameters: { chromatic: { disableSnapshot: false }, }, render: () => ( ), };