Feat/893 anchor per network param (#907)
* feat: highlight network param targeted by anchor * Feat/893: Highlighted key-value row colours * Feat/893: Removed unneeded important bangs Co-authored-by: sam-keen <samuel.kleinmann@gmail.com>
This commit is contained in:
parent
e1c532cc05
commit
b9d57efacf
@ -24,10 +24,10 @@ describe('NetworkParametersTable', () => {
|
|||||||
);
|
);
|
||||||
const rows = screen.getAllByTestId('key-value-table-row');
|
const rows = screen.getAllByTestId('key-value-table-row');
|
||||||
expect(rows[0].children[0]).toHaveTextContent(
|
expect(rows[0].children[0]).toHaveTextContent(
|
||||||
'Market Fee Factors Infrastructure Fee'
|
'market.fee.factors.infrastructureFee'
|
||||||
);
|
);
|
||||||
expect(rows[1].children[0]).toHaveTextContent(
|
expect(rows[1].children[0]).toHaveTextContent(
|
||||||
'Market Liquidity Provision Min Lp Stake Quantum Multiple'
|
'market.liquidityProvision.minLpStakeQuantumMultiple'
|
||||||
);
|
);
|
||||||
expect(rows[0].children[1]).toHaveTextContent('0.0005');
|
expect(rows[0].children[1]).toHaveTextContent('0.0005');
|
||||||
expect(rows[1].children[1]).toHaveTextContent('1');
|
expect(rows[1].children[1]).toHaveTextContent('1');
|
||||||
@ -54,10 +54,10 @@ describe('NetworkParametersTable', () => {
|
|||||||
);
|
);
|
||||||
const rows = screen.getAllByTestId('key-value-table-row');
|
const rows = screen.getAllByTestId('key-value-table-row');
|
||||||
expect(rows[0].children[0]).toHaveTextContent(
|
expect(rows[0].children[0]).toHaveTextContent(
|
||||||
'Market Fee Factors Infrastructure Fee'
|
'market.fee.factors.infrastructureFee'
|
||||||
);
|
);
|
||||||
expect(rows[1].children[0]).toHaveTextContent(
|
expect(rows[1].children[0]).toHaveTextContent(
|
||||||
'Market Liquidity Provision Min Lp Stake Quantum Multiple'
|
'market.liquidityProvision.minLpStakeQuantumMultiple'
|
||||||
);
|
);
|
||||||
expect(rows[0].children[1]).toHaveTextContent('0.0005');
|
expect(rows[0].children[1]).toHaveTextContent('0.0005');
|
||||||
expect(rows[1].children[1]).toHaveTextContent('1');
|
expect(rows[1].children[1]).toHaveTextContent('1');
|
||||||
|
@ -16,7 +16,6 @@ import type {
|
|||||||
NetworkParametersQuery_networkParameters,
|
NetworkParametersQuery_networkParameters,
|
||||||
} from './__generated__/NetworkParametersQuery';
|
} from './__generated__/NetworkParametersQuery';
|
||||||
import orderBy from 'lodash/orderBy';
|
import orderBy from 'lodash/orderBy';
|
||||||
import startCase from 'lodash/startCase';
|
|
||||||
|
|
||||||
const BIG_NUMBER_PARAMS = [
|
const BIG_NUMBER_PARAMS = [
|
||||||
'spam.protection.delegation.min.tokens',
|
'spam.protection.delegation.min.tokens',
|
||||||
@ -42,8 +41,15 @@ export const renderRow = ({
|
|||||||
}: NetworkParametersQuery_networkParameters) => {
|
}: NetworkParametersQuery_networkParameters) => {
|
||||||
const isSyntaxRow = isJsonObject(value);
|
const isSyntaxRow = isJsonObject(value);
|
||||||
return (
|
return (
|
||||||
<KeyValueTableRow key={key} inline={!isSyntaxRow}>
|
<KeyValueTableRow
|
||||||
{startCase(key)}
|
key={key}
|
||||||
|
inline={!isSyntaxRow}
|
||||||
|
id={key}
|
||||||
|
className={
|
||||||
|
'group target:bg-vega-pink target:text-white dark:target:bg-vega-yellow dark:target:text-black'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{key}
|
||||||
{isSyntaxRow ? (
|
{isSyntaxRow ? (
|
||||||
<SyntaxHighlighter data={JSON.parse(value)} />
|
<SyntaxHighlighter data={JSON.parse(value)} />
|
||||||
) : isNaN(Number(value)) ? (
|
) : isNaN(Number(value)) ? (
|
||||||
|
@ -90,3 +90,19 @@ it('Applies muted class if prop is passed', () => {
|
|||||||
'w-full border-collapse mb-8 [border-spacing:0] break-all'
|
'w-full border-collapse mb-8 [border-spacing:0] break-all'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Applies id to row if passed', () => {
|
||||||
|
render(
|
||||||
|
<KeyValueTable>
|
||||||
|
<KeyValueTableRow inline={false} id="thisistheid">
|
||||||
|
<span>My value</span>
|
||||||
|
<span>My value</span>
|
||||||
|
</KeyValueTableRow>
|
||||||
|
</KeyValueTable>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByTestId('key-value-table-row')).toHaveAttribute(
|
||||||
|
'id',
|
||||||
|
'thisistheid'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
@ -77,6 +77,7 @@ export const KeyValueTableRow = ({
|
|||||||
noBorder = false,
|
noBorder = false,
|
||||||
dtClassName,
|
dtClassName,
|
||||||
ddClassName,
|
ddClassName,
|
||||||
|
id,
|
||||||
}: KeyValueTableRowProps) => {
|
}: KeyValueTableRowProps) => {
|
||||||
const dlClassName = classNames(
|
const dlClassName = classNames(
|
||||||
'flex gap-1 flex-wrap justify-between ',
|
'flex gap-1 flex-wrap justify-between ',
|
||||||
@ -92,14 +93,24 @@ export const KeyValueTableRow = ({
|
|||||||
const dtClassNames = `break-words font-medium uppercase align-top p-4 capitalize ${dtClassName}`;
|
const dtClassNames = `break-words font-medium uppercase align-top p-4 capitalize ${dtClassName}`;
|
||||||
const ddClassNames = classNames(
|
const ddClassNames = classNames(
|
||||||
'align-top p-4 text-black/60 dark:text-white/60 break-words',
|
'align-top p-4 text-black/60 dark:text-white/60 break-words',
|
||||||
|
'group-target:text-white dark:group-target:text-black',
|
||||||
{
|
{
|
||||||
'font-mono': numerical,
|
'font-mono': numerical,
|
||||||
},
|
},
|
||||||
ddClassName
|
ddClassName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const attributes = {} as Partial<React.HTMLProps<HTMLDListElement>>;
|
||||||
|
if (id) {
|
||||||
|
attributes.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dl className={dlClassName} data-testid="key-value-table-row">
|
<dl
|
||||||
|
className={dlClassName}
|
||||||
|
data-testid="key-value-table-row"
|
||||||
|
{...attributes}
|
||||||
|
>
|
||||||
<dt className={dtClassNames}>{children[0]}</dt>
|
<dt className={dtClassNames}>{children[0]}</dt>
|
||||||
<dd className={ddClassNames}>{children[1]}</dd>
|
<dd className={ddClassNames}>{children[1]}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
Loading…
Reference in New Issue
Block a user