diff --git a/apps/explorer/src/app/components/blocks/block-data.tsx b/apps/explorer/src/app/components/blocks/block-data.tsx new file mode 100644 index 000000000..419c3b235 --- /dev/null +++ b/apps/explorer/src/app/components/blocks/block-data.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { BlockMeta } from '../../routes/blocks/tendermint-blockchain-response'; +import { Link } from 'react-router-dom'; +import { SecondsAgo } from '../seconds-ago'; +import { Table, TableRow, TableCell } from '../table'; + +interface BlockProps { + block: BlockMeta; +} + +export const BlockData = ({ block }: BlockProps) => { + return ( + + + + + {block.header?.height} + + + + {block.num_txs === '1' + ? '1 transaction' + : `${block.num_txs} transactions`} + + + + {block.header.proposer_address} + + + + + + +
+ ); +}; diff --git a/apps/explorer/src/app/components/blocks/blocks-data.tsx b/apps/explorer/src/app/components/blocks/blocks-data.tsx new file mode 100644 index 000000000..1111235c2 --- /dev/null +++ b/apps/explorer/src/app/components/blocks/blocks-data.tsx @@ -0,0 +1,29 @@ +import React from 'react'; +import { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; +import { BlockData } from './block-data'; + +interface BlocksProps { + data: TendermintBlockchainResponse | undefined; + className?: string; +} + +export const BlocksData = ({ data, className }: BlocksProps) => { + if (!data?.result) { + return
Awaiting block data
; + } + + return ( + + ); +}; diff --git a/apps/explorer/src/app/components/blocks/home/blocks-refetch.tsx b/apps/explorer/src/app/components/blocks/blocks-refetch.tsx similarity index 100% rename from apps/explorer/src/app/components/blocks/home/blocks-refetch.tsx rename to apps/explorer/src/app/components/blocks/blocks-refetch.tsx diff --git a/apps/explorer/src/app/components/blocks/home/blocks-table.tsx b/apps/explorer/src/app/components/blocks/home/blocks-table.tsx deleted file mode 100644 index 9c69f89ad..000000000 --- a/apps/explorer/src/app/components/blocks/home/blocks-table.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react'; -import { TendermintBlockchainResponse } from '../../../routes/blocks/tendermint-blockchain-response'; -import { Link } from 'react-router-dom'; -import { SecondsAgo } from '../../seconds-ago'; -import { TxsPerBlock } from '../../txs/txs-per-block'; -import { Table, TableRow, TableCell } from '../../table'; - -interface BlocksProps { - data: TendermintBlockchainResponse | undefined; - showTransactions?: boolean; -} - -export const BlocksTable = ({ data, showTransactions }: BlocksProps) => { - if (!data?.result) { - return
Awaiting block data
; - } - - return ( - - {data.result?.block_metas?.map((block, index) => { - return ( - - - - - {block.header?.height} - - - - {block.num_txs === '1' - ? '1 transaction' - : `${block.num_txs} transactions`} - - - - {block.header.proposer_address} - - - - - - - {showTransactions && ( - - - - )} - - ); - })} -
- ); -}; diff --git a/apps/explorer/src/app/components/blocks/index.tsx b/apps/explorer/src/app/components/blocks/index.tsx index f829fcae7..2f4a52141 100644 --- a/apps/explorer/src/app/components/blocks/index.tsx +++ b/apps/explorer/src/app/components/blocks/index.tsx @@ -1,2 +1,3 @@ -export { BlocksTable } from './home/blocks-table'; -export { BlocksRefetch } from './home/blocks-refetch'; +export { BlocksData } from './blocks-data'; +export { BlockData } from './block-data'; +export { BlocksRefetch } from './blocks-refetch'; diff --git a/apps/explorer/src/app/components/table/index.tsx b/apps/explorer/src/app/components/table/index.tsx index ba62f2de2..59fe44991 100644 --- a/apps/explorer/src/app/components/table/index.tsx +++ b/apps/explorer/src/app/components/table/index.tsx @@ -1,59 +1,70 @@ import React, { ThHTMLAttributes } from 'react'; import classnames from 'classnames'; -interface TableProps { - children: React.ReactNode; -} - -interface TableHeaderProps extends ThHTMLAttributes { +interface TableProps extends ThHTMLAttributes { children: React.ReactNode; className?: string; } -interface TableChildProps { +interface TableHeaderProps + extends ThHTMLAttributes { + children: React.ReactNode; + className?: string; +} + +interface TableRowProps extends ThHTMLAttributes { children: React.ReactNode; className?: string; dataTestId?: string; modifier?: 'bordered' | 'background'; } -export const Table = ({ children }: TableProps) => { +interface TableCellProps extends ThHTMLAttributes { + children: React.ReactNode; + className?: string; + dataTestId?: string; + modifier?: 'bordered' | 'background'; +} + +export const Table = ({ children, className, ...props }: TableProps) => { + const classes = classnames(className, 'overflow-x-auto whitespace-nowrap'); return ( -
- +
+
{children}
); }; -export const TableRow = ({ - children, - className, - dataTestId, - modifier, -}: TableChildProps) => { - const cellClasses = classnames(className, { - 'border-b border-white-40': modifier === 'bordered', - 'bg-white-25 border-b-4 border-b-black': modifier === 'background', - }); - return ( - - {children} - - ); -}; - export const TableHeader = ({ children, className, ...props }: TableHeaderProps) => { const cellClasses = classnames(className, { - 'text-left, font-normal': props?.scope === 'row', + 'text-left font-normal': props?.scope === 'row', }); return ( - + + {children} + + ); +}; + +export const TableRow = ({ + children, + className, + dataTestId, + modifier, + ...props +}: TableRowProps) => { + const cellClasses = classnames(className, { + 'border-b border-white-40': modifier === 'bordered', + 'bg-white-25 border-b-4 border-b-black': modifier === 'background', + }); + return ( + {children} ); @@ -64,12 +75,13 @@ export const TableCell = ({ className, dataTestId, modifier, -}: TableChildProps) => { + ...props +}: TableCellProps) => { const cellClasses = classnames(className, { 'py-4': modifier === 'bordered', }); return ( - + {children} ); diff --git a/apps/explorer/src/app/components/txs/home/txs-data.tsx b/apps/explorer/src/app/components/txs/home/txs-data.tsx new file mode 100644 index 000000000..005bd4854 --- /dev/null +++ b/apps/explorer/src/app/components/txs/home/txs-data.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { TendermintBlockchainResponse } from '../../../routes/blocks/tendermint-blockchain-response'; +import { BlockData } from '../../blocks'; +import { TxsPerBlock } from '../txs-per-block'; + +interface TxsProps { + data: TendermintBlockchainResponse | undefined; + className?: string; +} + +export const TxsData = ({ data, className }: TxsProps) => { + if (!data?.result) { + return
Awaiting block data
; + } + + return ( +
    + {data.result?.block_metas?.map((block, index) => { + return ( +
  • + + +
  • + ); + })} +
+ ); +}; diff --git a/apps/explorer/src/app/components/txs/index.tsx b/apps/explorer/src/app/components/txs/index.tsx index c46ae93ef..b27e867fd 100644 --- a/apps/explorer/src/app/components/txs/index.tsx +++ b/apps/explorer/src/app/components/txs/index.tsx @@ -1,3 +1,4 @@ export { TxDetails } from './id/tx-details'; export { TxContent } from './id/tx-content'; -export { TxList } from './home/tx-list'; +export { TxList } from './pending/tx-list'; +export { TxsData } from './home/txs-data'; diff --git a/apps/explorer/src/app/components/txs/home/tx-list.tsx b/apps/explorer/src/app/components/txs/pending/tx-list.tsx similarity index 100% rename from apps/explorer/src/app/components/txs/home/tx-list.tsx rename to apps/explorer/src/app/components/txs/pending/tx-list.tsx diff --git a/apps/explorer/src/app/routes/blocks/home/index.tsx b/apps/explorer/src/app/routes/blocks/home/index.tsx index 0c71a77d3..28d572153 100644 --- a/apps/explorer/src/app/routes/blocks/home/index.tsx +++ b/apps/explorer/src/app/routes/blocks/home/index.tsx @@ -2,7 +2,7 @@ import { DATA_SOURCES } from '../../../config'; import useFetch from '../../../hooks/use-fetch'; import { TendermintBlockchainResponse } from '../tendermint-blockchain-response'; import { RouteTitle } from '../../../components/route-title'; -import { BlocksTable, BlocksRefetch } from '../../../components/blocks'; +import { BlocksData, BlocksRefetch } from '../../../components/blocks'; import { JumpToBlock } from '../../../components/jump-to-block'; const Blocks = () => { @@ -17,7 +17,7 @@ const Blocks = () => {
Blocks - +
); diff --git a/apps/explorer/src/app/routes/blocks/id/index.tsx b/apps/explorer/src/app/routes/blocks/id/index.tsx index a646cecba..32539e5b8 100644 --- a/apps/explorer/src/app/routes/blocks/id/index.tsx +++ b/apps/explorer/src/app/routes/blocks/id/index.tsx @@ -30,7 +30,7 @@ const Block = () => { return (
BLOCK {block} - +
Mined by diff --git a/apps/explorer/src/app/routes/txs/home/index.tsx b/apps/explorer/src/app/routes/txs/home/index.tsx index b5969dbd3..21144f509 100644 --- a/apps/explorer/src/app/routes/txs/home/index.tsx +++ b/apps/explorer/src/app/routes/txs/home/index.tsx @@ -2,7 +2,8 @@ import useFetch from '../../../hooks/use-fetch'; import { TendermintBlockchainResponse } from '../../blocks/tendermint-blockchain-response'; import { DATA_SOURCES } from '../../../config'; import { RouteTitle } from '../../../components/route-title'; -import { BlocksTable, BlocksRefetch } from '../../../components/blocks'; +import { BlocksRefetch } from '../../../components/blocks'; +import { TxsData } from '../../../components/txs'; import { JumpToBlock } from '../../../components/jump-to-block'; const Txs = () => { @@ -17,7 +18,7 @@ const Txs = () => {
Transactions - +
);