Skip to content

Commit 52c08a7

Browse files
feat: add configurable bar count for ScaleLoader (#617)
* [ScaleLoader] Configurable bar count * Update src/ScaleLoader.tsx * Update src/ScaleLoader.tsx * Update src/ScaleLoader.tsx * Update src/ScaleLoader.tsx --------- Co-authored-by: David Hu <davidhu314@gmail.com>
1 parent 0bd2d05 commit 52c08a7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/ScaleLoader.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ function ScaleLoader({
1919
width = 4,
2020
radius = 2,
2121
margin = 2,
22+
barCount = 5,
2223
...additionalprops
23-
}: LoaderHeightWidthRadiusProps): JSX.Element | null {
24+
}: LoaderHeightWidthRadiusProps & { barCount: number }): JSX.Element | null {
2425
const wrapper: React.CSSProperties = {
2526
display: "inherit",
2627
...cssOverride,
@@ -45,11 +46,9 @@ function ScaleLoader({
4546

4647
return (
4748
<span style={wrapper} {...additionalprops}>
48-
<span style={style(1)} />
49-
<span style={style(2)} />
50-
<span style={style(3)} />
51-
<span style={style(4)} />
52-
<span style={style(5)} />
49+
{[...Array(barCount)].map((_, i) => (
50+
<span key={i} style={style(i + 1)} />
51+
))}
5352
</span>
5453
);
5554
}

0 commit comments

Comments
 (0)