Adjust AddressMini with media (#3020)
* Adjust AddressMini with media * Payout tables
This commit is contained in:
parent
d1c4ff5a92
commit
de370cfde6
@ -137,6 +137,7 @@ function Nominate ({ className = '', controllerId, next, nominating, onChange, s
|
||||
value={
|
||||
selected.map((validatorId) => (
|
||||
<AddressMini
|
||||
className='addressStatic'
|
||||
isHighlight={favorites.includes(validatorId)}
|
||||
key={validatorId}
|
||||
value={validatorId}
|
||||
@ -193,8 +194,13 @@ export default React.memo(styled(Nominate)`
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ui--Static .ui--AddressMini.padded {
|
||||
.ui--Static .ui--AddressMini.padded.addressStatic {
|
||||
padding-top: 0.5rem;
|
||||
|
||||
.ui--AddressMini-address {
|
||||
min-width: 10rem;
|
||||
max-width: 10rem;
|
||||
}
|
||||
}
|
||||
|
||||
.shortlist {
|
||||
|
||||
@ -7,6 +7,7 @@ import { EraIndex } from '@polkadot/types/interfaces';
|
||||
import { PayoutValidator } from './types';
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { AddressMini, Button, Modal, InputAddress, Static, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useToggle } from '@polkadot/react-hooks';
|
||||
@ -16,6 +17,7 @@ import { useTranslation } from '../translate';
|
||||
const MAX_BATCH_SIZE = 40;
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
isAll?: boolean;
|
||||
isDisabled?: boolean;
|
||||
payout?: PayoutValidator | PayoutValidator[];
|
||||
@ -59,7 +61,7 @@ function createExtrinsic (api: ApiPromise, payout: PayoutValidator | PayoutValid
|
||||
);
|
||||
}
|
||||
|
||||
function PayButton ({ isAll, isDisabled, payout }: Props): React.ReactElement<Props> {
|
||||
function PayButton ({ className, isAll, isDisabled, payout }: Props): React.ReactElement<Props> {
|
||||
const { api } = useApi();
|
||||
const { t } = useTranslation();
|
||||
const [isVisible, togglePayout] = useToggle();
|
||||
@ -78,6 +80,7 @@ function PayButton ({ isAll, isDisabled, payout }: Props): React.ReactElement<Pr
|
||||
<>
|
||||
{payout && isVisible && (
|
||||
<Modal
|
||||
className={className}
|
||||
header={t<string>('Payout all stakers')}
|
||||
size='large'
|
||||
>
|
||||
@ -104,6 +107,7 @@ function PayButton ({ isAll, isDisabled, payout }: Props): React.ReactElement<Pr
|
||||
value={
|
||||
payout.map(({ validatorId }) => (
|
||||
<AddressMini
|
||||
className='addressStatic'
|
||||
key={validatorId}
|
||||
value={validatorId}
|
||||
/>
|
||||
@ -152,4 +156,13 @@ function PayButton ({ isAll, isDisabled, payout }: Props): React.ReactElement<Pr
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(PayButton);
|
||||
export default React.memo(styled(PayButton)`
|
||||
.ui--AddressMini.padded.addressStatic {
|
||||
padding-top: 0.5rem;
|
||||
|
||||
.ui--AddressMini-address {
|
||||
min-width: 10rem;
|
||||
max-width: 10rem;
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
@ -9,7 +9,7 @@ import { PayoutStash } from './types';
|
||||
import BN from 'bn.js';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import ApiPromise from '@polkadot/api/promise';
|
||||
import { AddressMini, TxButton } from '@polkadot/react-components';
|
||||
import { AddressSmall, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
import { BlockToTime, FormatBalance } from '@polkadot/react-query';
|
||||
|
||||
@ -76,7 +76,12 @@ function Stash ({ className = '', isDisabled, payout: { available, rewards, stas
|
||||
|
||||
return (
|
||||
<tr className={className}>
|
||||
<td className='address'><AddressMini value={stashId} /></td>
|
||||
<td
|
||||
className='address'
|
||||
colSpan={2}
|
||||
>
|
||||
<AddressSmall value={stashId} />
|
||||
</td>
|
||||
<td className='start'>
|
||||
<span className='payout-eras'>{eraStr}</span>
|
||||
</td>
|
||||
|
||||
@ -6,7 +6,7 @@ import { PayoutValidator } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { AddressMini, Expander } from '@polkadot/react-components';
|
||||
import { AddressMini, AddressSmall, Expander } from '@polkadot/react-components';
|
||||
import { BlockToTime, FormatBalance } from '@polkadot/react-query';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -55,7 +55,12 @@ function Validator ({ className = '', isDisabled, payout }: Props): React.ReactE
|
||||
|
||||
return (
|
||||
<tr className={className}>
|
||||
<td className='address'><AddressMini value={payout.validatorId} /></td>
|
||||
<td
|
||||
className='address'
|
||||
colSpan={2}
|
||||
>
|
||||
<AddressSmall value={payout.validatorId} />
|
||||
</td>
|
||||
<td className='start'>
|
||||
<span className='payout-eras'>{eraStr}</span>
|
||||
</td>
|
||||
|
||||
@ -114,7 +114,7 @@ function Payouts ({ className = '', isInElection }: Props): React.ReactElement<P
|
||||
}, [allRewards, stakerPayoutsAfter]);
|
||||
|
||||
const headerStashes = useMemo(() => [
|
||||
[t('payout/stash'), 'start'],
|
||||
[t('payout/stash'), 'start', 2],
|
||||
[t('eras'), 'start'],
|
||||
[t('available')],
|
||||
[('remaining')],
|
||||
@ -122,7 +122,7 @@ function Payouts ({ className = '', isInElection }: Props): React.ReactElement<P
|
||||
], [t]);
|
||||
|
||||
const headerValidators = useMemo(() => [
|
||||
[t('payout/validator'), 'start'],
|
||||
[t('payout/validator'), 'start', 2],
|
||||
[t('eras'), 'start'],
|
||||
[t('available')],
|
||||
[('remaining')],
|
||||
@ -131,7 +131,7 @@ function Payouts ({ className = '', isInElection }: Props): React.ReactElement<P
|
||||
|
||||
const footer = useMemo(() => (
|
||||
<tr>
|
||||
<td colSpan={2} />
|
||||
<td colSpan={3} />
|
||||
<td className='number'>
|
||||
{stashTotal && <FormatBalance value={stashTotal} />}
|
||||
</td>
|
||||
|
||||
@ -89,6 +89,7 @@ function Nominate ({ className = '', isDisabled, ownNominators, targets }: Props
|
||||
value={
|
||||
targets.map((validatorId) => (
|
||||
<AddressMini
|
||||
className='addressStatic'
|
||||
key={validatorId}
|
||||
value={validatorId}
|
||||
/>
|
||||
@ -118,7 +119,12 @@ function Nominate ({ className = '', isDisabled, ownNominators, targets }: Props
|
||||
}
|
||||
|
||||
export default React.memo(styled(Nominate)`
|
||||
.ui--AddressMini.padded {
|
||||
.ui--AddressMini.padded.addressStatic {
|
||||
padding-top: 0.5rem;
|
||||
|
||||
.ui--AddressMini-address {
|
||||
min-width: 10rem;
|
||||
max-width: 10rem;
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
@ -118,12 +118,42 @@ export default React.memo(styled(AddressMini)`
|
||||
}
|
||||
|
||||
.ui--AddressMini-address {
|
||||
max-width: 9rem;
|
||||
min-width: 9rem;
|
||||
max-width: 12rem;
|
||||
min-width: 12rem;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@media only screen and (max-width: 1800px) {
|
||||
max-width: 11.5rem;
|
||||
min-width: 11.5rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1700px) {
|
||||
max-width: 11rem;
|
||||
min-width: 11rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1600px) {
|
||||
max-width: 10.5rem;
|
||||
min-width: 10.5rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1500px) {
|
||||
max-width: 10rem;
|
||||
min-width: 10rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1400px) {
|
||||
max-width: 9.5rem;
|
||||
min-width: 9.5rem;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1300px) {
|
||||
max-width: 9rem;
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
> div {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@ -22,61 +22,6 @@ interface Props {
|
||||
valueLabel: React.ReactNode;
|
||||
}
|
||||
|
||||
// import { DragDropContext, Droppable, DraggableLocation, DroppableProvided, DropResult } from 'react-beautiful-dnd';
|
||||
|
||||
// <DragDropContext onDragEnd={_onDragEnd}>
|
||||
// <Droppable droppableId='available'>
|
||||
// {(provided: DroppableProvided): React.ReactElement => (
|
||||
// <div
|
||||
// className='ui--InputAddressMulti-items'
|
||||
// // eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
// ref={provided.innerRef}
|
||||
// >
|
||||
// {value.map((address, index): React.ReactNode => (
|
||||
// <Selected
|
||||
// address={address}
|
||||
// index={index}
|
||||
// key={address}
|
||||
// onDeselect={_onDeselect}
|
||||
// />
|
||||
// ))}
|
||||
// {provided.placeholder}
|
||||
// </div>
|
||||
// )}
|
||||
// </Droppable>
|
||||
// </DragDropContext>
|
||||
|
||||
// const _onReorder = useCallback(
|
||||
// (source: DraggableLocation, destination: DraggableLocation): void => {
|
||||
// const result = Array.from(value);
|
||||
// const [removed] = result.splice(source.index, 1);
|
||||
|
||||
// result.splice(destination.index, 0, removed);
|
||||
|
||||
// onChange(uniquesOf(result));
|
||||
// },
|
||||
// [onChange, value]
|
||||
// );
|
||||
|
||||
// const _onDeselect = useCallback(
|
||||
// (index: number): void =>
|
||||
// onChange(
|
||||
// uniquesOf([...value.slice(0, index), ...value.slice(index + 1)])
|
||||
// ),
|
||||
// [onChange, value]
|
||||
// );
|
||||
|
||||
// const _onDragEnd = useCallback(
|
||||
// (result: DropResult): void => {
|
||||
// const { destination, source } = result;
|
||||
|
||||
// !!destination && _onReorder(source, destination);
|
||||
// },
|
||||
// [_onReorder]
|
||||
// );
|
||||
|
||||
// NOTE Drag code above, disabled since it has massive performance implications
|
||||
|
||||
function InputAddressMulti ({ available, availableLabel, className = '', defaultValue, maxCount, onChange, valueLabel }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const [_filter, setFilter] = useState<string>('');
|
||||
@ -189,10 +134,16 @@ export default React.memo(styled(InputAddressMulti)`
|
||||
border-radius: 0.286rem 0.286rem;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
.ui--AddressToggle {
|
||||
padding-left: 0.75rem;
|
||||
}
|
||||
|
||||
.ui--AddressMini-address {
|
||||
min-width: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ export default React.memo(styled(Body)`
|
||||
|
||||
&.address {
|
||||
min-width: 11rem;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
&.badge {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user