2019-08-23 15:20:22 +02:00
|
|
|
Bootstrap modal component.
|
|
|
|
|
2020-11-20 16:54:01 +01:00
|
|
|
It's required to have an element `<div id={"modal-container"}/>` somewhere on
|
2020-08-18 15:39:00 +02:00
|
|
|
the page since modals are rendered in portals.
|
2019-10-07 17:16:27 +02:00
|
|
|
|
2020-11-20 16:54:01 +01:00
|
|
|
Modals also have three optional sizes, which can be defined through the `size`
|
|
|
|
prop:
|
|
|
|
|
|
|
|
- small - `sm`
|
|
|
|
- large - `lg`
|
|
|
|
- extra-large - `xl`
|
|
|
|
|
|
|
|
For more details please visit Bootstrap
|
|
|
|
<a href="https://getbootstrap.com/docs/4.5/components/modal/#optional-sizes" target="_blank">
|
|
|
|
documentation</a>.
|
|
|
|
|
2019-10-07 17:16:27 +02:00
|
|
|
```js
|
2020-08-18 15:39:00 +02:00
|
|
|
<div id="modal-container" />
|
2019-10-07 17:16:27 +02:00
|
|
|
```
|
|
|
|
|
2019-08-23 15:20:22 +02:00
|
|
|
```js
|
2020-08-18 15:39:00 +02:00
|
|
|
import { ModalHeader, ModalBody, ModalFooter } from "./Modal";
|
2019-08-23 15:20:22 +02:00
|
|
|
|
2020-08-18 15:39:00 +02:00
|
|
|
import { useState } from "react";
|
2019-08-23 15:20:22 +02:00
|
|
|
const [shown, setShown] = useState(false);
|
|
|
|
|
|
|
|
<>
|
2020-11-20 16:54:01 +01:00
|
|
|
<Modal setShown={setShown} shown={shown} size="sm">
|
2020-08-18 15:39:00 +02:00
|
|
|
<ModalHeader setShown={setShown} title="Warning!" />
|
|
|
|
<ModalBody>
|
|
|
|
<p>Bla bla bla...</p>
|
|
|
|
</ModalBody>
|
2019-08-23 15:20:22 +02:00
|
|
|
<ModalFooter>
|
2020-08-18 15:39:00 +02:00
|
|
|
<button
|
|
|
|
className="btn btn-secondary"
|
2019-08-23 15:20:22 +02:00
|
|
|
onClick={() => setShown(false)}
|
2020-08-18 15:39:00 +02:00
|
|
|
>
|
|
|
|
Skip it
|
|
|
|
</button>
|
2019-08-23 15:20:22 +02:00
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
2020-08-18 15:39:00 +02:00
|
|
|
|
|
|
|
<button className="btn btn-secondary" onClick={() => setShown(true)}>
|
2019-10-07 17:16:27 +02:00
|
|
|
Show modal
|
|
|
|
</button>
|
2020-08-18 15:39:00 +02:00
|
|
|
</>;
|
2019-08-23 15:20:22 +02:00
|
|
|
```
|