Skip to content

Commit

Permalink
fix: commify fails when string contains < or >, responsiveness issues…
Browse files Browse the repository at this point in the history
… in mobile
  • Loading branch information
kemuru committed Feb 7, 2025
1 parent c0c8158 commit 59b50e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions web/src/components/NumberDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import { Tooltip } from "@kleros/ui-components-library";

import { commify } from "utils/commify";

interface INumberDisplay {
value: string | number;
unit?: string;
Expand All @@ -21,7 +22,7 @@ const getFormattedValue = (value: number, decimals: number) => {
return `> -0.${"0".repeat(decimals - 1)}1`;
}
}
return withFixedDecimals;
return commify(withFixedDecimals);
};

const NumberDisplay: React.FC<INumberDisplay> = ({
Expand All @@ -33,8 +34,8 @@ const NumberDisplay: React.FC<INumberDisplay> = ({
isCurrency = false,
}) => {
const parsedValue = Number(value);
const formattedValue = commify(getFormattedValue(parsedValue, decimals));
const tooltipValue = isCurrency ? `${unit} ${value}` : `${value} ${unit}`;
const formattedValue = getFormattedValue(parsedValue, decimals);
const tooltipValue = isCurrency ? `${unit} ${commify(value)}` : `${commify(value)} ${unit}`;
const displayUnit = showUnitInDisplay ? unit : "";
const displayValue = isCurrency ? `${displayUnit} ${formattedValue}` : `${formattedValue} ${displayUnit}`;
return (
Expand Down
3 changes: 2 additions & 1 deletion web/src/pages/Profile/Stakes/CourtCard/CourtName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const Container = styled.div`
display: flex;
width: 100%;
flex-direction: row;
gap: 16px;
gap: 8px 16px;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
small {
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Profile/Stakes/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const TotalStakeAndLockedPnk = styled.div`

const StyledPnkIcon = styled(PnkIcon)`
fill: ${({ theme }) => theme.secondaryPurple};
width: 14px;
width: 16px;
`;

const StyledLockerIcon = styled(LockerIcon)`
Expand Down

0 comments on commit 59b50e9

Please sign in to comment.