Skip to content

Commit 0d8dcf6

Browse files
authored
fix(components): fix Meter max styling (#1691)
* fix(components): fix `Meter` max styling * fix: update progress bar * fix: apply suggestion
1 parent ecd067b commit 0d8dcf6

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

.changeset/wet-yaks-lick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@launchpad-ui/components": patch
3+
---
4+
5+
Fix `Meter` max styling

packages/components/src/Meter.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { VariantProps } from 'class-variance-authority';
22
import type { Ref } from 'react';
33
import type { MeterProps as AriaMeterProps, ContextValue } from 'react-aria-components';
44

5-
import { cva } from 'class-variance-authority';
5+
import { cva, cx } from 'class-variance-authority';
66
import { createContext } from 'react';
77
import { Meter as AriaMeter, Text, composeRenderProps } from 'react-aria-components';
88

@@ -86,7 +86,10 @@ const Meter = ({ ref, ...props }: MeterProps) => {
8686
{children}
8787
<Text className={styles.value}>{valueText}</Text>
8888
<div className={styles.track}>
89-
<div className={styles.fill} style={{ width: `${percentage}%` }} />
89+
<div
90+
className={cx(styles.fill, { [styles.max]: percentage === 100 })}
91+
style={{ width: `${percentage}%` }}
92+
/>
9093
</div>
9194
</>
9295
)}

packages/components/src/ProgressBar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ const ProgressBar = ({ ref, ...props }: ProgressBarProps) => {
100100
{children}
101101
<Text className={styles.value}>{valueText}</Text>
102102
<div className={styles.track}>
103-
<div className={styles.fill} style={{ width: `${percentage}%` }} />
103+
<div
104+
className={cx(styles.fill, { [styles.max]: percentage === 100 })}
105+
style={{ width: `${percentage}%` }}
106+
/>
104107
</div>
105108
</>
106109
)}

packages/components/src/styles/Meter.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
height: 100%;
4444
}
4545

46+
.max {
47+
border-radius: var(--lp-border-radius-medium);
48+
}
49+
4650
.text {
4751
fill: var(--lp-color-text-ui-primary-base);
4852
font: var(--lp-text-body-1-semibold);

packages/components/src/styles/ProgressBar.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
height: 100%;
5454
}
5555

56+
.max {
57+
border-radius: var(--lp-border-radius-medium);
58+
}
59+
5660
.base {
5761
height: var(--lp-size-64);
5862
width: var(--lp-size-64);

0 commit comments

Comments
 (0)