Display council voters via ExpanderScroll (#7386)

This commit is contained in:
Jaco 2022-04-18 12:59:14 +02:00 committed by GitHub
parent 82df29709e
commit 7fcade014a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 11 deletions

View File

@ -3,9 +3,9 @@
import type { AccountId, Balance } from '@polkadot/types/interfaces';
import React from 'react';
import React, { useCallback } from 'react';
import { AddressMini, Expander } from '@polkadot/react-components';
import { AddressMini, ExpanderScroll } from '@polkadot/react-components';
import { FormatBalance } from '@polkadot/react-query';
import { formatNumber } from '@polkadot/util';
@ -15,6 +15,17 @@ interface Props {
}
function Voters ({ balance, voters }: Props): React.ReactElement<Props> {
const renderVoters = useCallback(
() => voters && voters.map((who): React.ReactNode =>
<AddressMini
key={who.toString()}
value={who}
withLockedVote
/>
),
[voters]
);
if (!balance || !voters || !voters.length) {
return <><td className='all number' /><td className='number' /></>;
}
@ -22,15 +33,10 @@ function Voters ({ balance, voters }: Props): React.ReactElement<Props> {
return (
<>
<td className='all expand'>
<Expander summary={<FormatBalance value={balance} />}>
{voters.map((who): React.ReactNode =>
<AddressMini
key={who.toString()}
value={who}
withLockedVote
/>
)}
</Expander>
<ExpanderScroll
renderChildren={renderVoters}
summary={<FormatBalance value={balance} />}
/>
</td>
<td className='number'>
{formatNumber(voters.length)}

View File

@ -62,8 +62,10 @@ export default React.memo(styled(ExpanderScroll)`
.tableContainer {
overflow-y: scroll;
display: block;
margin: 0 0 0 auto;
min-height: 50px;
max-height: 200px;
max-width: 30rem;
overflow-x: hidden;
}
`);

View File

@ -93,6 +93,7 @@ export default React.memo(styled(Table)`
td {
border-top-width: 1px;
padding: 0.25rem 0.75rem;
}
}
}