diff --git a/src/components/GraphChannelList/index.module.scss b/src/components/GraphChannelList/index.module.scss index 6ccecbe1a..399a0e332 100644 --- a/src/components/GraphChannelList/index.module.scss +++ b/src/components/GraphChannelList/index.module.scss @@ -1,3 +1,6 @@ +@import '../../styles/variables.module'; +@import '../../styles/text.module'; + .container { font-size: 0.875rem; @@ -12,14 +15,20 @@ dl { display: flex; gap: 4px; + + @media screen and (width <= $mobileBreakPoint) { + display: block; + } } dl, dd, dt { margin: 0; - white-space: pre; - flex-wrap: wrap; + + /* white-space: pre; */ + + /* flex-wrap: wrap; */ } dt { @@ -34,41 +43,15 @@ gap: 4px; } - .general { - dd { - .content { - & > *:first-child { - display: none; - } - - @media screen and (width<800px) { - & > *:first-child { - display: flex; - } - - & > *:last-child { - display: none; - } - } - } - - .content[data-is-full-width='false'] { - & > *:first-child { - display: flex; - } - - & > *:last-child { - display: none; - } - } - } - } - .channel { margin-bottom: 4px; background: #fff; padding: 8px 40px; + @media screen and (width <= $largeBreakPoint) { + padding: 8px; + } + h1 { font-size: 1.2rem; } @@ -76,11 +59,29 @@ .funding { display: flex; + gap: 4px; + flex-wrap: nowrap; + overflow: hidden; + + dd { + overflow: hidden; + } + + a.address { + @extend %hash; - .funder { - flex: 0.4; + min-width: 180px; + } + } + + .outPoint { + dd { overflow: hidden; } + + a { + @extend %hash; + } } .nodesContainer { @@ -89,6 +90,12 @@ padding: 8px; margin-top: 8px; background: rgb(0 0 0 / 3%); + + dt, + dd { + display: flex; + flex-wrap: nowrap; + } } .nodes { @@ -114,9 +121,18 @@ .node { flex: 1; + overflow: hidden; + + dd { + overflow: hidden; + } + + a { + @extend %hash; + } } - @media screen and (width<690px) { + @media screen and (width <= $mobileBreakPoint) { flex-direction: column; } } diff --git a/src/components/GraphChannelList/index.tsx b/src/components/GraphChannelList/index.tsx index 480b9705b..1653f4cac 100644 --- a/src/components/GraphChannelList/index.tsx +++ b/src/components/GraphChannelList/index.tsx @@ -7,23 +7,18 @@ import type { Fiber } from '../../services/ExplorerService/fetcher' import { parseNumericAbbr } from '../../utils/chart' import { localeNumberString } from '../../utils/number' import { shannonToCkb } from '../../utils/util' -import AddressText from '../AddressText' import styles from './index.module.scss' const TIME_TEMPLATE = 'YYYY/MM/DD hh:mm:ss' -const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; isFullWidth?: boolean; node?: string }> = ({ - list, - isFullWidth = true, - node, -}) => { +const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; node?: string }> = ({ list, node }) => { if (!list.length) { return
No Channels
} return (
- {list.map(channel => { + {list.map((channel, i) => { const outPoint = { txHash: channel.channelOutpoint.slice(0, -8), index: parseInt(channel.channelOutpoint.slice(-8), 16), @@ -39,23 +34,21 @@ const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; isFullWidth?: boolean; ? parseNumericAbbr(channel.outpointInfo.fundingUdtAmount) : null + const outpoint = `${outPoint.txHash}#${outPoint.index}` + return (
-

General

-
+

Channel #{i + 1}

+
Out Point
-
- - - {`${outPoint.txHash.slice(0, 6)}...${outPoint.txHash.slice(-6)}#${outPoint.index}`} - - + - {`${outPoint.txHash}#${outPoint.index}`} +
{outpoint.slice(0, -15)}
+
{outpoint.slice(-15)}
-
+ @@ -71,57 +64,38 @@ const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; isFullWidth?: boolean;
-
Funding
-
- - {`${fundingCkbAmount} CKB`} - - {fundingUdtAmount ? '&' : null} - {fundingUdtAmount} - from -
- - {channel.outpointInfo.fundingAddress} - -
-
-
- -
-
Chain Hash
+
Source
-
- - {`${channel.chainHash.slice(0, 8)}...${channel.chainHash.slice( - -8, - )}`} + {fundingUdtAmount || ( + + {`${fundingCkbAmount} CKB`} - {channel.chainHash} -
- + )} + from + + +
{channel.outpointInfo.fundingAddress.slice(0, -15)}
+
{channel.outpointInfo.fundingAddress.slice(-15)}
+ +
- -
-
Funded at
+
+
Position
- - {localeNumberString(channel.fundingTxBlockNumber)} - - (
{dayjs(+channel.lastUpdatedTimestamp).format(TIME_TEMPLATE)}
) + On + + + {localeNumberString(channel.fundingTxBlockNumber)} + +

Nodes

-
+

First Node @@ -131,10 +105,10 @@ const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; isFullWidth?: boolean;
ID
- {`0x${channel.node1.slice( - 0, - 8, - )}...${channel.node1.slice(-8)}`} + +
{`0x${channel.node1.slice(0, -8)}`}
+
{channel.node1.slice(-8)}
+
-
+
@@ -150,8 +159,10 @@ const GraphNode = () => {
{dayjs(+node.timestamp).format(TIME_TEMPLATE)}
-
{t('fiber.graph.node.chain_hash')}
-
{node.chainHash}
+
{t('fiber.graph.node.chain')}
+
+ {chain} +
{t('fiber.graph.node.total_capacity')}
@@ -185,8 +196,23 @@ const GraphNode = () => {

-

Open | Close Transactions

- Coming soon +

+ Open Transactions + (Close transactions coming soon) +

+
+ {openTxs.map(tx => ( +
+ Open Channel by + + +
{tx.hash.slice(0, -15)}
+
{tx.hash.slice(-15)}
+ +
+
+ ))} +
diff --git a/src/pages/Fiber/GraphNodeList/index.tsx b/src/pages/Fiber/GraphNodeList/index.tsx index 00d1958ca..0dcc283d4 100644 --- a/src/pages/Fiber/GraphNodeList/index.tsx +++ b/src/pages/Fiber/GraphNodeList/index.tsx @@ -16,6 +16,7 @@ import styles from './index.module.scss' import { shannonToCkb } from '../../../utils/util' import { parseNumericAbbr } from '../../../utils/chart' import { localeNumberString } from '../../../utils/number' +import { ChainHash } from '../../../constants/fiberChainHash' const TIME_TEMPLATE = 'YYYY/MM/DD hh:mm:ss' @@ -109,14 +110,13 @@ const fields = [ }, { key: 'chainHash', - label: 'chain_hash', + label: 'chain', transformer: (v: unknown) => { if (typeof v !== 'string') return v + const chain = ChainHash.get(v) ?? '-' return ( - - {`${v.slice(0, 8)}...${v.slice(-8)}`} - + {chain} diff --git a/src/styles/text.module.scss b/src/styles/text.module.scss new file mode 100644 index 000000000..cbb2415db --- /dev/null +++ b/src/styles/text.module.scss @@ -0,0 +1,21 @@ +%monospace { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; +} + +%hash { + @extend %monospace; + + display: flex; + align-items: center; + overflow: hidden; + user-select: none; + + div { + font-family: inherit; + } + + div:first-child { + overflow: hidden; + text-overflow: ellipsis; + } +}