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

48 lines
1.2 KiB
Markdown
Raw Normal View History

2019-08-23 15:20:22 +02:00
Bootstrap modal component.
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
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);
<>
<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
```