Adjust table consistency (#3397)
* Adjust table consistency * Header transparent * Non-transparent summary
This commit is contained in:
parent
eaafee1a85
commit
41d6303f6f
53
packages/page-staking/src/Slashes/Era.tsx
Normal file
53
packages/page-staking/src/Slashes/Era.tsx
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2020 @polkadot/app-staking authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SlashEra } from './types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
import Row from './Row';
|
||||
import Summary from './Summary';
|
||||
|
||||
interface Props {
|
||||
slash: SlashEra;
|
||||
}
|
||||
|
||||
function Slashes ({ slash }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const header = useMemo((): [string?, string?, number?][] => [
|
||||
[undefined, 'start', 3],
|
||||
[t('reporters'), 'address'],
|
||||
[t('own')],
|
||||
[t('other')],
|
||||
[t('total')],
|
||||
[t('payout')]
|
||||
], [t]);
|
||||
|
||||
return (
|
||||
<Table header={[[t('era {{era}}/unapplied', { replace: { era: slash.era.toString() } }), 'start', 8]]}>
|
||||
<Summary slash={slash} />
|
||||
<tr className='transparent'>
|
||||
{header.map(([label, className, colSpan = 1], index): React.ReactNode => (
|
||||
<td
|
||||
className={className}
|
||||
colSpan={colSpan}
|
||||
key={index}
|
||||
>
|
||||
<label>{label}</label>
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
{slash.slashes.map((slash, index): React.ReactNode => (
|
||||
<Row
|
||||
key={index}
|
||||
slash={slash}
|
||||
/>
|
||||
))}
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Slashes);
|
||||
@ -11,8 +11,7 @@ import React, { useMemo } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
import Header from './Header';
|
||||
import Row from './Row';
|
||||
import Era from './Era';
|
||||
|
||||
interface Props {
|
||||
ownStashes?: StakerState[];
|
||||
@ -86,14 +85,6 @@ function calcSlashEras (slashes: [BN, UnappliedSlash[]][], ownStashes: StakerSta
|
||||
|
||||
function Slashes ({ ownStashes = [], slashes }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const header = useMemo((): [string?, string?, number?][] => [
|
||||
[undefined, 'start', 3],
|
||||
[t('reporters'), 'address'],
|
||||
[t('own')],
|
||||
[t('other')],
|
||||
[t('total')],
|
||||
[t('payout')]
|
||||
], [t]);
|
||||
const rows = useMemo(() => calcSlashEras(slashes, ownStashes), [ownStashes, slashes]);
|
||||
|
||||
if (!rows.length) {
|
||||
@ -108,29 +99,10 @@ function Slashes ({ ownStashes = [], slashes }: Props): React.ReactElement<Props
|
||||
return (
|
||||
<>
|
||||
{rows.map((slash): React.ReactNode => (
|
||||
<Table
|
||||
header={[[t('era {{era}}/unapplied', { replace: { era: slash.era.toString() } }), 'start', 6]]}
|
||||
<Era
|
||||
key={slash.era.toString()}
|
||||
>
|
||||
<Header slash={slash} />
|
||||
<tr>
|
||||
{header.map(([label, className, colSpan = 1], index): React.ReactNode => (
|
||||
<td
|
||||
className={className}
|
||||
colSpan={colSpan}
|
||||
key={index}
|
||||
>
|
||||
<label>{label}</label>
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
{slash.slashes.map((slash, index): React.ReactNode => (
|
||||
<Row
|
||||
key={index}
|
||||
slash={slash}
|
||||
/>
|
||||
))}
|
||||
</Table>
|
||||
slash={slash}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
||||
@ -30,8 +30,6 @@ function Body ({ children, className = '', empty, emptySpinner }: Props): React.
|
||||
}
|
||||
|
||||
export default React.memo(styled(Body)`
|
||||
background: white;
|
||||
|
||||
td {
|
||||
padding: 0.75rem 1rem;
|
||||
text-align: left;
|
||||
@ -139,7 +137,11 @@ export default React.memo(styled(Body)`
|
||||
|
||||
tr {
|
||||
&:nth-child(even) {
|
||||
background: #f9f8f7;
|
||||
background: #faf9f8;
|
||||
}
|
||||
|
||||
&:nth-child(odd) {
|
||||
background: white;
|
||||
}
|
||||
|
||||
&:first-child td {
|
||||
@ -170,10 +172,13 @@ export default React.memo(styled(Body)`
|
||||
}
|
||||
}
|
||||
|
||||
&.transparent {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.ui--Button:not(.isIcon):not(:hover) {
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
// color: #555 !important;
|
||||
}
|
||||
|
||||
.ui.toggle.checkbox input:checked~.box:before,
|
||||
|
||||
@ -10,11 +10,15 @@ type HeaderDef = [React.ReactNode?, string?, number?, (() => void)?];
|
||||
interface Props {
|
||||
className?: string;
|
||||
filter?: React.ReactNode;
|
||||
header: (null | undefined | HeaderDef)[];
|
||||
header?: (null | undefined | HeaderDef)[];
|
||||
isEmpty: boolean;
|
||||
}
|
||||
|
||||
function Head ({ className = '', filter, header, isEmpty }: Props): React.ReactElement<Props> {
|
||||
function Head ({ className = '', filter, header, isEmpty }: Props): React.ReactElement<Props> | null {
|
||||
if (!header?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<thead className={className}>
|
||||
{filter && (
|
||||
|
||||
@ -16,7 +16,7 @@ interface TableProps {
|
||||
emptySpinner?: React.ReactNode;
|
||||
filter?: React.ReactNode;
|
||||
footer?: React.ReactNode;
|
||||
header: [React.ReactNode?, string?, number?, (() => void)?][];
|
||||
header?: [React.ReactNode?, string?, number?, (() => void)?][];
|
||||
isFixed?: boolean;
|
||||
}
|
||||
|
||||
@ -76,18 +76,6 @@ export default React.memo(styled(Table)`
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
|
||||
label {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
th label {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&:hover label {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
td, &:not(.filter) th {
|
||||
&:first-child {
|
||||
padding-left: 1.5rem;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user