Skip to content

Commit a96f772

Browse files
authored
fix(ProgressBar): allow value to be above maximum (#4855)
1 parent a775764 commit a96f772

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.changeset/tasty-olives-flash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/ui": patch
3+
---
4+
5+
Fix `<ProgressBar />` to allow values above the maximum value
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Template } from './Template.stories'
2+
3+
export const Overflow = Template.bind({})
4+
5+
Overflow.args = {
6+
label: 'Storage',
7+
value: 110,
8+
max: 100,
9+
suffix: '%',
10+
showProgress: true,
11+
sentiment: 'danger',
12+
}

packages/ui/src/components/ProgressBar/__stories__/index.stories.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ export { Direction } from './Direction.stories'
1515
export { ShowProgress } from './ShowProgress.stories'
1616
export { PrefixSuffix } from './PrefixSuffix.stories'
1717
export { Max } from './Max.stories'
18+
export { Overflow } from './Overflow.stories'

packages/ui/src/components/ProgressBar/index.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ export const ProgressBar = ({
131131
placement="right"
132132
>
133133
{prefix}
134-
{suffix === '%'
135-
? (100 * Math.max(0, Math.min(max, value))) / max
136-
: Math.max(0, Math.min(max, value))}
134+
{suffix === '%' ? (100 * value) / max : value}
137135
{suffix}
138136
</Text>
139137
) : null}
@@ -169,9 +167,7 @@ export const ProgressBar = ({
169167
<StyledStack direction="row" gap={1}>
170168
<StyledText as="label" variant="bodySmall" sentiment="neutral">
171169
{prefix}
172-
{suffix === '%'
173-
? (100 * Math.max(0, Math.min(max, value))) / max
174-
: Math.max(0, Math.min(max, value))}
170+
{suffix === '%' ? (100 * value) / max : value}
175171
{suffix}
176172
</StyledText>
177173
</StyledStack>

0 commit comments

Comments
 (0)