Block route styling and improved components
This commit is contained in:
parent
5028d7a763
commit
f2f1083260
@ -0,0 +1,11 @@
|
|||||||
|
interface BlocksRefetchProps {
|
||||||
|
refetch: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BlocksRefetch = ({ refetch }: BlocksRefetchProps) => {
|
||||||
|
return (
|
||||||
|
<button onClick={() => refetch()} className="underline mb-28">
|
||||||
|
Refresh to see latest blocks
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
@ -12,7 +12,7 @@ interface BlocksProps {
|
|||||||
|
|
||||||
export const BlocksTable = ({ data, showTransactions }: BlocksProps) => {
|
export const BlocksTable = ({ data, showTransactions }: BlocksProps) => {
|
||||||
if (!data?.result) {
|
if (!data?.result) {
|
||||||
return <>No block data</>;
|
return <div className="mb-28">Awaiting block data</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -20,23 +20,26 @@ export const BlocksTable = ({ data, showTransactions }: BlocksProps) => {
|
|||||||
{data.result?.block_metas?.map((block, index) => {
|
{data.result?.block_metas?.map((block, index) => {
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={index}>
|
<React.Fragment key={index}>
|
||||||
<tr>
|
<tr className="bg-neutral-850 border-b-4 border-b-black">
|
||||||
<td>
|
<td className="pl-4">
|
||||||
<Link to={`/blocks/${block.header?.height}`}>
|
<Link
|
||||||
|
to={`/blocks/${block.header?.height}`}
|
||||||
|
className="text-vega-yellow"
|
||||||
|
>
|
||||||
{block.header?.height}
|
{block.header?.height}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className="px-8 text-center">
|
||||||
{block.num_txs === '1'
|
{block.num_txs === '1'
|
||||||
? '1 transaction'
|
? '1 transaction'
|
||||||
: `${block.num_txs} transactions`}
|
: `${block.num_txs} transactions`}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className="px-8 text-center">
|
||||||
<Link to={`/validators/${block.header?.proposer_address}`}>
|
<Link to={`/validators/${block.header?.proposer_address}`}>
|
||||||
{block.header.proposer_address}
|
{block.header.proposer_address}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className="text-center pr-28 text-neutral-300">
|
||||||
<SecondsAgo date={block.header?.time} />
|
<SecondsAgo date={block.header?.time} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export { BlocksTable } from './home/blocks-table';
|
export { BlocksTable } from './home/blocks-table';
|
||||||
|
export { BlocksRefetch } from './home/blocks-refetch';
|
||||||
|
@ -20,8 +20,20 @@ export const JumpToBlock = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<input type={'tel'} name={'blockNumber'} placeholder={'Block number'} />
|
<label
|
||||||
<input type={'submit'} value={'Go'} />
|
htmlFor="block-input"
|
||||||
|
className="block uppercase text-h5 font-bold"
|
||||||
|
>
|
||||||
|
Jump to block
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="block-input"
|
||||||
|
type={'tel'}
|
||||||
|
name={'blockNumber'}
|
||||||
|
placeholder={'Block number'}
|
||||||
|
className="form-input"
|
||||||
|
/>
|
||||||
|
<input className="form-submit" type={'submit'} value={'Go'} />
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1 @@
|
|||||||
import React from 'react';
|
export { Table } from './table';
|
||||||
|
|
||||||
interface TableProps {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Table = ({ children }: TableProps) => {
|
|
||||||
return (
|
|
||||||
<table>
|
|
||||||
<tbody>{children}</tbody>
|
|
||||||
</table>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
15
apps/explorer/src/app/components/table/table.tsx
Normal file
15
apps/explorer/src/app/components/table/table.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface TableProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Table = ({ children }: TableProps) => {
|
||||||
|
return (
|
||||||
|
<div className="overflow-x-auto whitespace-nowrap mb-28">
|
||||||
|
<table className="w-full">
|
||||||
|
<tbody>{children}</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -1,7 +1,7 @@
|
|||||||
import { DATA_SOURCES } from '../../../config';
|
import { DATA_SOURCES } from '../../../config';
|
||||||
import useFetch from '../../../hooks/use-fetch';
|
import useFetch from '../../../hooks/use-fetch';
|
||||||
import { TendermintBlockchainResponse } from '../tendermint-blockchain-response';
|
import { TendermintBlockchainResponse } from '../tendermint-blockchain-response';
|
||||||
import { BlocksTable } from '../../../components/blocks';
|
import { BlocksTable, BlocksRefetch } from '../../../components/blocks';
|
||||||
import { JumpToBlock } from '../../../components/jump-to-block';
|
import { JumpToBlock } from '../../../components/jump-to-block';
|
||||||
|
|
||||||
const Blocks = () => {
|
const Blocks = () => {
|
||||||
@ -15,8 +15,8 @@ const Blocks = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<section>
|
<section>
|
||||||
<h1>Blocks</h1>
|
<h1 className="route-header">Blocks</h1>
|
||||||
<button onClick={() => refetch()}>Refresh to see latest blocks</button>
|
<BlocksRefetch refetch={refetch} />
|
||||||
<BlocksTable data={data} />
|
<BlocksTable data={data} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import useFetch from '../../../hooks/use-fetch';
|
import useFetch from '../../../hooks/use-fetch';
|
||||||
import { TendermintBlockchainResponse } from '../../blocks/tendermint-blockchain-response';
|
import { TendermintBlockchainResponse } from '../../blocks/tendermint-blockchain-response';
|
||||||
import { DATA_SOURCES } from '../../../config';
|
import { DATA_SOURCES } from '../../../config';
|
||||||
import { BlocksTable } from '../../../components/blocks';
|
import { BlocksTable, BlocksRefetch } from '../../../components/blocks';
|
||||||
import { JumpToBlock } from '../../../components/jump-to-block';
|
import { JumpToBlock } from '../../../components/jump-to-block';
|
||||||
|
|
||||||
const Txs = () => {
|
const Txs = () => {
|
||||||
@ -16,7 +16,7 @@ const Txs = () => {
|
|||||||
<>
|
<>
|
||||||
<section>
|
<section>
|
||||||
<h1>Transactions</h1>
|
<h1>Transactions</h1>
|
||||||
<button onClick={() => refetch()}>Refresh to see latest blocks</button>
|
<BlocksRefetch refetch={refetch} />
|
||||||
<BlocksTable data={data} showTransactions={true} />
|
<BlocksTable data={data} showTransactions={true} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
|
|
||||||
|
.route-header {
|
||||||
|
@apply font-alpha text-h3 uppercase mt-12 mb-28;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Used for text, tel input */
|
||||||
|
.form-input {
|
||||||
|
@apply bg-neutral-800 border-white border px-8 py-4 placeholder-neutral-300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-submit {
|
||||||
|
@apply border-white border px-28 py-4;
|
||||||
|
}
|
||||||
|
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
@ -86,6 +86,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
backgroundColor: ({ theme }) => ({
|
backgroundColor: ({ theme }) => ({
|
||||||
transparent: 'transparent',
|
transparent: 'transparent',
|
||||||
|
neutral: theme('colors.neutral'),
|
||||||
dark: theme('colors.dark'),
|
dark: theme('colors.dark'),
|
||||||
black: '#000',
|
black: '#000',
|
||||||
white: theme('colors.white'),
|
white: theme('colors.white'),
|
||||||
|
Loading…
Reference in New Issue
Block a user