diff --git a/README.md b/README.md index e1fb934d..dfaa79f5 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ ReactDOM.render( | title | String\|React.Element | | Title of the dialog | | | footer | React.Element | | footer of the dialog | | | closable | Boolean \| ({ closeIcon?: React.ReactNode; disabled?: boolean, afterClose:function } & React.AriaAttributes) | true | whether show close button | | -| mask | Boolean | true | whether show mask | | +| mask | Boolean \| `blur` | true | whether to show the mask. Can be set to `blur` for a blur effect. | | | maskClosable | Boolean | true | whether click mask to close | | | keyboard | Boolean | true | whether support press esc to close | | | mousePosition | {x:number,y:number} | | set pageX and pageY of current mouse(it will cause transform origin to be set). | | @@ -104,8 +104,7 @@ open coverage/ dir rc-dialog is released under the MIT license. - -## 🤝 Contributing +## 🤝 Contributing Contribution Leaderboard diff --git a/assets/index/Mask.less b/assets/index/Mask.less index 944863b7..46818a41 100644 --- a/assets/index/Mask.less +++ b/assets/index/Mask.less @@ -10,7 +10,9 @@ height: 100%; filter: alpha(opacity=50); z-index: 1050; - + &&-blur { + backdrop-filter: blur(4px); + } &-hidden { display: none; } @@ -22,7 +24,8 @@ animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); } - &-fade-enter,&-fade-appear { + &-fade-enter, + &-fade-appear { opacity: 0; .fade-effect(); animation-play-state: paused; @@ -33,7 +36,8 @@ animation-play-state: paused; } - &-fade-enter&-fade-enter-active,&-fade-appear&-fade-appear-active { + &-fade-enter&-fade-enter-active, + &-fade-appear&-fade-appear-active { animation-name: rcDialogFadeIn; animation-play-state: running; } diff --git a/src/Dialog/Mask.tsx b/src/Dialog/Mask.tsx index 389c9c36..7013d448 100644 --- a/src/Dialog/Mask.tsx +++ b/src/Dialog/Mask.tsx @@ -9,10 +9,11 @@ export type MaskProps = { style?: React.CSSProperties; maskProps?: React.HTMLAttributes; className?: string; + mask?: boolean | 'blur'; }; const Mask: React.FC = (props) => { - const { prefixCls, style, visible, maskProps, motionName, className } = props; + const { prefixCls, style, visible, maskProps, motionName, className, mask } = props; return ( = (props) => {
)} diff --git a/src/Dialog/index.tsx b/src/Dialog/index.tsx index 3512e772..fd908967 100644 --- a/src/Dialog/index.tsx +++ b/src/Dialog/index.tsx @@ -198,6 +198,7 @@ const Dialog: React.FC = (props) => { style={{ zIndex, ...maskStyle, ...modalStyles?.mask }} maskProps={maskProps} className={modalClassNames?.mask} + mask={mask} />
>; @@ -18,7 +25,7 @@ export type IDialogPropTypes = { keyboard?: boolean; style?: CSSProperties; rootStyle?: CSSProperties; - mask?: boolean; + mask?: boolean | 'blur'; children?: React.ReactNode; afterClose?: () => any; afterOpenChange?: (open: boolean) => void; diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index bd7274c7..49c88a28 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -752,4 +752,11 @@ describe('dialog', () => { expect(document.querySelector('.rc-dialog')).toBeTruthy(); expect(document.querySelector('.rc-dialog-close')).toBeFalsy(); }); + + it('Dialog mask blur', () => { + render(); + jest.runAllTimers(); + expect(document.querySelector('.rc-dialog-root')).toBeTruthy(); + expect(document.querySelector('.rc-dialog-mask-blur')).toBeTruthy(); + }); });