|
1 | 1 | import 'react-app-polyfill/ie11'; |
2 | 2 | import * as React from 'react'; |
3 | 3 | import * as ReactDOM from 'react-dom'; |
4 | | -import { ModalProvider, Modal, useModal } from '../dist/index'; |
| 4 | +import { ModalProvider, ModalTransition } from '../dist/index'; |
5 | 5 | import '../dist/styles.css'; |
6 | 6 | import './styles.css'; |
7 | | - |
8 | | -const ModalContent = ({ onCloseClicked }) => { |
9 | | - const { isModalOpen, openModal, closeModal } = useModal(); |
10 | | - const [toggle, setToggle] = React.useState(false); |
11 | | - |
12 | | - return ( |
13 | | - <> |
14 | | - <div>This modal can be closed by clicking the close button below.</div> |
15 | | - <button |
16 | | - className="p-3 bg-red-500 text-white rounded mt-4 mr-4" |
17 | | - onClick={onCloseClicked} |
18 | | - > |
19 | | - Close this modal |
20 | | - </button> |
21 | | - <Modal |
22 | | - id="2" |
23 | | - content={<p>This modal can be closed by clicking the backdrop.</p>} |
24 | | - isOpen={isModalOpen} |
25 | | - onBackdropClick={closeModal} |
26 | | - /> |
27 | | - <div className="mt-8"> |
28 | | - Open another modal which will appear stacked on top of the current |
29 | | - modal. |
30 | | - </div> |
31 | | - <button |
32 | | - className="p-3 bg-blue-500 text-white rounded mt-4" |
33 | | - onClick={openModal} |
34 | | - > |
35 | | - Open next modal |
36 | | - </button> |
37 | | - <div className="mt-8"> |
38 | | - Toggle some long content to see how react-simple-hook-modal behaves. |
39 | | - </div> |
40 | | - <button |
41 | | - className="p-3 bg-blue-700 text-white rounded mt-4" |
42 | | - onClick={() => setToggle(prev => !prev)} |
43 | | - > |
44 | | - Toggle long content |
45 | | - </button> |
46 | | - {toggle ? ( |
47 | | - <div className="mt-4"> |
48 | | - {[...Array(30)].map((e, i) => ( |
49 | | - <p key={i} className="mb-2"> |
50 | | - Are you using react-simple-hook-modal yet? |
51 | | - </p> |
52 | | - ))} |
53 | | - </div> |
54 | | - ) : null} |
55 | | - </> |
56 | | - ); |
57 | | -}; |
58 | | - |
59 | | -const Component = () => { |
60 | | - const { isModalOpen, openModal, closeModal } = useModal(); |
61 | | - |
62 | | - return ( |
63 | | - <div className="p-8"> |
64 | | - <h1 className="mb-4 text-2xl">React Simple Modal Example</h1> |
65 | | - <a |
66 | | - className="block mb-4 hover:text-blue-700" |
67 | | - href="https://github.com/mbrookson/react-simple-hook-modal" |
68 | | - > |
69 | | - https://github.com/mbrookson/react-simple-hook-modal |
70 | | - </a> |
71 | | - <button |
72 | | - className="p-3 bg-blue-500 text-white rounded" |
73 | | - onClick={openModal} |
74 | | - > |
75 | | - Open modal |
76 | | - </button> |
77 | | - <Modal |
78 | | - id="1" |
79 | | - content={<ModalContent onCloseClicked={closeModal} />} |
80 | | - isOpen={isModalOpen} |
81 | | - /> |
82 | | - </div> |
83 | | - ); |
84 | | -}; |
| 7 | +import { Header } from './src/Header'; |
| 8 | +import { Example } from './src/Example'; |
| 9 | +import { TransitionSelect } from './src/TransitionSelect'; |
85 | 10 |
|
86 | 11 | const App = () => { |
| 12 | + const [transition, setTransition] = React.useState(ModalTransition.SCALE); |
| 13 | + |
87 | 14 | return ( |
88 | 15 | <ModalProvider> |
89 | | - <Component /> |
| 16 | + <Header /> |
| 17 | + <Example transition={transition} /> |
| 18 | + <TransitionSelect value={transition} onChange={setTransition} /> |
90 | 19 | </ModalProvider> |
91 | 20 | ); |
92 | 21 | }; |
|
0 commit comments