Skip to content

Commit

Permalink
fix(evm): add max 2 decimals places for baby point (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored Jan 13, 2025
1 parent eabd12f commit af8782c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions apps/evm/src/components/AnimantedAmount/AnimantedAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Props = {
gap?: FlexProps['gap'];
showAnimation?: boolean;
shouldRoundDown?: boolean;
maximumFractionDigits?: number;
};

type InheritAttrs = Omit<SpanProps, keyof Props>;
Expand All @@ -26,6 +27,7 @@ const AnimantedAmount = ({
gap = 'xs',
showAnimation,
shouldRoundDown,
maximumFractionDigits = 0,
...props
}: AnimantedAmountProps) => {
const [start, setStart] = useState(0);
Expand All @@ -36,10 +38,10 @@ const AnimantedAmount = ({
Intl.NumberFormat(locale, {
notation: compact ? 'compact' : undefined,
roundingMode: shouldRoundDown ? 'floor' : undefined,
maximumFractionDigits: 0
maximumFractionDigits
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any).format(value),
[compact, shouldRoundDown, locale]
[compact, shouldRoundDown, maximumFractionDigits, locale]
);

const { value, reset } = useCountUp({
Expand Down
7 changes: 6 additions & 1 deletion apps/evm/src/components/BabyPoints/BabyPoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { AnimantedAmount, AnimantedAmountProps } from '../AnimantedAmount';
type BabyPointsProps = Omit<AnimantedAmountProps, 'icon'>;

const BabyPoints = (props: BabyPointsProps) => (
<AnimantedAmount shouldRoundDown icon={<Babylon style={{ width: '1em', height: '1em' }} />} {...props} />
<AnimantedAmount
shouldRoundDown
icon={<Babylon style={{ width: '1em', height: '1em' }} />}
maximumFractionDigits={2}
{...props}
/>
);

export { BabyPoints };

0 comments on commit af8782c

Please sign in to comment.