11import * as React from 'react'
22import classNames from 'classnames'
3- import { Check , Loading , Failure , Tips } from '@nutui/icons-react'
3+ import { Success , Loading , Failure , Tips } from '@nutui/icons-react'
44import { render , unmount } from '@/utils/render'
55import Overlay from '@/packages/overlay/index'
66import { BasicComponent } from '@/utils/typings'
@@ -83,23 +83,12 @@ export default class Notification extends React.PureComponent<
8383 renderIcon ( ) {
8484 const { icon } = this . props
8585 if ( typeof icon === 'string' ) {
86- let iconNode = null
87- switch ( icon ) {
88- case 'success' :
89- iconNode = < Check />
90- break
91- case 'loading' :
92- iconNode = < Loading className = "nut-icon-loading" />
93- break
94- case 'fail' :
95- iconNode = < Failure />
96- break
97- case 'warn' :
98- iconNode = < Tips />
99- break
100- default :
101- break
102- }
86+ const iconNode = {
87+ success : < Success /> ,
88+ fail : < Failure /> ,
89+ warn : < Tips /> ,
90+ loading : < Loading className = "nut-icon-loading" /> ,
91+ } [ icon ]
10392 return < p className = { `${ classPrefix } -icon-wrapper` } > { iconNode } </ p >
10493 }
10594 return icon
@@ -134,7 +123,6 @@ export default class Notification extends React.PureComponent<
134123
135124 const classes = classNames ( {
136125 'nut-toast-has-icon' : icon ,
137- [ `nut-toast-${ size } ` ] : true ,
138126 } )
139127 return (
140128 < >
@@ -150,14 +138,20 @@ export default class Notification extends React.PureComponent<
150138 >
151139 < div className = { `${ classPrefix } ${ classes } ` } id = { `toast-${ id } ` } >
152140 < div
153- className = { `${ classPrefix } -inner ${ classPrefix } -${ position } ${ contentClassName } ${ wordBreak } ` }
154- style = { contentStyle }
141+ className = { `${ classPrefix } -inner ${ classPrefix } -${ position } ${ contentClassName } ${ classPrefix } -inner-${ size } ${ classPrefix } -inner-${ wordBreak } ` }
142+ style = { {
143+ ...contentStyle ,
144+ } }
155145 >
156146 { this . renderIcon ( ) }
157147 { title ? (
158148 < div className = { `${ classPrefix } -title` } > { title } </ div >
159149 ) : null }
160- < span className = { `${ classPrefix } -text` } > { content } </ span >
150+ < span
151+ className = { `${ classPrefix } -text ${ content ? '' : `${ classPrefix } -text-empty` } ` }
152+ >
153+ { content }
154+ </ span >
161155 </ div >
162156 </ div >
163157 </ Overlay >
0 commit comments