2023-03-23 14:36:09 +01:00
|
|
|
import React, { useState } from 'react';
|
2023-08-01 23:39:08 +02:00
|
|
|
import { StoryFn, Meta } from '@storybook/react';
|
2023-03-23 14:36:09 +01:00
|
|
|
|
|
|
|
import { ModalOverlay } from './modal-overlay';
|
|
|
|
|
|
|
|
import README from './README.mdx';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Components/ComponentLibrary/ModalOverlay',
|
|
|
|
component: ModalOverlay,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
className: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
onClick: {
|
|
|
|
action: 'onClick',
|
|
|
|
},
|
|
|
|
},
|
2023-08-01 23:39:08 +02:00
|
|
|
} as Meta<typeof ModalOverlay>;
|
2023-03-23 14:36:09 +01:00
|
|
|
|
2023-08-01 23:39:08 +02:00
|
|
|
const Template: StoryFn<typeof ModalOverlay> = (args) => (
|
2023-03-23 14:36:09 +01:00
|
|
|
<ModalOverlay {...args} />
|
|
|
|
);
|
|
|
|
|
|
|
|
export const DefaultStory = Template.bind({});
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2023-08-01 23:39:08 +02:00
|
|
|
export const OnClick: StoryFn<typeof ModalOverlay> = (args) => {
|
2023-03-23 14:36:09 +01:00
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
const handleOnClick = () => {
|
|
|
|
setOpen(!open);
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<button onClick={handleOnClick}>Show modal overlay</button>
|
|
|
|
{open && <ModalOverlay {...args} onClick={handleOnClick} />}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|