1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-11-14 17:35:35 +01:00
foris-js/src/bootstrap/Modal.md

37 lines
876 B
Markdown
Raw Normal View History

2019-08-23 15:20:22 +02:00
Bootstrap modal component.
2020-08-18 15:39:00 +02:00
it's required to have an element `<div id={"modal-container"}/>` somewhere on
the page since modals are rendered in portals.
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);
<>
2019-10-07 17:16:27 +02:00
<Modal setShown={setShown} shown={shown}>
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
```