diff --git a/packages/page-council/src/Motions/index.tsx b/packages/page-council/src/Motions/index.tsx index 9bb4a8d8c1..f6cca0924b 100644 --- a/packages/page-council/src/Motions/index.tsx +++ b/packages/page-council/src/Motions/index.tsx @@ -29,7 +29,7 @@ function Proposals ({ className = '', motions, prime }: Props): React.ReactEleme [t('motions'), 'start', 2], [t('threshold')], [t('voting end')], - [t('votes'), 'start'], + [t('votes'), 'expand'], [], [undefined, 'badge'], [] diff --git a/packages/page-council/src/Overview/Candidates.tsx b/packages/page-council/src/Overview/Candidates.tsx index d7e064fb6f..13aa466da2 100644 --- a/packages/page-council/src/Overview/Candidates.tsx +++ b/packages/page-council/src/Overview/Candidates.tsx @@ -28,7 +28,7 @@ function Candidates ({ allVotes = {}, electionsInfo }: Props): React.ReactElemen const headerRunnersRef = useRef([ [t('runners up'), 'start', 2], - [t('backing')], + [t('backing'), 'expand'], [t('votes')] ]); diff --git a/packages/page-council/src/Overview/Members.tsx b/packages/page-council/src/Overview/Members.tsx index 85182099c8..202887f7e0 100644 --- a/packages/page-council/src/Overview/Members.tsx +++ b/packages/page-council/src/Overview/Members.tsx @@ -23,7 +23,7 @@ function Members ({ allVotes = {}, className = '', electionsInfo, prime }: Props const headerRef = useRef([ [t('members'), 'start', 2], - [t('backing')], + [t('backing'), 'expand'], [t('votes')] ]); diff --git a/packages/page-council/src/Overview/Voters.tsx b/packages/page-council/src/Overview/Voters.tsx index 0eaa570aa2..0b6f7c0039 100644 --- a/packages/page-council/src/Overview/Voters.tsx +++ b/packages/page-council/src/Overview/Voters.tsx @@ -21,7 +21,7 @@ function Voters ({ balance, voters }: Props): React.ReactElement { return ( <> - + } > {voters.map((who): React.ReactNode => - + {seconding.length !== 0 && ( ('Seconds ({{count}})', { replace: { count: seconding.length } })}> {seconding.map((address, count): React.ReactNode => ( diff --git a/packages/page-democracy/src/Overview/Referendum.tsx b/packages/page-democracy/src/Overview/Referendum.tsx index a5e9c36690..4c66c091bf 100644 --- a/packages/page-democracy/src/Overview/Referendum.tsx +++ b/packages/page-democracy/src/Overview/Referendum.tsx @@ -126,7 +126,6 @@ function Referendum ({ className = '', value: { allAye, allNay, image, imageHash | null { +function ReferendumVotes ({ change, className, count, isAye, isWinning, total, votes }: Props): React.ReactElement | null { const { t } = useTranslation(); - const [trigger] = useState(`votes-${index.toString()}-${++id}`); const sorted = useMemo( () => votes.sort((a, b) => { @@ -45,36 +41,23 @@ function ReferendumVotes ({ change, className, count, index, isAye, isWinning, t return ( + +

{isWinning + ? t('The amount this total can be reduced by to change the referendum outcome. This assumes changes to the convictions of the existing votes, with no additional turnout.') + : t('The amount this total should be increased by to change the referendum outcome. This assumes additional turnout with new votes at 1x conviction.') + }

+ + )} + helpIcon={isWinning ? 'arrow-circle-down' : 'arrow-circle-up'} summary={ <> {isAye ? t('Aye {{count}}', { replace: { count: count ? ` (${formatNumber(count)})` : '' } }) : t('Nay {{count}}', { replace: { count: count ? ` (${formatNumber(count)})` : '' } }) - }{change.gtn(0) && ( - <> - {' '} - - - -

{isWinning - ? t('The amount this total can be reduced by to change the referendum outcome. This assumes changes to the convictions of the existing votes, with no additional turnout.') - : t('The amount this total should be increased by to change the referendum outcome. This assumes additional turnout with new votes at 1x conviction.') - }

- - } - trigger={trigger} - /> - - )} -
- -
+ } +
} > diff --git a/packages/page-democracy/src/Overview/Referendums.tsx b/packages/page-democracy/src/Overview/Referendums.tsx index 22ba3eca3c..973c9d8f62 100644 --- a/packages/page-democracy/src/Overview/Referendums.tsx +++ b/packages/page-democracy/src/Overview/Referendums.tsx @@ -24,7 +24,7 @@ function Referendums ({ className = '', referendums }: Props): React.ReactElemen [t('activate'), 'media--1400'], [t('turnout'), 'media--1400'], [undefined, 'badge'], - [t('votes'), 'start'], + [t('votes'), 'expand'], [undefined, undefined, 2], [undefined, 'media--1000'] ]); diff --git a/packages/page-society/src/Overview/Candidates.tsx b/packages/page-society/src/Overview/Candidates.tsx index 837d6bb404..56719e82b9 100644 --- a/packages/page-society/src/Overview/Candidates.tsx +++ b/packages/page-society/src/Overview/Candidates.tsx @@ -27,7 +27,7 @@ function Candidates ({ allMembers, className = '', isMember, ownMembers }: Props [t('candidates'), 'start'], [t('kind')], [t('value')], - [t('votes'), 'start'], + [t('votes'), 'expand'], [] ]); diff --git a/packages/page-society/src/Overview/Defender.tsx b/packages/page-society/src/Overview/Defender.tsx index 624604b808..a8fe3a741f 100644 --- a/packages/page-society/src/Overview/Defender.tsx +++ b/packages/page-society/src/Overview/Defender.tsx @@ -36,7 +36,7 @@ function Defender ({ className = '', info, isMember, ownMembers }: Props): React const headerRef = useRef([ [t('defender'), 'start'], - [t('votes'), 'start'], + [t('votes'), 'expand'], [] ]); diff --git a/packages/page-society/src/Overview/Votes.tsx b/packages/page-society/src/Overview/Votes.tsx index d33a970ef4..94c7ed6c9e 100644 --- a/packages/page-society/src/Overview/Votes.tsx +++ b/packages/page-society/src/Overview/Votes.tsx @@ -26,7 +26,7 @@ function Votes ({ votes }: Props): React.ReactElement { }, [votes]); return ( - + ('Skeptics')} votes={allSkeptic} diff --git a/packages/page-staking/src/Actions/Account/index.tsx b/packages/page-staking/src/Actions/Account/index.tsx index 3cf2cd4f46..c76154f455 100644 --- a/packages/page-staking/src/Actions/Account/index.tsx +++ b/packages/page-staking/src/Actions/Account/index.tsx @@ -203,7 +203,7 @@ function Account ({ allSlashes, className = '', info: { controllerId, destinatio ) : ( - + {isStashNominating && ( + {nominators ? ( <> diff --git a/packages/page-staking/src/Overview/Address/StakeOther.tsx b/packages/page-staking/src/Overview/Address/StakeOther.tsx index 891a454910..573b16dc7d 100644 --- a/packages/page-staking/src/Overview/Address/StakeOther.tsx +++ b/packages/page-staking/src/Overview/Address/StakeOther.tsx @@ -39,7 +39,7 @@ function StakeOther ({ nominators, stakeOther }: Props): React.ReactElement + {!!rewarded.length && ( <> {eraBlocks && } ('{{count}} own stashes', { replace: { count: numNominators } })}> diff --git a/packages/page-staking/src/Slashes/Row.tsx b/packages/page-staking/src/Slashes/Row.tsx index dac2c925c3..2b32cfa725 100644 --- a/packages/page-staking/src/Slashes/Row.tsx +++ b/packages/page-staking/src/Slashes/Row.tsx @@ -39,7 +39,7 @@ function Row ({ index, isSelected, onSelect, slash: { isMine, slash: { others, o - + {!!others.length && ( ('Nominators ({{count}})', { replace: { count: formatNumber(others.length) } })}> {others.map(([accountId, balance], index): React.ReactNode => ( diff --git a/packages/page-treasury/src/Tips/Tip.tsx b/packages/page-treasury/src/Tips/Tip.tsx index 0c674d238a..c63ae64700 100644 --- a/packages/page-treasury/src/Tips/Tip.tsx +++ b/packages/page-treasury/src/Tips/Tip.tsx @@ -113,21 +113,23 @@ function Tip ({ bestNumber, className = '', defaultId, hash, isMember, members, )} - + {tips.length !== 0 && ( - <> - ('Tippers ({{count}})', { replace: { count: tips.length } })}> - {tips.map(([tipper, balance]) => ( - - ))} - - - + +
{t('Tippers ({{count}})', { replace: { count: tips.length } })}
+ + + }> + {tips.map(([tipper, balance]) => ( + + ))} +
)} diff --git a/packages/react-components/src/Expander.tsx b/packages/react-components/src/Expander.tsx index f63edb0dad..8379562931 100644 --- a/packages/react-components/src/Expander.tsx +++ b/packages/react-components/src/Expander.tsx @@ -2,6 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { IconName } from '@fortawesome/fontawesome-svg-core'; import React, { useMemo } from 'react'; import styled from 'styled-components'; import { LabelHelp } from '@polkadot/react-components'; @@ -19,12 +20,12 @@ export interface Props { children?: React.ReactNode; className?: string; help?: string; + helpIcon?: IconName; isOpen?: boolean; isPadded?: boolean; summary?: React.ReactNode; summaryMeta?: Meta; summarySub?: React.ReactNode; - withDot?: boolean; withHidden?: boolean; } @@ -43,7 +44,7 @@ function formatMeta (meta?: Meta): React.ReactNode | null { ).join(' '); } -function Expander ({ children, className = '', help, isOpen, isPadded, summary, summaryMeta, summarySub, withDot, withHidden }: Props): React.ReactElement { +function Expander ({ children, className = '', help, helpIcon, isOpen, isPadded, summary, summaryMeta, summarySub, withHidden }: Props): React.ReactElement { const { t } = useTranslation(); const [isExpanded, toggleExpanded] = useToggle(isOpen); const headerMain = useMemo( @@ -66,17 +67,20 @@ function Expander ({ children, className = '', help, isOpen, isPadded, summary, onClick={toggleExpanded} >
- {help && } - {hasContent - ? - : withDot - ? - : undefined - }{headerMain || t('Details')} + {help && ( + + )} + {headerMain || t('Details')} + {headerSub && ( +
{headerSub}
+ )}
- {headerSub && ( -
{headerSub}
- )} + {hasContent && + + } {hasContent && (isExpanded || withHidden) && (
{children}
@@ -117,22 +121,31 @@ export default React.memo(styled(Expander)` min-width: 13.5rem; overflow: hidden; - .ui--Expander-summary-header > .ui--FormatBalance { - min-width: 11rem; - } - - > div { + .ui--Expander-summary-header { + display: inline-block; overflow: hidden; text-overflow: ellipsis; + vertical-align: middle; } .ui--Icon { - margin-right: 0.5rem; + margin-left: 0.75rem; + vertical-align: middle; } - .ui--Expander-summary-sub { + .ui--LabelHelp { + .ui--Icon { + margin-left: 0; + margin-right: 0.5rem; + vertical-align: text-bottom; + } + } + + .ui--Expander-summary-header-sub { font-size: 1rem; opacity: 0.6; + overflow: hidden; + text-overflow: ellipsis; } } `); diff --git a/packages/react-components/src/LabelHelp.tsx b/packages/react-components/src/LabelHelp.tsx index 475d87ff46..14515d1ef3 100644 --- a/packages/react-components/src/LabelHelp.tsx +++ b/packages/react-components/src/LabelHelp.tsx @@ -2,6 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { IconName } from '@fortawesome/fontawesome-svg-core'; import React, { useState } from 'react'; import styled from 'styled-components'; @@ -11,18 +12,19 @@ import Tooltip from './Tooltip'; interface Props { help: React.ReactNode; + icon?: IconName; className?: string; } let id = 0; -function LabelHelp ({ className = '', help }: Props): React.ReactElement { +function LabelHelp ({ className = '', help, icon = 'question-circle' }: Props): React.ReactElement { const [trigger] = useState(`label-help-${++id}`); return (
{formatBalance(dispatchInfo.partialFee, { withSiFull: true })} will be applied to the submission } - withDot /> ); }