({
baseColor,
highlightColor,
width,
height,
borderRadius,
circle,
direction,
duration,
enableAnimation = defaultEnableAnimation,
customHighlightBackground,
}: SkeletonStyleProps & { circle: boolean })
| 7 | |
| 8 | // For performance & cleanliness, don't add any inline styles unless we have to |
| 9 | function styleOptionsToCssProperties({ |
| 10 | baseColor, |
| 11 | highlightColor, |
| 12 | |
| 13 | width, |
| 14 | height, |
| 15 | borderRadius, |
| 16 | circle, |
| 17 | |
| 18 | direction, |
| 19 | duration, |
| 20 | enableAnimation = defaultEnableAnimation, |
| 21 | |
| 22 | customHighlightBackground, |
| 23 | }: SkeletonStyleProps & { circle: boolean }): CSSProperties & |
| 24 | Record<`--${string}`, string> { |
| 25 | const style: ReturnType<typeof styleOptionsToCssProperties> = {}; |
| 26 | |
| 27 | if (direction === 'rtl') style['--animation-direction'] = 'reverse'; |
| 28 | if (typeof duration === 'number') |
| 29 | style['--animation-duration'] = `${duration}s`; |
| 30 | if (!enableAnimation) style['--pseudo-element-display'] = 'none'; |
| 31 | |
| 32 | if (typeof width === 'string' || typeof width === 'number') |
| 33 | style.width = width; |
| 34 | if (typeof height === 'string' || typeof height === 'number') |
| 35 | style.height = height; |
| 36 | |
| 37 | if (typeof borderRadius === 'string' || typeof borderRadius === 'number') |
| 38 | style.borderRadius = borderRadius; |
| 39 | |
| 40 | if (circle) style.borderRadius = '50%'; |
| 41 | |
| 42 | if (typeof baseColor !== 'undefined') style['--base-color'] = baseColor; |
| 43 | if (typeof highlightColor !== 'undefined') |
| 44 | style['--highlight-color'] = highlightColor; |
| 45 | |
| 46 | if (typeof customHighlightBackground === 'string') |
| 47 | style['--custom-highlight-background'] = customHighlightBackground; |
| 48 | |
| 49 | return style; |
| 50 | } |
| 51 | |
| 52 | export interface SkeletonProps extends SkeletonStyleProps { |
| 53 | count?: number; |
no outgoing calls
no test coverage detected
searching dependent graphs…