1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00
metamask-extension/ui/components/component-library/modal-overlay
jainex d879f08763
Update ModalOverlay to use TS Box version (#20203)
* Update ModalOverlay to use TS Box version

* fix jest error

* lint error fix

* Fix lint errors and improve ModalOverlay's TypeScript typings

* Some small updates to story and docs

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-08-01 14:39:08 -07:00
..
__snapshots__ Update ModalOverlay to use TS Box version (#20203) 2023-08-01 14:39:08 -07:00
index.ts Update ModalOverlay to use TS Box version (#20203) 2023-08-01 14:39:08 -07:00
modal-overlay.scss Some style, accessibility and sematic html updates to modal sub components (#19034) 2023-05-09 14:09:10 -07:00
modal-overlay.stories.tsx Update ModalOverlay to use TS Box version (#20203) 2023-08-01 14:39:08 -07:00
modal-overlay.test.tsx Adding ModalOverlay component (#18161) 2023-03-23 06:36:09 -07:00
modal-overlay.tsx Update ModalOverlay to use TS Box version (#20203) 2023-08-01 14:39:08 -07:00
modal-overlay.types.ts Update ModalOverlay to use TS Box version (#20203) 2023-08-01 14:39:08 -07:00
README.mdx Update ModalOverlay to use TS Box version (#20203) 2023-08-01 14:39:08 -07: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

The `ModalOverlay` accepts all props below as well as all [Box](/docs/components-componentlibrary-box--docs#props) component props

<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} />;
}
```