@@ -52,6 +52,7 @@ export const Badge: FunctionComponent<Partial<BadgeProps>> = (props) => {
5252 ...props ,
5353 }
5454 const classPrefix = 'nut-badge'
55+ const isHarmony = harmony ( )
5556 const classes = classNames ( classPrefix , className )
5657 const badgeRef = useRef ( null )
5758 const [ contentStyle , setContentStyle ] = useState ( { } )
@@ -88,10 +89,10 @@ export const Badge: FunctionComponent<Partial<BadgeProps>> = (props) => {
8889 if ( badgeRef . current ) {
8990 getPositionStyle ( )
9091 }
91- } , [ badgeRef . current ] )
92+ } , [ ] )
9293 const getPositionStyle = async ( ) => {
9394 const style : CSSProperties = { }
94- style . top = pxTransform ( Number ( - top ) || 0 )
95+ style . top = pxTransform ( - Number ( top ) || 0 )
9596 if ( rn ( ) ) {
9697 const reacts = await getRectByTaro ( badgeRef . current )
9798 style . left =
@@ -100,7 +101,7 @@ export const Badge: FunctionComponent<Partial<BadgeProps>> = (props) => {
100101 : 0
101102 } else {
102103 const dir = rtl ? 'left' : 'right'
103- style [ dir ] = harmony ( )
104+ style [ dir ] = isHarmony
104105 ? pxTransform ( Number ( right ) )
105106 : `${ Number ( right ) || parseFloat ( String ( right ) ) || 0 } px`
106107 }
@@ -112,13 +113,15 @@ export const Badge: FunctionComponent<Partial<BadgeProps>> = (props) => {
112113 if ( color ) {
113114 if ( fill === 'outline' ) {
114115 style . color = color
115- style . backgroundColor = '#fff'
116+ isHarmony
117+ ? ( style . backgroundColor = '#fff' )
118+ : ( style . background = '#fff' )
116119 if ( ! color ?. includes ( 'gradient' ) ) {
117120 style . borderColor = color
118121 }
119122 } else {
120123 style . color = '#fff'
121- style . backgroundColor = color
124+ isHarmony ? ( style . backgroundColor = color ) : ( style . background = color )
122125 }
123126 }
124127 return style
0 commit comments