Skip to content

Commit

Permalink
mobile ui
Browse files Browse the repository at this point in the history
  • Loading branch information
xieqiancaosissi committed Jan 1, 2024
1 parent 31ecec4 commit 32d0244
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 133 deletions.
2 changes: 1 addition & 1 deletion components/Modal/CollateralTypeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function CollateralTypeSelectorBorrow({
setShow(!show);
}}
>
<span className="text-sm text-gray-300 mr-2.5 whitespace-nowrap">
<span className="text-sm text-gray-300 mr-2.5 whitespace-nowrap xsm:max-w-[120px] overflow-hidden text-ellipsis">
{getName(selectedCollateralType)}
</span>
<ArrowDownIcon className={`${show ? " transform rotate-180" : ""}`} />
Expand Down
7 changes: 5 additions & 2 deletions components/Modal/TokenBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ArrowDownIcon } from "./svg";
import SelectToken, { IAssetType } from "../SelectToken";
import { IToken } from "../../interfaces/asset";
import { standardizeAsset } from "../../utils";
import { isMobileDevice } from "../../helpers/helpers";

export default function TokenBox({ asset, action }: { asset: UIAsset; action: string }) {
const [open, setOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -59,10 +60,12 @@ export default function TokenBox({ asset, action }: { asset: UIAsset; action: st
}
return (
<div
className="relative"
className="relative flex-shrink-0"
tabIndex={0}
onBlur={() => {
setOpen(false);
if (!isMobileDevice()) {
setOpen(false);
}
}}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const Modal = () => {
const activePosition =
action === "Repay" || action === "Borrow"
? selectedCollateralType
: tokenId.indexOf(lpTokenPrefix) > -1
: tokenId?.indexOf(lpTokenPrefix) > -1
? tokenId
: DEFAULT_POSITION;
const { maxBorrowAmount = 0, maxBorrowValue = 0 } =
Expand Down
2 changes: 1 addition & 1 deletion components/SelectToken/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function TokenList() {
<>
{rows.map((asset: IUIAsset) => (
<GetBalance
key={asset.symbol}
key={asset.tokenId}
asset={asset}
updateAsset={updateAsset}
setUpdateAsset={setUpdateAsset}
Expand Down
115 changes: 61 additions & 54 deletions screens/Market/table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "next/link";
import { useEffect, useState } from "react";
import React, { useEffect, useState } from "react";
import { TableProps } from "../../components/Table";
import { ArrowDownIcon, ArrowUpIcon, ArrowLineDownIcon, CheckIcon, NewTagIcon } from "./svg";
import type { UIAsset } from "../../interfaces";
Expand Down Expand Up @@ -262,42 +262,6 @@ function TableRow({
}, [Object.keys(borrowApyMap).length]);
const is_native = NATIVE_TOKENS?.includes(row.tokenId);
const is_new = NEW_TOKENS?.includes(row.tokenId);
return (
<div>
{isMobile ? (
<TableRowMobile
key={row.tokenId}
row={row}
lastRow={lastRow}
depositAPY={depositAPY}
borrowAPY={borrowAPY}
is_native={is_native}
is_new={is_new}
/>
) : (
<TableRowPc
key={row.tokenId}
row={row}
lastRow={lastRow}
is_native={is_native}
is_new={is_new}
/>
)}
</div>
);
}

function TableRowPc({
row,
lastRow,
is_native,
is_new,
}: {
row: UIAsset;
lastRow: boolean;
is_native: boolean;
is_new: boolean;
}) {
function getIcons() {
const { isLpToken, tokens } = row;
return (
Expand All @@ -316,7 +280,7 @@ function TableRowPc({
);
})
) : (
<img src={row.icon} alt="" className="w-[27px] h-[27px] rounded-full" />
<img src={row.icon} alt="" className="w-[26px] h-[26px] rounded-full" />
)}
</div>
);
Expand All @@ -338,7 +302,7 @@ function TableRowPc({
);
})
) : (
<span className="text-sm text-white">
<span className="text-sm text-white xsm:text-base">
{row.symbol}
{is_native ? (
<span className="text-gray-300 italic text-xs transform -translate-y-0.5 ml-0.5">
Expand All @@ -350,6 +314,50 @@ function TableRowPc({
</div>
);
}
return (
<div>
{isMobile ? (
<TableRowMobile
key={row.tokenId}
row={row}
lastRow={lastRow}
depositAPY={depositAPY}
borrowAPY={borrowAPY}
is_native={is_native}
is_new={is_new}
getIcons={getIcons}
getSymbols={getSymbols}
/>
) : (
<TableRowPc
key={row.tokenId}
row={row}
lastRow={lastRow}
is_native={is_native}
is_new={is_new}
getIcons={getIcons}
getSymbols={getSymbols}
/>
)}
</div>
);
}

function TableRowPc({
row,
lastRow,
is_native,
is_new,
getIcons,
getSymbols,
}: {
row: UIAsset;
lastRow: boolean;
is_native: boolean;
is_new: boolean;
getIcons: () => React.ReactNode;
getSymbols: () => React.ReactNode;
}) {
return (
<Link key={row.tokenId} href={`/tokenDetail/${row.tokenId}`}>
<div
Expand Down Expand Up @@ -454,39 +462,38 @@ function TableRowMobile({
borrowAPY,
is_native,
is_new,
getIcons,
getSymbols,
}: {
row: UIAsset;
lastRow: boolean;
depositAPY: number;
borrowAPY: number;
is_native: boolean;
is_new: boolean;
getIcons: () => React.ReactNode;
getSymbols: () => React.ReactNode;
}) {
return (
<Link key={row.tokenId} href={`/tokenDetail/${row.tokenId}`}>
<div className={`bg-gray-800 rounded-xl p-3.5 ${lastRow ? "" : "mb-4"}`}>
<div className="relative flex items-center pb-4 border-b border-dark-950">
<img src={row.icon} alt="" className="w-[26px] h-[26px] rounded-full" />
<div className="flex">
<span className="text-base text-white font-bold ml-2">{row.symbol}</span>
{is_native ? (
<span className="text-gray-300 italic text-xs transform translate-y-1.5 ml-0.5">
Native
</span>
) : null}
</div>
{is_new ? <NewTagIcon className="absolute bottom-2 transform -translate-x-1" /> : null}
<div className="relative flex items-center pb-4 border-b border-dark-950 -ml-1">
{getIcons()}
<div className="flex ml-2">{getSymbols()}</div>
{is_new ? (
<NewTagIcon
className={`absolute transform -translate-x-[1px] z-20 ${
row.isLpToken && row?.tokens?.length > 2 ? "bottom-2" : "bottom-1"
}`}
/>
) : null}
</div>
<div className="grid grid-cols-2 gap-y-5 pt-4">
<TemplateMobile
title="Total Supplied"
value={toInternationalCurrencySystem_number(row.totalSupply)}
subValue={toInternationalCurrencySystem_usd(row.totalSupplyMoney)}
/>
{/* <TemplateMobile
title="Supply APY"
value={row.can_deposit ? format_apy(depositAPY) : "-"}
/> */}
<TemplateMobileAPY title="Supply APY" row={row} canShow={row.can_deposit} />
<TemplateMobile
title="Total Borrowed"
Expand Down
Loading

0 comments on commit 32d0244

Please sign in to comment.