diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-29 15:49:14 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:40 +0100 |
| commit | 9128c224c65f8f2a172b22a443ccb4573c7acd90 (patch) | |
| tree | bc435554174a5ed4c3f8808190cb94016f8d28f0 /src/components/atoms/loaders/progress-bar/progress-bar.module.scss | |
| parent | 81b1e0e05919eb368a66aef47adcf7738af76f29 (diff) | |
refactor(components): rewrite ProgressBar component
* Avoid browser vendors by adding an extra div
* Add a loading state
* Add an option to center the progress bar (no longer the default)
* Remove min since it is always 0
Diffstat (limited to 'src/components/atoms/loaders/progress-bar/progress-bar.module.scss')
| -rw-r--r-- | src/components/atoms/loaders/progress-bar/progress-bar.module.scss | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/components/atoms/loaders/progress-bar/progress-bar.module.scss b/src/components/atoms/loaders/progress-bar/progress-bar.module.scss new file mode 100644 index 0000000..3605ae7 --- /dev/null +++ b/src/components/atoms/loaders/progress-bar/progress-bar.module.scss @@ -0,0 +1,85 @@ +@use "../../../../styles/abstracts/functions" as fun; + +.wrapper { + width: fit-content; + text-align: center; + + &--centered { + margin-inline: auto; + } +} + +.label { + margin-bottom: var(--spacing-2xs); + font-size: var(--font-size-sm); + cursor: default; +} + +.progress { + width: clamp(25ch, 20vw, 30ch); + height: fun.convert-px(13); + position: relative; + overflow: hidden; + background: var(--color-bg-tertiary); + border: fun.convert-px(1) solid var(--color-primary-darker); + border-radius: 1em; + box-shadow: inset 0 0 fun.convert-px(4) fun.convert-px(1) + var(--color-shadow-light); + container-type: inline-size; + + &::before { + content: ""; + position: absolute; + width: 15%; + left: 0; + } + + &::before, + &__bar { + background-color: var(--color-primary-dark); + border-radius: 1em; + } + + &::before, + progress { + height: 100%; + opacity: 0; + } + + &__bar, + progress { + width: 100%; + position: absolute; + inset: 0; + } + + &__bar { + transform: translateX(var(--currentProgress)); + transition: all 0.25s linear 0s; + } + + progress { + appearance: none; + } + + &--loading { + &::before { + opacity: 1; + animation: move 1s linear 0s infinite alternate both; + } + } + + &--loading &__bar { + opacity: 0; + } +} + +@keyframes move { + 0% { + transform: translateX(0); + } + + 100% { + transform: translateX(calc(100cqw - 100%)); + } +} |
