-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the structure and logic for table cells
- Loading branch information
1 parent
af0b403
commit 6da5a2a
Showing
10 changed files
with
129 additions
and
108 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
dapp/src/components/TransactionHistory/Table/Cell/Custom.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react" | ||
import { TransactionInfo } from "#/types" | ||
import Cell from "." | ||
import { ContentType, getCustomContent } from "./utils/content" | ||
|
||
function CustomCell({ | ||
type, | ||
transaction1, | ||
transaction2, | ||
}: { | ||
type: ContentType | ||
transaction1: TransactionInfo | ||
transaction2: TransactionInfo | ||
}) { | ||
if (type === "date") { | ||
return <Cell children1={getCustomContent(type, transaction1)} /> | ||
} | ||
|
||
return ( | ||
<Cell | ||
children1={getCustomContent(type, transaction1)} | ||
children2={getCustomContent(type, transaction2)} | ||
/> | ||
) | ||
} | ||
|
||
export default CustomCell |
21 changes: 21 additions & 0 deletions
21
dapp/src/components/TransactionHistory/Table/Cell/components/BlockExplorer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react" | ||
import { Chain, ExplorerDataType } from "#/types" | ||
import { BLOCK_EXPLORER } from "#/constants" | ||
import ViewInBlockExplorer from "#/components/shared/ViewInBlockExplorer" | ||
import SimpleText from "./SimpleText" | ||
|
||
function BlockExplorer({ txHash, chain }: { txHash?: string; chain: Chain }) { | ||
if (txHash) { | ||
return ( | ||
<ViewInBlockExplorer | ||
id={txHash} | ||
type={ExplorerDataType.TRANSACTION} | ||
chain={chain} | ||
size="sm" | ||
/> | ||
) | ||
} | ||
return <SimpleText color="grey.400">{BLOCK_EXPLORER[chain].title}</SimpleText> | ||
} | ||
|
||
export default BlockExplorer |
9 changes: 9 additions & 0 deletions
9
dapp/src/components/TransactionHistory/Table/Cell/components/SimpleText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react" | ||
import { TextSm } from "#/components/shared/Typography" | ||
import { TextProps } from "@chakra-ui/react" | ||
|
||
function SimpleText({ ...textProps }: TextProps) { | ||
return <TextSm fontWeight="semibold" {...textProps} /> | ||
} | ||
|
||
export default SimpleText |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
dapp/src/components/TransactionHistory/Table/Cell/utils/content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react" | ||
import { TransactionInfo } from "#/types" | ||
import { CurrencyBalance } from "#/components/shared/CurrencyBalance" | ||
import CurrencyIcon from "#/components/shared/CurrencyIcon" | ||
import { displayBlockTimestamp } from "#/utils" | ||
import BlockExplorer from "../components/BlockExplorer" | ||
import SimpleText from "../components/SimpleText" | ||
import Status from "../components/Status" | ||
|
||
export type ContentType = | ||
| "currency-balance" | ||
| "block-explorer" | ||
| "currency-icon" | ||
| "date" | ||
| "status" | ||
|
||
export const getCustomContent = ( | ||
type: ContentType, | ||
transaction: TransactionInfo, | ||
) => { | ||
switch (type) { | ||
case "currency-balance": | ||
return ( | ||
<CurrencyBalance | ||
currency={transaction.asset.currency} | ||
amount={transaction.asset.amount} | ||
size="sm" | ||
/> | ||
) | ||
case "block-explorer": { | ||
return ( | ||
<BlockExplorer txHash={transaction.txHash} chain={transaction.chain} /> | ||
) | ||
} | ||
case "currency-icon": { | ||
return <CurrencyIcon currency={transaction.asset.currency} withSymbol /> | ||
} | ||
case "date": { | ||
return ( | ||
<SimpleText whiteSpace="pre-line"> | ||
{displayBlockTimestamp(transaction.timestamp)} | ||
</SimpleText> | ||
) | ||
} | ||
case "status": { | ||
return <Status status={transaction.status} /> | ||
} | ||
default: | ||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
return <></> | ||
} | ||
} |
77 changes: 0 additions & 77 deletions
77
dapp/src/components/TransactionHistory/Table/Cells/CustomCell.tsx
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
dapp/src/components/TransactionHistory/Table/Cells/TextCell.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters