Skip to content

Commit 15e7952

Browse files
committed
✨ Add indeterminate progress bars
1 parent b048048 commit 15e7952

File tree

8 files changed

+43
-7
lines changed

8 files changed

+43
-7
lines changed

src/blocks/Maintenance/maintenance.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from {
2828
transform: rotate(0);
2929
}
30-
to {
30+
to {
3131
transform: rotate(360deg);
3232
}
3333
}

src/components/Progress/Progress.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
striped,
1818
stripeLight,
1919
stripeDark,
20+
indeterminate,
2021
className
2122
} = Astro.props
2223
@@ -25,6 +26,7 @@ const classes = [
2526
size && styles[size],
2627
striped && styles.striped,
2728
square && styles.square,
29+
indeterminate && styles.indeterminate,
2830
className
2931
]
3032
@@ -34,10 +36,12 @@ const styleVariables = classNames([
3436
stripeLight && `--w-progress-stripe-light: ${stripeLight};`,
3537
stripeDark && `--w-progress-stripe-dark: ${stripeDark};`
3638
])
39+
40+
const currentValue = indeterminate && !value ? 20 : value
3741
---
3842

3943
<div class:list={classes} style={styleVariables}>
40-
<div class={styles.progress} style={`--w-progress-width: ${value}%;`}>
41-
{label && `${value}%`}
44+
<div class={styles.progress} style={`--w-progress-width: ${currentValue}%;`}>
45+
{label && `${currentValue}%`}
4246
</div>
4347
</div>

src/components/Progress/Progress.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
striped,
1616
stripeLight,
1717
stripeDark,
18+
indeterminate,
1819
className
1920
}: ProgressProps = $props()
2021
@@ -23,6 +24,7 @@
2324
size && styles[size],
2425
striped && styles.striped,
2526
square && styles.square,
27+
indeterminate && styles.indeterminate,
2628
className
2729
])
2830
@@ -32,12 +34,14 @@
3234
stripeLight && `--w-progress-stripe-light: ${stripeLight};`,
3335
stripeDark && `--w-progress-stripe-dark: ${stripeDark};`
3436
])
37+
38+
const currentValue = indeterminate && !value ? 20 : value
3539
</script>
3640

3741
<div class={classes} style={styleVariables || null}>
38-
<div class={styles.progress} style={`--w-progress-width: ${value}%;`}>
42+
<div class={styles.progress} style={`--w-progress-width: ${currentValue}%;`}>
3943
{#if label}
40-
{`${value}%`}
44+
{`${currentValue}%`}
4145
{/if}
4246
</div>
4347
</div>

src/components/Progress/Progress.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ const Progress = ({
1515
striped,
1616
stripeLight,
1717
stripeDark,
18+
indeterminate,
1819
className
1920
}: ProgressProps) => {
2021
const classes = classNames([
2122
styles['w-progress'],
2223
size && styles[size],
2324
striped && styles.striped,
2425
square && styles.square,
26+
indeterminate && styles.indeterminate,
2527
className
2628
])
2729

@@ -32,14 +34,16 @@ const Progress = ({
3234
...(stripeDark && { '--w-progress-stripe-dark': stripeDark })
3335
} as React.CSSProperties
3436

37+
const currentValue = indeterminate && !value ? 20 : value
38+
3539
const percent = {
36-
'--w-progress-width': `${value}%`
40+
'--w-progress-width': `${currentValue}%`
3741
} as React.CSSProperties
3842

3943
return (
4044
<div className={classes} style={styleVariables}>
4145
<div className={styles.progress} style={percent}>
42-
{label && `${value}%`}
46+
{label && `${currentValue}%`}
4347
</div>
4448
</div>
4549
)

src/components/Progress/progress.module.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ body {
5858
}
5959
}
6060

61+
&.indeterminate .progress {
62+
@include position(relative);
63+
64+
animation: load 1s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
65+
}
66+
6167
.progress {
6268
@include transition(width);
6369
@include size('h100%');
@@ -68,3 +74,12 @@ body {
6874
width: var(--w-progress-width);
6975
}
7076
}
77+
78+
@keyframes load {
79+
from {
80+
left: -100%;
81+
}
82+
to {
83+
left: 100%;
84+
}
85+
}

src/components/Progress/progress.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export type ProgressProps = {
88
striped?: boolean
99
stripeLight?: string
1010
stripeDark?: string
11+
indeterminate?: boolean
1112
className?: string
1213
}

src/pages/components/progress.astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ const sections = getSections({
148148
</p>
149149
<section.component value={33} />
150150
</ComponentWrapper>
151+
152+
<ComponentWrapper title="Indeterminate">
153+
<section.component indeterminate={true} />
154+
</ComponentWrapper>
155+
156+
<ComponentWrapper title="Indeterminate with value">
157+
<section.component indeterminate={true} value={50} />
158+
</ComponentWrapper>
151159
</div>
152160
))}
153161
</Layout>
12.2 KB
Loading

0 commit comments

Comments
 (0)