Skip to content

Commit

Permalink
Adds units in Preview Mode and Event List
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedobaid23 committed Aug 12, 2024
1 parent f6735f4 commit eb50b5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ let make = (
<div className="grid grid-cols-2 items-center gap-4 justify-around mt-4">
<div className="flex flex-col items-center text-center">
<div className="text-black font-bold text-xl">
{str(state.width->Belt.Float.toString)}
{str(`${state.width->Belt.Float.toString} cm`)}
</div>
<div className="text-sm text-secondary-700"> {str("Width")} </div>
</div>
<div className="flex flex-col items-center text-center">
<div className="text-black font-bold text-xl">
{str(state.length->Belt.Float.toString)}
{str(`${state.length->Belt.Float.toString} cm`)}
</div>
<div className="text-sm text-secondary-700"> {str("Length")} </div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
}

if (typeof value === "number") {
return value % 1 ? value.toFixed(2) : value;
const formattedValue = value % 1 ? value.toFixed(2) : value;

if (key === "length" || key === "width") {
return `${formattedValue} cm`;
}

return formattedValue;
}

if (typeof value === "string") {
Expand Down Expand Up @@ -74,7 +80,9 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
<span className="text-xs uppercase text-secondary-700">
{key.replaceAll(/_/g, " ")}
</span>
<span className="text-sm font-semibold capitalize text-secondary-700">
<span
className={`text-sm font-semibold text-secondary-700 ${key === "length" || key === "width" ? "" : "capitalize"}`}
>
{formatValue(value, key)}
</span>
</div>
Expand Down

0 comments on commit eb50b5d

Please sign in to comment.