Skip to content

Commit 39d98a9

Browse files
authored
fix: value length at progress bar when unit is percentage (#7439)
2 parents 6807980 + 1c7366c commit 39d98a9

15 files changed

+9
-9
lines changed

packages/components/src/components/progress/shadow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class KolProgress implements ProgressAPI {
9696
</div>
9797
)}
9898
{this.state._variant == 'bar' && (
99-
<div class="value" style={{ width: `${`${this.state._max}`.length}ch` }}>
99+
<div class="value" style={{ width: `${`${(isPercentage ? 100 : this.state._max) + 1}`.length}ch` }}>
100100
{displayValue}
101101
</div>
102102
)}

packages/components/src/components/progress/test/__snapshots__/snapshot.spec.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exports[`kol-progress should render with _label="Label" _variant="bar" _max=42 _
3939
<rect class="border" fill="currentColor" height="11" rx="5" stroke="currentColor" stroke-width="1" x="1" y="1" style="width: 100%;"></rect>
4040
<rect class="progress" fill="currentColor" height="7" rx="3.5" stroke="currentColor" stroke-width="3" x="3" y="3" style="width: calc(0% - 4px);"></rect>
4141
</svg>
42-
<div class="value" style="width: 2ch;">
42+
<div class="value" style="width: 3ch;">
4343
0
4444
</div>
4545
<div class="unit">
@@ -66,7 +66,7 @@ exports[`kol-progress should render with _label="Label" _variant="bar" _max=42 _
6666
<rect class="border" fill="currentColor" height="11" rx="5" stroke="currentColor" stroke-width="1" x="1" y="1" style="width: 100%;"></rect>
6767
<rect class="progress" fill="currentColor" height="7" rx="3.5" stroke="currentColor" stroke-width="3" x="3" y="3" style="width: calc(40.476190476190474% - 4px);"></rect>
6868
</svg>
69-
<div class="value" style="width: 2ch;">
69+
<div class="value" style="width: 3ch;">
7070
40
7171
</div>
7272
<div class="unit">
@@ -120,7 +120,7 @@ exports[`kol-progress should render with _label="Label" _variant="bar" _max=42 _
120120
<rect class="border" fill="currentColor" height="11" rx="5" stroke="currentColor" stroke-width="1" x="1" y="1" style="width: 100%;"></rect>
121121
<rect class="progress" fill="currentColor" height="7" rx="3.5" stroke="currentColor" stroke-width="3" x="3" y="3" style="width: calc(238.0952380952381% - 4px);"></rect>
122122
</svg>
123-
<div class="value" style="width: 2ch;">
123+
<div class="value" style="width: 3ch;">
124124
238
125125
</div>
126126
<div class="unit">

packages/samples/react/src/components/progress/basic.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export const ProgressBasic: FC = () => (
1313

1414
<div className="grid gap-4 grid-cols-1 sm:grid-cols-2">
1515
<fieldset title="Percentages" className="flex flex-col gap-4">
16-
<KolProgress _variant="bar" _max={100} _value={0}></KolProgress>
17-
<KolProgress _variant="bar" _max={100} _value={17}></KolProgress>
18-
<KolProgress _variant="bar" _max={100} _value={100}></KolProgress>
19-
<KolProgress _variant="cycle" _max={100} _value={85}></KolProgress>
16+
<KolProgress _variant="bar" _max={7} _value={0}></KolProgress>
17+
<KolProgress _variant="bar" _max={7} _value={2}></KolProgress>
18+
<KolProgress _variant="bar" _max={7} _value={7}></KolProgress>
19+
<KolProgress _variant="cycle" _max={7} _value={6}></KolProgress>
2020
</fieldset>
2121
<fieldset title="Custom units" className="flex flex-col gap-4">
2222
<KolProgress _label="Distance" _variant="bar" _max={65434} _value={7236} _unit="m"></KolProgress>
2323
<KolProgress _label="12 Tasks to do" _variant="bar" _max={12} _value={5} _unit="tasks completed"></KolProgress>
24-
<KolProgress _label="Max 150 kg" _variant="cycle" _max={150} _value={134} _unit="kg"></KolProgress>
24+
<KolProgress _label="Max 150 kg" _variant="cycle" _max={150} _value={42} _unit="kg"></KolProgress>
2525
</fieldset>
2626
</div>
2727
</>
1.87 KB
Loading
-697 Bytes
Loading
Binary file not shown.
Binary file not shown.
1.91 KB
Loading

0 commit comments

Comments
 (0)