import React from 'react';
import Button from '../button';
import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
import SlidingPanel, { type SlidingPanelProps } from './SlidingPanel';

export default {
  component: SlidingPanel,
  title: 'Dialogs/SlidingPanel',
  argTypes: {
    position: {
      control: 'select',
      options: ['left', 'right', 'top', 'bottom'],
    },
  },
  parameters: {
    docs: {
      source: { type: 'code' },
    },
  },
  decorators: [
    (Story: any) => (
      <div style={{ paddingTop: '80px' }}>
        <Story />
      </div>
    ),
  ],
};

export const Sandbox = createSandboxStory({
  code: `const App = () => {
  const [open, setOpen] = React.useState(false);

  return (
    <div>
      <Button v2 onClick={() => setOpen(!open)}>Toggle Sliding Panel</Button>
      <SlidingPanel open={open} position="top">
        <div className="p-y-4 p-x-4">
          Panel content slides in from the chosen position.
        </div>
      </SlidingPanel>
    </div>
  );
};`,
  scope: globalScope,
});

export const Basic = function Render(args: SlidingPanelProps) {
  const [open, setOpen] = React.useState(false);

  return (
    <div>
      <Button v2 block onClick={() => setOpen(!open)}>
        Open Sliding Panel
      </Button>

      <SlidingPanel {...args} open={open}>
        <div className="p-y-4 p-x-4 ">
          Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
          been the industry standard dummy text ever since the 1500s, when an unknown printer took a
          galley of type and scrambled it to
        </div>
      </SlidingPanel>
    </div>
  );
};
Basic.args = {
  position: 'top',
};
