Skip to content

Commit

Permalink
feat(Dialog): new api noPadding for Dialog body padding fix #3892 (#3893
Browse files Browse the repository at this point in the history
)
  • Loading branch information
潕量 authored May 30, 2022
1 parent e421fe2 commit ffb274f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/dialog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ API变化:
| isFullScreen | [v2废弃] 是否撑开页面。 v2 改用 overflowScroll | Boolean | false | |
| shouldUpdatePosition | [v2废弃] 是否在对话框重新渲染时及时更新对话框位置,一般用于对话框高度变化后依然能保证原来的对齐方式 | Boolean | false | |
| minMargin | [v2废弃] 对话框距离浏览器顶部和底部的最小间距,align 被设置为 'cc cc' 并且 isFullScreen 被设置为 true 时不生效 | Number | 40 | |
| noPadding | 去除body内间距 | Boolean | false | 1.26 |

<!-- api-extra-start -->

Expand Down
8 changes: 8 additions & 0 deletions src/dialog/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ export default class Dialog extends Component {
* [v2废弃] 对话框距离浏览器顶部和底部的最小间距,align 被设置为 'cc cc' 并且 isFullScreen 被设置为 true 时不生效
*/
minMargin: PropTypes.number,
/**
* 去除body内间距
* @version 1.26
*/
noPadding: PropTypes.bool,
};

static defaultProps = {
Expand Down Expand Up @@ -235,6 +240,7 @@ export default class Dialog extends Component {
bottom: 40,
overlayProps: {},
locale: zhCN.Dialog,
noPadding: false,
};

constructor(props, context) {
Expand Down Expand Up @@ -383,6 +389,7 @@ export default class Dialog extends Component {
visible,
rtl,
height,
noPadding,
} = this.props;
const others = pickOthers(Object.keys(Dialog.propTypes), this.props);

Expand All @@ -403,6 +410,7 @@ export default class Dialog extends Component {
rtl={rtl}
onClose={onClose.bind(this, 'closeClick')}
height={height}
noPadding={noPadding}
{...others}
>
{children}
Expand Down
4 changes: 3 additions & 1 deletion src/dialog/inner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class Inner extends Component {
v2: PropTypes.bool,
closeIcon: PropTypes.node,
pure: PropTypes.bool,
noPadding: PropTypes.bool,
};

static defaultProps = {
Expand Down Expand Up @@ -113,12 +114,13 @@ export default class Inner extends Component {
}

renderBody() {
const { prefix, children, footer } = this.props;
const { prefix, children, footer, noPadding } = this.props;
if (children) {
return (
<div
className={cx(`${prefix}dialog-body`, {
[`${prefix}dialog-body-no-footer`]: footer === false,
[`${prefix}dialog-body-no-padding`]: noPadding === true,
})}
ref={this.getNode.bind(this, 'bodyNode')}
>
Expand Down
6 changes: 6 additions & 0 deletions src/dialog/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
&-body-no-footer {
margin-bottom: $dialog-content-margin-bottom-no-footer;
}
&-body-no-padding {
padding: 0;
}

/* 让用户自己设置 */
/* &.#{$css-prefix}closeable &-header, */
Expand Down Expand Up @@ -171,6 +174,9 @@
#{$dialog-prefix}-header + #{$dialog-prefix}-body-no-footer {
margin-bottom: $dialog-content-margin-bottom-no-footer;
}
#{$dialog-prefix}-body#{$dialog-prefix}-body-no-padding {
padding: 0;
}
}

&#{$dialog-prefix}-v2 {
Expand Down
8 changes: 7 additions & 1 deletion src/drawer/drawer-v2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ const Drawer = props => {
setVisibleOverlayToParent(id, node);
};

const nstyle = {
width,
height,
...style,
};

return (
<OverlayContext.Provider
value={{
Expand All @@ -292,7 +298,7 @@ const Drawer = props => {
</Animate.OverlayAnimate>
) : null}

<div className={innerWrapperCls} style={{ width, height }} ref={drawerRef}>
<div className={innerWrapperCls} style={nstyle} ref={drawerRef}>
<Animate.OverlayAnimate
visible={visible}
animation={newAnimation}
Expand Down

0 comments on commit ffb274f

Please sign in to comment.