import { useEffect, useRef, useState } from 'react' import { type Meta, type StoryFn, type StoryObj } from '@storybook/react' import { isBoolean } from '~/src/utils/type' import { Button } from '~/src/components/Button' import { Overlay } from './Overlay' import type { OverlayProps } from './Overlay.types' const meta: Meta = { component: Overlay, argTypes: { position: { control: { type: 'radio', }, options: [ 'top-center', 'top-left', 'top-right', 'right-center', 'right-top', 'right-bottom', 'bottom-center', 'bottom-left', 'bottom-right', 'left-center', 'left-top', 'left-bottom', 'inner-left-top', 'inner-left-bottom', 'inner-right-top', 'inner-right-bottom', ], }, marginX: { control: { type: 'range', min: -200, max: 200, step: 1, }, }, marginY: { control: { type: 'range', min: -200, max: 200, step: 1, }, }, }, } const Template: StoryFn = ({ show: showProp, children, ...rest }) => { const [show, setShow] = useState(false) const containerRef = useRef(null) const targetRef = useRef(null) useEffect( function syncShow() { if (isBoolean(showProp)) { setShow(showProp) } }, [showProp] ) return (
) } export const Primary: StoryObj = { render: Template, args: { show: false, position: 'bottom-center', marginY: 6, }, } export default meta