Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog margin no footer #3809

Merged
merged 9 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions docs/dialog/theme/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ class FunctionDemo extends Component {
value: 'false'
}]
},
footer: {
label: '按钮',
value: 'true',
enum: [{
label: '显示',
value: 'true'
}, {
label: '隐藏',
value: 'false'
}]
},
footerAlign: {
label: '按钮对齐方式',
value: 'right',
Expand Down Expand Up @@ -102,6 +113,7 @@ class FunctionDemo extends Component {
const locale = (lang === 'en-us' ? enUS : zhCN).Dialog;
const hasTitle = this.state.demoFunction.hasTitle.value === 'true';
const hasMask = this.state.demoFunction.hasMask.value === 'true';
const footer = this.state.demoFunction.footer.value === 'true';
const footerAlign = this.state.demoFunction.footerAlign.value;
const okIsLeft = this.state.demoFunction.okPosition.value === 'left';
const style = hasMask ?
Expand All @@ -111,6 +123,7 @@ class FunctionDemo extends Component {
<Dialog.Inner
style={style}
title={hasTitle ? i18n.title : null}
footer={footer}
footerAlign={footerAlign}
footerActions={okIsLeft ? ['ok', 'cancel'] : ['cancel', 'ok']}
locale={locale}>
Expand All @@ -122,6 +135,7 @@ class FunctionDemo extends Component {
<Dialog.Inner
className="next-dialog-quick"
style={style}
footer={footer}
footerAlign={footerAlign}
footerActions={okIsLeft ? ['ok', 'cancel'] : ['cancel', 'ok']}
locale={locale}>
Expand All @@ -137,6 +151,7 @@ class FunctionDemo extends Component {
<Dialog.Inner
className="next-dialog-quick"
style={style}
footer={footer}
footerAlign={footerAlign}
footerActions={okIsLeft ? ['ok', 'cancel'] : ['cancel', 'ok']}
locale={locale}>
Expand Down
9 changes: 7 additions & 2 deletions src/dialog/inner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,15 @@ export default class Inner extends Component {
}

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

&-body-no-footer {
margin-bottom: $dialog-content-margin-bottom-no-footer;
Copy link
Member

Choose a reason for hiding this comment

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

这个样式感觉可以删掉,下面 {$dialog-prefix}-header + #{$dialog-prefix}-body-no-footer 才展示 margin-bottom

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这样就只支持 v2 了,旧弹窗不支持了

Copy link
Member

Choose a reason for hiding this comment

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

  1. 这一行是重复样式,没有 footer 的时候会在 body 上设置 margin-bottom。

  2. 下面是有 header + no-footer {} 是有 header 的时候才设置 margin-bottom。

如果你一直想加上留1,如果只有header存在的时候才加留2。我建议是留2删1

}

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

&#{$dialog-prefix}-v2 {
Expand Down
3 changes: 3 additions & 0 deletions src/dialog/scss/variable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ $dialog-content-padding-bottom: $s-5 !default;
/// padding (l, r)
/// @namespace size/content
$dialog-content-padding-left-right: $s-5 !default;
/// margin (b) no footer
/// @namespace size/content
$dialog-content-margin-bottom-no-footer: $s-0 !default;
/// divider
/// @namespace size/footer
$dialog-footer-border-width: $line-zero !default;
Expand Down