|
| 1 | +import React, { useState } from 'react'; |
| 2 | + |
| 3 | +import { useModal } from '../../../../src/future'; |
| 4 | + |
| 5 | +const contentStyle1: React.CSSProperties = { |
| 6 | + width: '400px', |
| 7 | + padding: '10px 40px 40px', |
| 8 | + backgroundColor: '#fff', |
| 9 | + borderRadius: '10px', |
| 10 | +}; |
| 11 | +const contentStyle2: React.CSSProperties = { |
| 12 | + width: '400px', |
| 13 | + height: '100%', |
| 14 | + padding: '10px 40px 40px', |
| 15 | + boxSizing: 'border-box', |
| 16 | + backgroundColor: '#fff', |
| 17 | + borderRadius: '10px', |
| 18 | +}; |
| 19 | +const dialogStyle2: React.CSSProperties = { |
| 20 | + justifyContent: 'flex-end', |
| 21 | +}; |
| 22 | + |
| 23 | +export const Modal = () => { |
| 24 | + const [Modal1, open1, close1, isOpen1] = useModal(); |
| 25 | + const [Modal2, open2, close2] = useModal(); |
| 26 | + const [value, setValue] = useState(''); |
| 27 | + |
| 28 | + return ( |
| 29 | + <div> |
| 30 | + <div>Modal is Open? {isOpen1 ? 'Yes' : 'No'}</div> |
| 31 | + <button onClick={open1}>OPEN</button> |
| 32 | + <Modal1 |
| 33 | + title="Title" |
| 34 | + description="This is a customizable modal." |
| 35 | + contentProps={{ |
| 36 | + style: contentStyle1, |
| 37 | + }} |
| 38 | + > |
| 39 | + <input |
| 40 | + type="text" |
| 41 | + value={value} |
| 42 | + onChange={(e) => setValue(e.target.value)} |
| 43 | + /> |
| 44 | + <button onClick={close1}>CLOSE</button> |
| 45 | + <button onClick={open2}>OPEN 2</button> |
| 46 | + </Modal1> |
| 47 | + <Modal2 |
| 48 | + title="Title" |
| 49 | + description="This is a customizable modal." |
| 50 | + dialogProps={{ |
| 51 | + style: dialogStyle2, |
| 52 | + }} |
| 53 | + contentProps={{ |
| 54 | + style: contentStyle2, |
| 55 | + }} |
| 56 | + > |
| 57 | + <button onClick={close2}>CLOSE</button> |
| 58 | + </Modal2> |
| 59 | + </div> |
| 60 | + ); |
| 61 | +}; |
0 commit comments