diff --git a/packages/page-democracy/src/Overview/ProposalCell.tsx b/packages/page-democracy/src/Overview/ProposalCell.tsx index 6663d292e0..7c78f6df5d 100644 --- a/packages/page-democracy/src/Overview/ProposalCell.tsx +++ b/packages/page-democracy/src/Overview/ProposalCell.tsx @@ -2,7 +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 { FunctionMetadataLatest, Hash, Proposal } from '@polkadot/types/interfaces'; +import { Hash, Proposal } from '@polkadot/types/interfaces'; import React from 'react'; import { registry } from '@polkadot/react-api'; @@ -16,21 +16,6 @@ interface Props { proposalHash: Hash | string; } -function formatDocs (meta?: FunctionMetadataLatest): React.ReactNode | null { - if (!meta) { - return null; - } - - const strings = meta.documentation.map((doc): string => doc.toString().trim()); - const firstEmpty = strings.findIndex((doc): boolean => !doc.length); - - if (!firstEmpty) { - return null; - } - - return strings.slice(0, firstEmpty).join(' '); -} - function ProposalCell ({ className, proposal, proposalHash }: Props): React.ReactElement { const { t } = useTranslation(); @@ -48,7 +33,7 @@ function ProposalCell ({ className, proposal, proposalHash }: Props): React.Reac return (
{section}.{method}
- + )} - + - + { +function formatMeta (meta?: Meta): React.ReactNode | null { + if (!meta || !meta.documentation.length) { + return null; + } + + const strings = meta.documentation.map((doc): string => doc.toString().trim()); + const firstEmpty = strings.findIndex((doc): boolean => !doc.length); + + return firstEmpty === -1 + ? strings.join(' ') + : strings.slice(0, firstEmpty).join(' '); +} + +function Expander ({ children, className, isOpen, summary, summaryMeta, withDot, withHidden }: Props): React.ReactElement { + const { t } = useTranslation(); const [isExpanded, toggleExpanded] = useToggle(isOpen); + const headerMain = useMemo( + () => summary || formatMeta(summaryMeta), + [summary, summaryMeta] + ); + const headerSub = useMemo( + () => summary ? formatMeta(summaryMeta) : null, + [summary, summaryMeta] + ); const hasContent = useMemo( (): boolean => !!children && (!Array.isArray(children) || children.length !== 0), [children] @@ -31,12 +60,17 @@ function Expander ({ children, className, isOpen, summary, withDot, withHidden } onClick={toggleExpanded} >
- {hasContent - ? - : withDot - ? - : undefined - }{summary} +
+ {hasContent + ? + : withDot + ? + : undefined + }{headerMain || t('Details')} +
+ {headerSub && ( +
{headerSub}
+ )}
{hasContent && (isExpanded || withHidden) && (
{children}
@@ -68,5 +102,11 @@ export default React.memo(styled(Expander)` i.icon { margin-right: 0.5rem; } + + .ui--Expander-summary-sub { + font-size: 1rem; + opacity: 0.6; + padding-left: 1.75rem; + } } `); diff --git a/packages/react-components/src/ProposedAction.tsx b/packages/react-components/src/ProposedAction.tsx index d9b1b42b2d..9a63b7719b 100644 --- a/packages/react-components/src/ProposedAction.tsx +++ b/packages/react-components/src/ProposedAction.tsx @@ -22,7 +22,6 @@ interface Props { insetProps?: Partial; proposal?: Proposal | null; idNumber: BN | number | string; - isCollapsible?: boolean; withLinks?: boolean; expandNested?: boolean; } @@ -41,7 +40,7 @@ export const styles = ` } `; -function ProposedAction ({ className, asInset, idNumber, insetProps, isCollapsible = true, proposal, withLinks, expandNested }: Props): React.ReactElement { +function ProposedAction ({ className, asInset, idNumber, insetProps, proposal, withLinks, expandNested }: Props): React.ReactElement { const stringId = isString(idNumber) ? idNumber : formatNumber(idNumber); @@ -92,21 +91,9 @@ function ProposedAction ({ className, asInset, idNumber, insetProps, isCollapsib return (

{header}

- {isCollapsible - ? ( - - {documentation} - {params} - - ) - : ( - <> - - {documentation} - - {params} - - )} + + {params} +
); } diff --git a/packages/react-signer/src/Transaction.tsx b/packages/react-signer/src/Transaction.tsx index f53bc1e8a3..f8965e140c 100644 --- a/packages/react-signer/src/Transaction.tsx +++ b/packages/react-signer/src/Transaction.tsx @@ -2,7 +2,6 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { FunctionMetadataLatest } from '@polkadot/types/interfaces'; import { QueueTx } from '@polkadot/react-components/Status/types'; import BN from 'bn.js'; @@ -24,25 +23,6 @@ interface Props { value: QueueTx; } -function formatMeta (meta?: FunctionMetadataLatest): React.ReactNode | null { - if (!meta) { - return null; - } - - const strings = meta.documentation.map((doc): string => doc.toString().trim()); - const firstEmpty = strings.findIndex((doc): boolean => !doc.length); - - if (!firstEmpty) { - return null; - } - - return ( -
- {strings.slice(0, firstEmpty).join(' ')} -
- ); -} - function Transaction ({ children, className, hideDetails, isSendable, onError, value: { accountId, extrinsic, isUnsigned }, tip }: Props): React.ReactElement | null { const { t } = useTranslation(); @@ -75,8 +55,8 @@ function Transaction ({ children, className, hideDetails, isSendable, onError, v }) } + summaryMeta={meta} > - {formatMeta(meta)}