|
| 1 | +/** |
| 2 | + * cn - 遮罩 |
| 3 | + * -- 通过 `mask` 属性控制遮罩的显示。设置 `mask={false}` 隐藏遮罩,设置 `mask={{ blur: true }}` 显示模糊遮罩 |
| 4 | + * en - Mask |
| 5 | + * -- Use the `mask` prop to control the mask display. Set `mask={false}` to hide the mask, set `mask={{ blur: true }}` to show a blurred mask |
| 6 | + */ |
| 7 | +import React, { useState } from 'react'; |
| 8 | +import { Modal, Button } from 'shineout'; |
| 9 | + |
| 10 | +const App: React.FC = () => { |
| 11 | + const [visible1, setVisible1] = useState(false); |
| 12 | + const [visible2, setVisible2] = useState(false); |
| 13 | + |
| 14 | + const info1 = () => { |
| 15 | + Modal.info({ |
| 16 | + title: 'This is a info message', |
| 17 | + content: 'this is some information that user must know', |
| 18 | + mask: { blur: true }, |
| 19 | + }); |
| 20 | + }; |
| 21 | + |
| 22 | + const info2 = () => { |
| 23 | + Modal.info({ |
| 24 | + title: 'This is a success message', |
| 25 | + content: 'this is some information that user successful operation', |
| 26 | + mask: false, |
| 27 | + }); |
| 28 | + }; |
| 29 | + |
| 30 | + return ( |
| 31 | + <div style={{ display: 'flex', gap: '16px' }}> |
| 32 | + <Button mode='outline' onClick={() => setVisible1(true)}> |
| 33 | + mask blur |
| 34 | + </Button> |
| 35 | + <Button mode='outline' onClick={() => setVisible2(true)}> |
| 36 | + mask=false |
| 37 | + </Button> |
| 38 | + <Modal |
| 39 | + title='Modal with blur mask' |
| 40 | + visible={visible1} |
| 41 | + onClose={() => setVisible1(false)} |
| 42 | + mask={{ blur: true }} |
| 43 | + footer={<Button type="primary" onClick={() => setVisible1(false)}>Close</Button>} |
| 44 | + > |
| 45 | + This modal has a blurred mask |
| 46 | + </Modal> |
| 47 | + <Modal |
| 48 | + title='Modal without mask' |
| 49 | + visible={visible2} |
| 50 | + onClose={() => setVisible2(false)} |
| 51 | + mask={false} |
| 52 | + footer={<Button type="primary" onClick={() => setVisible2(false)}>Close</Button>} |
| 53 | + > |
| 54 | + This modal has no mask |
| 55 | + </Modal> |
| 56 | + |
| 57 | + <Button type='primary' onClick={info1}> |
| 58 | + info (blur) |
| 59 | + </Button> |
| 60 | + <Button type='primary' onClick={info2}> |
| 61 | + info (no mask) |
| 62 | + </Button> |
| 63 | + </div> |
| 64 | + ); |
| 65 | +}; |
| 66 | + |
| 67 | +export default App; |
0 commit comments