@@ -7,6 +7,7 @@ import { SkeletonStyleProps } from './SkeletonStyleProps'
77const defaultBaseColor = '#ebebeb'
88const defaultHighlightColor = '#f5f5f5'
99
10+ // For performance & cleanliness, don't add any inline styles unless we have to
1011function styleOptionsToCssProperties ( {
1112 baseColor,
1213 highlightColor,
@@ -20,9 +21,7 @@ function styleOptionsToCssProperties({
2021 duration,
2122 enableAnimation = true ,
2223} : SkeletonStyleProps & { circle : boolean } ) : CSSProperties {
23- const style : CSSProperties = {
24- animationDirection : direction === 'rtl' ? 'reverse' : 'normal' ,
25- }
24+ const style : CSSProperties = { }
2625
2726 if ( direction === 'rtl' ) style . animationDirection = 'reverse'
2827
@@ -43,19 +42,16 @@ function styleOptionsToCssProperties({
4342 }
4443
4544 if ( typeof baseColor !== 'undefined' || typeof highlightColor !== 'undefined' ) {
46- baseColor ??= defaultBaseColor
47- highlightColor ??= defaultHighlightColor
48-
49- style . backgroundColor = baseColor
45+ style . backgroundColor = baseColor ?? defaultBaseColor
5046 style . backgroundImage = `linear-gradient(
5147 90deg,
52- ${ baseColor } ,
53- ${ highlightColor } ,
54- ${ baseColor }
48+ ${ baseColor ?? defaultBaseColor } ,
49+ ${ highlightColor ?? defaultHighlightColor } ,
50+ ${ baseColor ?? defaultBaseColor }
5551 )`
5652 }
5753
58- if ( ! enableAnimation ) style . animation = 'none'
54+ if ( ! enableAnimation ) style . backgroundImage = 'none'
5955
6056 return style
6157}
0 commit comments