Added 'Highlighted Link' component for shared styling for links in light and dark themes

This commit is contained in:
sam-keen 2022-03-30 11:39:32 +01:00
parent ee66bea4f4
commit 2857e8081e
4 changed files with 35 additions and 21 deletions

View File

@ -0,0 +1,22 @@
import { Link } from 'react-router-dom';
interface HighlightedLinkProps {
to: string;
text: string | undefined;
}
export const HighlightedLink = ({
to,
text,
...props
}: HighlightedLinkProps) => {
return (
<Link
className="font-bold underline dark:text-vega-yellow dark:font-normal dark:no-underline"
to={to}
{...props}
>
{text}
</Link>
);
};

View File

@ -55,7 +55,7 @@ export const TableHeader = ({
className,
...props
}: TableHeaderProps) => {
const cellClasses = classnames(className, 'pl-4 dark:pl-0', {
const cellClasses = classnames(className, {
'text-left font-normal': props?.scope === 'row',
});
return (

View File

@ -15,6 +15,7 @@ import { TxsPerBlock } from '../../../components/txs/txs-per-block';
import { Button } from '@vegaprotocol/ui-toolkit';
import { Routes } from '../../router-config';
import { RenderFetched } from '../../../components/render-fetched';
import { HighlightedLink } from '../../../components/highlighted-link';
const Block = () => {
const { block } = useParams<{ block: string }>();
@ -60,13 +61,11 @@ const Block = () => {
<TableRow modifier="bordered">
<TableHeader scope="row">Mined by</TableHeader>
<TableCell modifier="bordered">
<Link
data-testid="block-validator"
className="font-mono font-bold underline dark:text-vega-yellow dark:font-normal dark:no-underline"
<HighlightedLink
to={`/${Routes.VALIDATORS}`}
>
{header.proposer_address}
</Link>
text={header.proposer_address}
data-testid="block-validator"
/>
</TableCell>
</TableRow>
<TableRow modifier="bordered">

View File

@ -1,4 +1,5 @@
import { Link } from 'react-router-dom';
import { Routes } from '../../router-config';
import { Result } from '../tendermint-transaction-response.d';
import {
TableWithTbody,
TableCell,
@ -6,8 +7,7 @@ import {
TableRow,
} from '../../../components/table';
import { TruncateInline } from '../../../components/truncate/truncate';
import { Routes } from '../../router-config';
import { Result } from '../tendermint-transaction-response.d';
import { HighlightedLink } from '../../../components/highlighted-link';
interface TxDetailsProps {
txData: Result | undefined;
@ -35,23 +35,16 @@ export const TxDetails = ({ txData, pubKey, className }: TxDetailsProps) => {
Submitted by
</TableHeader>
<TableCell modifier="bordered" data-testid="submitted-by">
<Link
className="text-vega-yellow"
to={`/${Routes.PARTIES}/${pubKey}`}
>
{pubKey}
</Link>
<HighlightedLink to={`/${Routes.PARTIES}/${pubKey}`} text={pubKey} />
</TableCell>
</TableRow>
<TableRow modifier="bordered">
<TableCell>Block</TableCell>
<TableCell modifier="bordered" data-testid="block">
<Link
className="text-vega-yellow"
<HighlightedLink
to={`/${Routes.BLOCKS}/${txData.height}`}
>
{txData.height}
</Link>
text={txData.height}
/>
</TableCell>
</TableRow>
<TableRow modifier="bordered">