| 13 | ); |
| 14 | |
| 15 | function ScaleLoader({ |
| 16 | loading = true, |
| 17 | color = "#000000", |
| 18 | speedMultiplier = 1, |
| 19 | cssOverride = {}, |
| 20 | height = 35, |
| 21 | width = 4, |
| 22 | radius = 2, |
| 23 | margin = 2, |
| 24 | barCount = 5, |
| 25 | ...additionalprops |
| 26 | }: LoaderHeightWidthRadiusProps & { barCount?: number }) { |
| 27 | const wrapper: React.CSSProperties = { |
| 28 | display: "inherit", |
| 29 | ...cssOverride, |
| 30 | }; |
| 31 | |
| 32 | const style = (i: number): React.CSSProperties => { |
| 33 | return { |
| 34 | backgroundColor: color, |
| 35 | width: cssValue(width), |
| 36 | height: cssValue(height), |
| 37 | margin: cssValue(margin), |
| 38 | borderRadius: cssValue(radius), |
| 39 | display: "inline-block", |
| 40 | animation: `${scale} ${1 / speedMultiplier}s ${i * 0.1}s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08)`, |
| 41 | animationFillMode: "both", |
| 42 | }; |
| 43 | }; |
| 44 | |
| 45 | if (!loading) { |
| 46 | return null; |
| 47 | } |
| 48 | |
| 49 | return ( |
| 50 | <span style={wrapper} {...additionalprops}> |
| 51 | {[...Array(barCount)].map((_, i) => ( |
| 52 | <span key={i} style={style(i + 1)} /> |
| 53 | ))} |
| 54 | </span> |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | export default ScaleLoader; |