Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 show mask | |
| 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). | |
Expand Down Expand Up @@ -104,8 +104,7 @@ open coverage/ dir

rc-dialog is released under the MIT license.


## 🤝 Contributing
## 🤝 Contributing

<a href="https://openomy.app/github/react-component/dialog" target="_blank" style="display: block; width: 100%;" align="center">
<img src="https://www.openomy.app/svg?repo=react-component/dialog&chart=bubble&latestMonth=24" target="_blank" alt="Contribution Leaderboard" style="display: block; width: 100%;" />
Expand Down
10 changes: 7 additions & 3 deletions assets/index/Mask.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
height: 100%;
filter: alpha(opacity=50);
z-index: 1050;

&&-blur {
backdrop-filter: blur(4px);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了更好的浏览器兼容性,特别是对于旧版本的 Safari,建议为 backdrop-filter 属性添加 -webkit- 前缀。

      -webkit-backdrop-filter: blur(4px);
      backdrop-filter: blur(4px);

}
&-hidden {
display: none;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
10 changes: 8 additions & 2 deletions src/Dialog/Mask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export type MaskProps = {
style?: React.CSSProperties;
maskProps?: React.HTMLAttributes<HTMLDivElement>;
className?: string;
mask?: boolean | 'blur';
};

const Mask: React.FC<MaskProps> = (props) => {
const { prefixCls, style, visible, maskProps, motionName, className } = props;
const { prefixCls, style, visible, maskProps, motionName, className, mask } = props;
return (
<CSSMotion
key="mask"
Expand All @@ -24,7 +25,12 @@ const Mask: React.FC<MaskProps> = (props) => {
<div
ref={ref}
style={{ ...motionStyle, ...style }}
className={classNames(`${prefixCls}-mask`, motionClassName, className)}
className={classNames(
`${prefixCls}-mask`,
motionClassName,
className,
mask === 'blur' && `${prefixCls}-mask-blur`,
)}
{...maskProps}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions src/Dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const Dialog: React.FC<IDialogPropTypes> = (props) => {
style={{ zIndex, ...maskStyle, ...modalStyles?.mask }}
maskProps={maskProps}
className={modalClassNames?.mask}
mask={mask}
/>
<div
tabIndex={-1}
Expand Down
11 changes: 9 additions & 2 deletions src/IDialogPropTypes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import type { GetContainer } from '@rc-component/util/lib/PortalWrapper';
import type { CSSProperties, ReactNode, SyntheticEvent } from 'react';

export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask';
export type SemanticName =
| 'header'
| 'body'
| 'footer'
| 'container'
| 'title'
| 'wrapper'
| 'mask';

export type ModalClassNames = Partial<Record<SemanticName, string>>;

Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,11 @@ describe('dialog', () => {
expect(document.querySelector('.rc-dialog')).toBeTruthy();
expect(document.querySelector('.rc-dialog-close')).toBeFalsy();
});

it('Dialog mask blur', () => {
render(<Dialog mask="blur" visible/>);
jest.runAllTimers();
expect(document.querySelector('.rc-dialog-root')).toBeTruthy();
expect(document.querySelector('.rc-dialog-mask-blur')).toBeTruthy();
});
});
Loading