Skip to content

Commit 5456b8c

Browse files
fix(Progress): improve status-position when 0 (#4994)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
1 parent dc28907 commit 5456b8c

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/runtime/components/Progress.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ const indicatorStyle = computed(() => {
122122
})
123123
124124
const statusStyle = computed(() => {
125-
return {
126-
[props.orientation === 'vertical' ? 'height' : 'width']: percent.value ? `${percent.value}%` : 'fit-content'
127-
}
125+
const value = `${Math.max(percent.value ?? 0, 0)}%`
126+
return props.orientation === 'vertical' ? { height: value } : { width: value }
128127
})
129128
130129
function isActive(index: number) {

src/theme/progress.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default (options: Required<ModuleOptions>) => ({
55
root: 'gap-2',
66
base: 'relative overflow-hidden rounded-full bg-accented',
77
indicator: 'rounded-full size-full transition-transform duration-200 ease-out',
8-
status: 'flex justify-end text-dimmed transition-[width] duration-200',
8+
status: 'flex text-dimmed transition-[width] duration-200',
99
steps: 'grid items-end',
1010
step: 'truncate text-end row-start-1 col-start-1 transition-opacity'
1111
},
@@ -74,12 +74,12 @@ export default (options: Required<ModuleOptions>) => ({
7474
horizontal: {
7575
root: 'w-full flex flex-col',
7676
base: 'w-full',
77-
status: 'flex-row'
77+
status: 'flex-row items-center justify-end min-w-fit'
7878
},
7979
vertical: {
8080
root: 'h-full flex flex-row-reverse',
8181
base: 'h-full',
82-
status: 'flex-col'
82+
status: 'flex-col justify-end min-h-fit'
8383
}
8484
},
8585
inverted: {

test/components/__snapshots__/Progress-vue.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports[`Progress > renders with color neutral correctly 1`] = `
7272

7373
exports[`Progress > renders with max correctly 1`] = `
7474
"<div class="gap-2 w-full flex flex-col">
75-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm flex-row" style="width: 50%;">50% </div>
75+
<div class="flex text-dimmed transition-[width] duration-200 text-sm flex-row items-center justify-end min-w-fit" style="width: 50%;">50% </div>
7676
<div aria-valuemax="4" aria-valuemin="0" aria-valuenow="2" aria-label="50%" role="progressbar" data-state="loading" data-value="2" data-max="4" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
7777
<div data-state="loading" data-value="2" data-max="4" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(-50%);"></div>
7878
</div>
@@ -88,7 +88,7 @@ exports[`Progress > renders with max correctly 1`] = `
8888

8989
exports[`Progress > renders with max inverted correctly 1`] = `
9090
"<div class="gap-2 w-full flex flex-col">
91-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm self-end flex-row-reverse" style="width: 50%;">50% </div>
91+
<div class="flex text-dimmed transition-[width] duration-200 text-sm items-center justify-end min-w-fit self-end flex-row-reverse" style="width: 50%;">50% </div>
9292
<div aria-valuemax="4" aria-valuemin="0" aria-valuenow="2" aria-label="50%" role="progressbar" data-state="loading" data-value="2" data-max="4" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
9393
<div data-state="loading" data-value="2" data-max="4" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(50%);"></div>
9494
</div>
@@ -204,7 +204,7 @@ exports[`Progress > renders with size xs correctly 1`] = `
204204

205205
exports[`Progress > renders with status correctly 1`] = `
206206
"<div class="gap-2 w-full flex flex-col">
207-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm flex-row" style="width: 50%;">50% </div>
207+
<div class="flex text-dimmed transition-[width] duration-200 text-sm flex-row items-center justify-end min-w-fit" style="width: 50%;">50% </div>
208208
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="50" aria-label="50%" role="progressbar" data-state="loading" data-value="50" data-max="100" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
209209
<div data-state="loading" data-value="50" data-max="100" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(-50%);"></div>
210210
</div>
@@ -214,7 +214,7 @@ exports[`Progress > renders with status correctly 1`] = `
214214

215215
exports[`Progress > renders with status inverted correctly 1`] = `
216216
"<div class="gap-2 w-full flex flex-col">
217-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm self-end flex-row-reverse" style="width: 50%;">50% </div>
217+
<div class="flex text-dimmed transition-[width] duration-200 text-sm items-center justify-end min-w-fit self-end flex-row-reverse" style="width: 50%;">50% </div>
218218
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="50" aria-label="50%" role="progressbar" data-state="loading" data-value="50" data-max="100" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
219219
<div data-state="loading" data-value="50" data-max="100" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(50%);"></div>
220220
</div>

test/components/__snapshots__/Progress.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports[`Progress > renders with color neutral correctly 1`] = `
7272

7373
exports[`Progress > renders with max correctly 1`] = `
7474
"<div class="gap-2 w-full flex flex-col">
75-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm flex-row" style="width: 50%;">50% </div>
75+
<div class="flex text-dimmed transition-[width] duration-200 text-sm flex-row items-center justify-end min-w-fit" style="width: 50%;">50% </div>
7676
<div aria-valuemax="4" aria-valuemin="0" aria-valuenow="2" aria-label="50%" role="progressbar" data-state="loading" data-value="2" data-max="4" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
7777
<div data-state="loading" data-value="2" data-max="4" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(-50%);"></div>
7878
</div>
@@ -88,7 +88,7 @@ exports[`Progress > renders with max correctly 1`] = `
8888

8989
exports[`Progress > renders with max inverted correctly 1`] = `
9090
"<div class="gap-2 w-full flex flex-col">
91-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm self-end flex-row-reverse" style="width: 50%;">50% </div>
91+
<div class="flex text-dimmed transition-[width] duration-200 text-sm items-center justify-end min-w-fit self-end flex-row-reverse" style="width: 50%;">50% </div>
9292
<div aria-valuemax="4" aria-valuemin="0" aria-valuenow="2" aria-label="50%" role="progressbar" data-state="loading" data-value="2" data-max="4" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
9393
<div data-state="loading" data-value="2" data-max="4" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(50%);"></div>
9494
</div>
@@ -204,7 +204,7 @@ exports[`Progress > renders with size xs correctly 1`] = `
204204

205205
exports[`Progress > renders with status correctly 1`] = `
206206
"<div class="gap-2 w-full flex flex-col">
207-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm flex-row" style="width: 50%;">50% </div>
207+
<div class="flex text-dimmed transition-[width] duration-200 text-sm flex-row items-center justify-end min-w-fit" style="width: 50%;">50% </div>
208208
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="50" aria-label="50%" role="progressbar" data-state="loading" data-value="50" data-max="100" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
209209
<div data-state="loading" data-value="50" data-max="100" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(-50%);"></div>
210210
</div>
@@ -214,7 +214,7 @@ exports[`Progress > renders with status correctly 1`] = `
214214

215215
exports[`Progress > renders with status inverted correctly 1`] = `
216216
"<div class="gap-2 w-full flex flex-col">
217-
<div class="flex justify-end text-dimmed transition-[width] duration-200 text-sm self-end flex-row-reverse" style="width: 50%;">50% </div>
217+
<div class="flex text-dimmed transition-[width] duration-200 text-sm items-center justify-end min-w-fit self-end flex-row-reverse" style="width: 50%;">50% </div>
218218
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="50" aria-label="50%" role="progressbar" data-state="loading" data-value="50" data-max="100" class="relative overflow-hidden rounded-full bg-accented w-full h-2" style="transform: translateZ(0);">
219219
<div data-state="loading" data-value="50" data-max="100" class="rounded-full size-full transition-transform duration-200 ease-out bg-primary data-[state=indeterminate]:animate-[carousel_2s_ease-in-out_infinite] data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_ease-in-out_infinite]" style="transform: translateX(50%);"></div>
220220
</div>

0 commit comments

Comments
 (0)