Skip to content

Commit

Permalink
fix(toast): refactor to position center. close #1389
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoidjk committed Jun 2, 2017
1 parent 332114f commit bfdf563
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
10 changes: 6 additions & 4 deletions components/toast/index.web.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* tslint:disable:no-unused-variable */
import React from 'react';
/* tslint:enable:no-unused-variable */
import Notification from 'rc-notification';
import Icon from '../icon';
import classnames from 'classnames';

let messageInstance;
let prefixCls = 'am-toast';
Expand All @@ -14,9 +13,12 @@ function getMessageInstance(mask) {
}
messageInstance = (Notification as any).newInstance({
prefixCls,
style: { top: (mask ? 0 : '50%') },
style: { }, // clear rc-notification default style
transitionName: 'am-fade',
className: mask ? `${prefixCls}-mask` : '',
className: classnames({
[`${prefixCls}-mask`]: mask,
[`${prefixCls}-nomask`]: !mask,
}),
});
return messageInstance;
}
Expand Down
19 changes: 13 additions & 6 deletions components/toast/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@
justify-content: center;
align-items: center;
left: 0;
top: 0;
.@{toastPrefixCls}-notice {
max-width: 50%;
}
}

&-notice {
width: auto;
vertical-align: middle;
&&-nomask {
position: absolute;
max-width: 50%;
width: auto;
left: 50%;
top: 50%;
.@{toastPrefixCls}-notice {
transform: translateX(-50%) translateY(-50%);
}
}



&-notice-content {
position: relative;
right: 50%;
display: block;

.@{toastPrefixCls}-text {
min-width: 1.2rem;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"rc-dialog": "~6.5.7",
"rc-drawer": "~0.4.9",
"rc-input-number": "~3.4.13",
"rc-notification": "~1.4.1",
"rc-notification": "~2.0.0",
"rc-slider": "~7.0.1",
"rc-steps": "~2.5.1",
"rc-swipeout": "~1.3.0",
Expand Down

0 comments on commit bfdf563

Please sign in to comment.