import type { Meta, StoryObj } from '@storybook/react-vite' import React from 'react' import { DocsTemplate } from '../../../.storybook' import Popover from './Popover' import Button from '../Button/Button' import { toast } from '../Toast/Toast' const meta: Meta = { title: 'Components/Popover', component: Popover, argTypes: { children: { control: false }, popoverContent: { control: false }, onClickOutside: { control: false }, }, parameters: { design: { type: 'figma', url: 'https://www.figma.com/design/RvhKD82948FMQnh5MyCi0o/Web-Design-System?node-id=121-608&t=jsd8kEmb1sJfCa2m-0', }, docs: { page: () => ( The Popover component is a versatile UI element that enhances user interactions by providing additional content in a popover when a clickable element is activated. This component offers a clean and unobtrusive way to present supplementary information, options, or actions. } infoBullets={[ For more information about the Popover component, please see the{' '} floating-ui documentation . , Implement the Popover component when you want to display additional content, options, or actions related to a clickable element. , ]} /> ), }, }, } export default meta type Story = StoryObj const Template: Story = { render: (args) => , } const loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.' const genericProps = { children: ({ setVisible, visible, }: { setVisible: (visible: boolean) => void visible: boolean }) => , popoverContent:
{loremIpsum}
, position: 'bottom' as const, onClickOutside: () => { toast({ type: 'info', message: 'Clicked outside of the Popover', }) }, } export const Basic: Story = { ...Template, args: genericProps, } export const TopPlacement: Story = { ...Template, args: { ...genericProps, position: 'top' }, } export const BottomPlacement: Story = { ...Template, args: { ...genericProps, position: 'bottom' }, } export const LeftPlacement: Story = { ...Template, args: { ...genericProps, position: 'left' }, } export const RightPlacement: Story = { ...Template, args: { ...genericProps, position: 'right' }, } const ScrollingTemplate: Story = { render: ({ ...args }) => (
{loremIpsum}
{loremIpsum}
), } export const CloseWhenScrolling: Story = { ...ScrollingTemplate, args: { ...genericProps, }, } export const CloseWhenScrollingDisabled: Story = { ...ScrollingTemplate, args: { ...genericProps, disableCloseOnScroll: true, }, } export const CloseFromPopoverContent: Story = { ...Template, args: { ...genericProps, popoverContent: ({ setVisible }) => (
{loremIpsum}
), }, } export const WithHeader: Story = { ...Template, args: { ...genericProps, header: { headerText: 'Header Text' }, noPadding: false, }, } export const NoPadding: Story = { ...Template, args: { ...genericProps, noPadding: true, }, } export const Disabled: Story = { ...Template, args: { ...genericProps, disabled: true, position: 'bottom', }, } export const AutoPosition: Story = { ...Template, args: { ...genericProps, position: 'auto', }, }