From 7a80c133ac0eb011c700ff4a3ab7e52f446ec95d Mon Sep 17 00:00:00 2001 From: myronliu347 Date: Wed, 10 Apr 2019 09:57:35 +0800 Subject: [PATCH] feat(Message): configable message icon type --- src/message/main.scss | 54 ++++++++++++++++++++++------------ src/message/message.jsx | 8 +++-- src/message/scss/mixin.scss | 9 +++++- src/message/scss/variable.scss | 24 +++++++++++++++ 4 files changed, 74 insertions(+), 21 deletions(-) diff --git a/src/message/main.scss b/src/message/main.scss index 447265d3b1..939ca02e98 100644 --- a/src/message/main.scss +++ b/src/message/main.scss @@ -33,7 +33,8 @@ $message-success-color-bg-inline, $message-success-color-border-inline, $message-border-radius, - none + none, + $message-success-icon-content ); } &.#{$css-prefix}addon { @@ -45,7 +46,8 @@ transparent, transparent, $message-border-radius, - none + none, + $message-success-icon-content ); } &.#{$css-prefix}toast { @@ -57,7 +59,8 @@ $message-success-color-bg-toast, $message-success-color-border-toast, $message-border-radius-toast, - $message-shadow-toast + $message-shadow-toast, + $message-success-icon-content ); } } @@ -72,7 +75,8 @@ $message-warning-color-bg-inline, $message-warning-color-border-inline, $message-border-radius, - none + none, + $message-warning-icon-content ); } &.#{$css-prefix}addon { @@ -84,7 +88,8 @@ transparent, transparent, $message-border-radius, - none + none, + $message-warning-icon-content ); } &.#{$css-prefix}toast { @@ -96,7 +101,8 @@ $message-warning-color-bg-toast, $message-warning-color-border-toast, $message-border-radius-toast, - $message-shadow-toast + $message-shadow-toast, + $message-warning-icon-content ); } } @@ -111,7 +117,8 @@ $message-error-color-bg-inline, $message-error-color-border-inline, $message-border-radius, - none + none, + $message-error-icon-content ); } &.#{$css-prefix}addon { @@ -123,7 +130,8 @@ transparent, transparent, $message-border-radius, - none + none, + $message-error-icon-content ); } &.#{$css-prefix}toast { @@ -135,7 +143,8 @@ $message-error-color-bg-toast, $message-error-color-border-toast, $message-border-radius-toast, - $message-shadow-toast + $message-shadow-toast, + $message-error-icon-content ); } } @@ -150,7 +159,8 @@ $message-notice-color-bg-inline, $message-notice-color-border-inline, $message-border-radius, - none + none, + $message-notice-icon-content ); } &.#{$css-prefix}addon { @@ -162,7 +172,8 @@ transparent, transparent, $message-border-radius, - none + none, + $message-notice-icon-content ); } &.#{$css-prefix}toast { @@ -174,7 +185,8 @@ $message-notice-color-bg-toast, $message-notice-color-border-toast, $message-border-radius-toast, - $message-shadow-toast + $message-shadow-toast, + $message-notice-icon-content ); } } @@ -189,7 +201,8 @@ $message-help-color-bg-inline, $message-help-color-border-inline, $message-border-radius, - none + none, + $message-help-icon-content ); } &.#{$css-prefix}addon { @@ -201,7 +214,8 @@ transparent, transparent, $message-border-radius, - none + none, + $message-help-icon-content ); } &.#{$css-prefix}toast { @@ -213,7 +227,8 @@ $message-help-color-bg-toast, $message-help-color-border-toast, $message-border-radius-toast, - $message-shadow-toast + $message-shadow-toast, + $message-help-icon-content ); } } @@ -228,7 +243,8 @@ $message-loading-color-bg-inline, $message-loading-color-border-inline, $message-border-radius, - none + none, + $message-loading-icon-content ); } &.#{$css-prefix}addon { @@ -240,7 +256,8 @@ transparent, transparent, $message-border-radius, - none + none, + $message-loading-icon-content ); } &.#{$css-prefix}toast { @@ -252,7 +269,8 @@ $message-loading-color-bg-toast, $message-loading-color-border-toast, $message-border-radius-toast, - $message-shadow-toast + $message-shadow-toast, + $message-loading-icon-content ); } } diff --git a/src/message/message.jsx b/src/message/message.jsx index 308f7e0952..033bdda8a2 100644 --- a/src/message/message.jsx +++ b/src/message/message.jsx @@ -148,7 +148,7 @@ class Message extends Component { /* eslint-enable */ const { visible } = this.state; const messagePrefix = `${prefix}message`; - const iconType = icon || TYPE_MAPS[type]; + const classes = classNames({ [messagePrefix]: true, [`${prefix}message-${type}`]: type, @@ -177,7 +177,11 @@ class Message extends Component { ) : null} - + {title ? (
{title}
) : null} diff --git a/src/message/scss/mixin.scss b/src/message/scss/mixin.scss index f24b5f9072..326cfac912 100755 --- a/src/message/scss/mixin.scss +++ b/src/message/scss/mixin.scss @@ -53,7 +53,8 @@ $bgColor, $borderColor, $corner, - $shadow + $shadow, + $icon ) { background-color: $bgColor; border-color: $borderColor; @@ -69,6 +70,12 @@ .#{$css-prefix}message-symbol { color: $iconColor; } + .#{$css-prefix}message-symbol-icon::before { + content: $icon; + @if ($icon == $message-loading-icon-content) { + animation: loadingCircle 1s infinite linear; + } + } @if ($shape == 'inline') { border-style: $message-border-style; diff --git a/src/message/scss/variable.scss b/src/message/scss/variable.scss index 6dbdb98ce3..487b42ba15 100644 --- a/src/message/scss/variable.scss +++ b/src/message/scss/variable.scss @@ -390,3 +390,27 @@ $message-close-icon-color: $color-text1-2 !default; /// icon /// @namespace statement/hover/close $message-hover-close-icon-color: $color-text1-3 !default; +/// success icon +/// @namespace statement/normal +/// @type icon +$message-success-icon-content: $icon-content-success !default; +/// warning icon +/// @namespace statement/normal +/// @type icon +$message-warning-icon-content: $icon-content-warning !default; +/// error icon +/// @namespace statement/normal +/// @type icon +$message-error-icon-content: $icon-content-error !default; +/// notice icon +/// @namespace statement/normal +/// @type icon +$message-notice-icon-content: $icon-content-prompt !default; +/// help icon +/// @namespace statement/normal +/// @type icon +$message-help-icon-content: $icon-content-help !default; +/// help icon +/// @namespace statement/normal +/// @type icon +$message-loading-icon-content: $icon-content-loading !default;