Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3100 from cardano-foundation/fix/display-value-co…
Browse files Browse the repository at this point in the history
…st-model-transaction

fix: display value cost model in ios
  • Loading branch information
Sotatek-TaiTruong authored Mar 4, 2024
2 parents aa429e8 + 95d8b3a commit 223bea3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/commons/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const getShortHashXs = (address = "", firstpart?: number, lastPart?: numb
if (address?.length <= 18) return address;
return address ? `${address.slice(0, firstpart ? firstpart : 7)}...${address.slice(-(lastPart ? lastPart : 5))}` : "";
};
export const getShortValue = (address = "", length = 50) => {
return address.slice(0, length);
};

export const LARGE_NUMBER_ABBREVIATIONS = ["", "K", "M", "B", "T", "q", "Q", "s", "S"];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
import { Column } from "src/components/commons/Table";
import ParseScriptModal from "src/components/ParseScriptModal";
import CustomTooltip from "src/components/commons/CustomTooltip";
import { getShortValue } from "src/commons/utils/helper";

import { LimitCell, TableProtocol, UpdatedValue, Wrapper } from "./styles";

Expand Down Expand Up @@ -39,7 +40,7 @@ const ProtocolUpdate: React.FC<IProps> = ({ data }) => {
onClick={() => r.protocol === "costModel" && setCostModelScript(r.oldValue?.toString() || "")}
color={({ palette }) => (r.protocol === "costModel" ? palette.primary.main : "unset")}
>
<LimitCell> {r.oldValue}</LimitCell>
<LimitCell>{getShortValue(r.oldValue?.toString())}</LimitCell>
</UpdatedValue>
</CustomTooltip>
);
Expand All @@ -59,7 +60,7 @@ const ProtocolUpdate: React.FC<IProps> = ({ data }) => {
onClick={() => r.protocol === "costModel" && setCostModelScript(r.value?.toString() || "")}
color={({ palette }) => (r.protocol === "costModel" ? palette.primary.main : "unset")}
>
<LimitCell>{r.value}</LimitCell>
<LimitCell>{getShortValue(r.value?.toString())}</LimitCell>
</UpdatedValue>
</CustomTooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ export const LimitCell = styled(Box)`
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
${({ theme }) => theme.breakpoints.between("xs", "sm")} {
max-width: 120px;
}
${({ theme }) => theme.breakpoints.between("sm", "md")} {
max-width: 220px;
}
`;

0 comments on commit 223bea3

Please sign in to comment.