Adjust bids tables (& overall table styling) (#4932)

This commit is contained in:
Jaco Greeff 2021-03-25 15:05:11 +01:00 committed by GitHub
parent 687901728b
commit 435770c73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 255 additions and 232 deletions

View File

@ -189,6 +189,7 @@ export default React.memo(styled(CalendarApp)`
h1 {
align-items: center;
border-bottom: 0.25rem solid var(--bg-page);
display: flex;
justify-content: space-between;
padding: 0.5rem 0.5rem 0 1rem;

View File

@ -37,20 +37,22 @@ function Auction ({ auctionInfo, className, winningData }: Props): React.ReactEl
)
}
header={headerRef.current}
noBodyTag
>
{auctionInfo && winningData?.map(({ blockNumber, winners }, round) =>
winners.map((value, index) => (
<WinRange
auctionInfo={auctionInfo}
blockNumber={blockNumber}
className={`${(round % 2) ? 'isEven' : 'isOdd'} ${index === (winners.length - 1) ? '' : 'noBorder'}`}
isFirst={index === 0}
isLatest={round === 0}
key={`${blockNumber.toString()}:${index}`}
value={value}
/>
))
)}
{auctionInfo && winningData?.map(({ blockNumber, winners }, round) => (
<tbody key={round}>
{winners.map((value, index) => (
<WinRange
auctionInfo={auctionInfo}
blockNumber={blockNumber}
isFirst={index === 0}
isLatest={round === 0}
key={`${blockNumber.toString()}:${index}`}
value={value}
/>
))}
</tbody>
))}
</Table>
);
}

View File

@ -13,223 +13,29 @@ interface Props {
className?: string;
empty?: React.ReactNode | false;
emptySpinner?: React.ReactNode;
noBodyTag?: boolean;
}
function Body ({ children, className = '', empty, emptySpinner }: Props): React.ReactElement<Props> {
return (
<tbody className={className}>
{children || (
<tr><td colSpan={100}>{
isString(empty)
? <div className='empty'>{empty}</div>
: empty || <Spinner label={emptySpinner} />
}</td></tr>
)}
</tbody>
);
function Body ({ children, className = '', empty, emptySpinner, noBodyTag }: Props): React.ReactElement<Props> {
return children
? (
noBodyTag
? <>{children}</>
: <tbody className={className}>{children}</tbody>
)
: (
<tbody className={className}>
<tr>
<td colSpan={100}>{
isString(empty)
? <div className='empty'>{empty}</div>
: empty || <Spinner label={emptySpinner} />
}</td>
</tr>
</tbody>
);
}
export default React.memo(styled(Body)`
position: relative;
td {
border-bottom: 1px solid var(--border-table);
padding: 0.5rem 1rem;
text-align: left;
vertical-align: middle;
&:first-child {
border-left: 1px solid var(--border-table);
}
&:last-child {
border-right: 1px solid var(--border-table);
}
label {
display: block !important;
white-space: nowrap;
}
div.empty {
opacity: 0.6;
padding: 0.25rem;
}
.ui--Spinner {
margin: 0 auto;
.text {
margin-bottom: 0;
}
}
&.address {
min-width: 11rem;
overflow-x: hidden;
}
&.badge {
padding: 0.5rem;
}
&.button {
padding: 0.25rem 0.5rem;
text-align: right;
white-space: nowrap;
> * {
vertical-align: middle;
}
.ui--Toggle {
display: inline-block;
white-space: nowrap;
label {
display: inline-block !important;
}
}
}
&.combined {
border-top-width: 0;
}
&.expand {
&:not(.left) {
text-align: right;
}
.ui--Expander+.ui--Expander {
margin-top: 0.375rem;
}
}
&.hash {
font: var(--font-mono);
}
&.links {
padding: 0.5rem 0.75rem;
text-align: center;
width: 0;
}
&.no-pad-left {
padding-left: 0.125rem;
}
&.no-pad-right {
padding-right: 0.125rem;
}
&.number {
text-align: right;
}
&.relative {
position: relative;
}
&.overflow {
max-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
&.start {
text-align: left;
}
&.together {
white-space: nowrap;
}
&.top {
vertical-align: top;
}
&.middle {
text-align: center;
}
&.mini {
padding: 0 !important;
width: fit-content;
white-space: normal;
> div {
margin-right: 0.75rem;
max-width: 3.8rem;
min-width: 3.8rem;
}
}
&.upper {
text-transform: uppercase;
}
&.favorite .ui--Icon.isSelected {
color: darkorange;
}
.ui--Button-Group .ui--Button:not(.isToplevel) {
margin: 0;
}
}
tr {
&:nth-child(odd):not(.isEven),
&:nth-child(even).isOdd {
background: var(--bg-table);
}
&:first-child {
td:first-child {
border-top-left-radius: 0.25rem;
}
td:last-child {
border-top-right-radius: 0.25rem;
}
}
&:last-child {
td {
border-bottom: 1px solid var(--border-table);
&:first-child {
border-bottom-left-radius: 0.25rem;
}
:last-child {
border-bottom-right-radius: 0.25rem;
}
}
}
&.transparent {
background: transparent;
}
&.noBorder td {
border-bottom: 1px solid transparent;
padding-bottom: 0 !important;
}
.ui--Button-Group {
margin: 0;
}
.ui--Button:not(.isIcon):not(:hover) {
background: transparent !important;
box-shadow: none !important;
}
.ui.toggle.checkbox input:checked~.box:before,
.ui.toggle.checkbox input:checked~label:before {
background-color: #eee !important;
}
}
`);

View File

@ -63,9 +63,9 @@ export default React.memo(styled(Head)`
th {
font: var(--font-sans);
font-weight: var(--font-weight-normal);
padding: 0.5rem 1rem 0.25rem;
padding: 0.375rem 1rem;
text-align: right;
vertical-align: baseline;
vertical-align: middle;
white-space: nowrap;
h1, h2 {
@ -73,6 +73,9 @@ export default React.memo(styled(Head)`
}
h1 {
display: table-cell;
vertical-align: middle;
.ui--Icon {
font-size: 1rem;
margin-right: 0.5rem;

View File

@ -18,9 +18,10 @@ interface TableProps {
header?: [React.ReactNode?, string?, number?, (() => void)?][];
isFixed?: boolean;
legend?: React.ReactNode;
noBodyTag?: boolean;
}
function extractKids (children: React.ReactNode): [boolean, React.ReactNode] {
function extractBodyChildren (children: React.ReactNode): [boolean, React.ReactNode] {
if (!Array.isArray(children)) {
return [!children, children];
}
@ -31,8 +32,8 @@ function extractKids (children: React.ReactNode): [boolean, React.ReactNode] {
return [isEmpty, isEmpty ? null : kids];
}
function Table ({ children, className = '', empty, emptySpinner, filter, footer, header, isFixed, legend }: TableProps): React.ReactElement<TableProps> {
const [isEmpty, kids] = extractKids(children);
function Table ({ children, className = '', empty, emptySpinner, filter, footer, header, isFixed, legend, noBodyTag }: TableProps): React.ReactElement<TableProps> {
const [isEmpty, bodyChildren] = extractBodyChildren(children);
return (
<div className={`ui--Table ${className}`}>
@ -46,8 +47,9 @@ function Table ({ children, className = '', empty, emptySpinner, filter, footer,
<Body
empty={empty}
emptySpinner={emptySpinner}
noBodyTag={noBodyTag}
>
{kids}
{bodyChildren}
</Body>
<Foot
footer={footer}
@ -99,4 +101,213 @@ export default React.memo(styled(Table)`
}
}
}
tbody {
position: relative;
td {
border-bottom: 1px solid var(--border-table);
padding: 0.5rem 1rem;
text-align: left;
vertical-align: middle;
&:first-child {
border-left: 1px solid var(--border-table);
}
&:last-child {
border-right: 1px solid var(--border-table);
}
label {
display: block !important;
white-space: nowrap;
}
div.empty {
opacity: 0.6;
padding: 0.25rem;
}
.ui--Spinner {
margin: 0 auto;
.text {
margin-bottom: 0;
}
}
&.address {
min-width: 11rem;
overflow-x: hidden;
}
&.badge {
padding: 0.5rem;
}
&.button {
padding: 0.25rem 0.5rem;
text-align: right;
white-space: nowrap;
> * {
vertical-align: middle;
}
.ui--Toggle {
display: inline-block;
white-space: nowrap;
label {
display: inline-block !important;
}
}
}
&.combined {
border-top-width: 0;
}
&.expand {
&:not(.left) {
text-align: right;
}
.ui--Expander+.ui--Expander {
margin-top: 0.375rem;
}
}
&.hash {
font: var(--font-mono);
}
&.links {
padding: 0.5rem 0.75rem;
text-align: center;
width: 0;
}
&.no-pad-left {
padding-left: 0.125rem;
}
&.no-pad-right {
padding-right: 0.125rem;
}
&.number {
text-align: right;
}
&.relative {
position: relative;
}
&.overflow {
max-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
&.start {
text-align: left;
}
&.together {
white-space: nowrap;
}
&.top {
vertical-align: top;
}
&.middle {
text-align: center;
}
&.mini {
padding: 0 !important;
width: fit-content;
white-space: normal;
> div {
margin-right: 0.75rem;
max-width: 3.8rem;
min-width: 3.8rem;
}
}
&.upper {
text-transform: uppercase;
}
&.favorite .ui--Icon.isSelected {
color: darkorange;
}
.ui--Button-Group .ui--Button:not(.isToplevel) {
margin: 0;
}
}
tr {
&:nth-child(odd):not(.isEven),
&:nth-child(even).isOdd {
background: var(--bg-table);
}
&:first-child {
td {
border-top: 0.25rem solid var(--bg-page);
}
td:first-child {
border-top-left-radius: 0.25rem;
}
td:last-child {
border-top-right-radius: 0.25rem;
}
}
&:last-child {
td {
border-bottom: 1px solid var(--border-table);
&:first-child {
border-bottom-left-radius: 0.25rem;
}
:last-child {
border-bottom-right-radius: 0.25rem;
}
}
}
&.transparent {
background: transparent;
}
&.noBorder td {
border-bottom: 1px solid transparent;
padding-bottom: 0 !important;
}
.ui--Button-Group {
margin: 0;
}
.ui--Button:not(.isIcon):not(:hover) {
background: transparent !important;
box-shadow: none !important;
}
.ui.toggle.checkbox input:checked~.box:before,
.ui.toggle.checkbox input:checked~label:before {
background-color: #eee !important;
}
}
}
`);