2023-03-23 14:36:09 +01:00
|
|
|
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
|
|
|
|
|
|
|
import { ModalOverlay } from './modal-overlay';
|
|
|
|
|
|
|
|
# ModalOverlay
|
|
|
|
|
|
|
|
`ModalOverlay` is a transparent overlay that covers the entire screen. It is used to dim the background when a modal is open.
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="components-componentlibrary-modaloverlay--default-story" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
## Props
|
|
|
|
|
2023-08-01 23:39:08 +02:00
|
|
|
The `ModalOverlay` accepts all props below as well as all [Box](/docs/components-componentlibrary-box--docs#props) component props
|
2023-03-23 14:36:09 +01:00
|
|
|
|
|
|
|
<ArgsTable of={ModalOverlay} />
|
|
|
|
|
|
|
|
### On Click
|
|
|
|
|
|
|
|
Use the `onClick` prop to handle clicks on the overlay
|
|
|
|
|
|
|
|
<Canvas>
|
|
|
|
<Story id="components-componentlibrary-modaloverlay--on-click" />
|
|
|
|
</Canvas>
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { ModalOverlay } from '../../component-library';
|
|
|
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
const handleOnClick = () => {
|
|
|
|
setOpen(!open);
|
|
|
|
};
|
|
|
|
|
|
|
|
<button onClick={handleOnClick}>Show modal overlay</button>;
|
|
|
|
{
|
|
|
|
open && <ModalOverlay onClick={handleOnClick} />;
|
|
|
|
}
|
|
|
|
```
|