diff --git a/packages/page-democracy/src/Overview/ExternalCell.tsx b/packages/page-democracy/src/Overview/ExternalCell.tsx index 9254101187..9f77ffc259 100644 --- a/packages/page-democracy/src/Overview/ExternalCell.tsx +++ b/packages/page-democracy/src/Overview/ExternalCell.tsx @@ -8,6 +8,7 @@ import { Hash } from '@polkadot/types/interfaces'; import React from 'react'; import { useApi, useCall } from '@polkadot/react-hooks'; import { CallExpander } from '@polkadot/react-components'; +import { Holder } from '@polkadot/react-params'; import { useTranslation } from '../translate'; @@ -26,13 +27,17 @@ function ExternalCell ({ className, value }: Props): React.ReactElement | } return ( - + withPadding + > + + ); } diff --git a/packages/react-components/src/CallExpander.tsx b/packages/react-components/src/CallExpander.tsx index c94e7642a6..a6ec99ab6a 100644 --- a/packages/react-components/src/CallExpander.tsx +++ b/packages/react-components/src/CallExpander.tsx @@ -15,11 +15,10 @@ interface Props { className?: string; labelHash?: React.ReactNode; value: Call; - withBorder?: boolean; withHash?: boolean; } -function CallExpander ({ children, className, labelHash, value, withBorder, withHash }: Props): React.ReactElement { +function CallExpander ({ children, className, labelHash, value, withHash }: Props): React.ReactElement { const { meta, method, section } = registry.findMetaCall(value.callIndex); return ( @@ -29,7 +28,6 @@ function CallExpander ({ children, className, labelHash, value, withBorder, with {children} diff --git a/packages/react-params/src/Holder.tsx b/packages/react-params/src/Holder.tsx new file mode 100644 index 0000000000..122439d842 --- /dev/null +++ b/packages/react-params/src/Holder.tsx @@ -0,0 +1,97 @@ +// Copyright 2017-2020 @polkadot/react-components authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import React from 'react'; +import styled from 'styled-components'; + +interface Props { + children?: React.ReactNode; + className?: string; + withBorder?: boolean; + withPadding?: boolean; +} + +function Holder ({ children, className, withBorder, withPadding }: Props): React.ReactElement { + return ( +
+ {children} +
+ ); +} + +export default React.memo(styled(Holder)` + &.withBorder { + border-left: 0.25rem solid #f2f2f2; + } + + &.withoutBorder { + margin-left: -1.75rem; + padding: 0; + } + + &.withPadding { + padding-left: 4rem; + } + + .ui--Param .ui--Labelled label { + text-transform: none !important; + font-family: monospace; + } + + .ui--row { + flex-wrap: wrap; + } + + .ui--Param-Address { + font-family: monospace; + } + + .ui--Params-Content { + box-sizing: border-box; + padding: 0 0 0 1.75rem; + } + + .ui--Param-text { + display: inline-block; + font-size: 1rem; + line-height: 1.714rem; + overflow: hidden; + text-overflow: ellipsis; + } + + .ui--Param-text .icon { + margin-right: 0.5rem !important; + } + + .ui--Param-text * { + vertical-align: middle; + } + + .ui--Param-text.nowrap { + white-space: nowrap; + } + + .ui--Param-text.name { + color: rgba(0, 0, 0, .6); + font-style: italic; + } + + .ui--Param-text + .ui--Param-text { + margin-left: 0.5rem; + } + + .ui--Param-Vector-buttons { + text-align: right; + } + + .ui--Param-composite { + position: relative; + + .ui--Param-overlay { + position: absolute; + top: 0.5rem; + right: 3.5rem; + } + } +`); diff --git a/packages/react-params/src/index.tsx b/packages/react-params/src/index.tsx index 3e0f5951d5..35547fa652 100644 --- a/packages/react-params/src/index.tsx +++ b/packages/react-params/src/index.tsx @@ -6,10 +6,9 @@ import { I18nProps } from '@polkadot/react-components/types'; import { ComponentMap, ParamDef, RawParam, RawParams, RawParamOnChangeValue } from './types'; import React from 'react'; -import styled from 'styled-components'; import { ErrorBoundary } from '@polkadot/react-components'; -import { classes } from '@polkadot/react-components/util'; +import Holder from './Holder'; import ParamComp from './ParamComp'; import translate from './translate'; import { createValue } from './values'; @@ -32,6 +31,8 @@ interface State { values?: RawParams; } +export { Holder }; + class Params extends React.PureComponent { public state: State = { params: null @@ -75,7 +76,7 @@ class Params extends React.PureComponent { } public render (): React.ReactNode { - const { children, className, isDisabled, onEnter, onEscape, overrides, params, style, withBorder = true } = this.props; + const { children, className, isDisabled, onEnter, onEscape, overrides, params, withBorder = true } = this.props; const { values = this.props.values } = this.state; if (!values || !values.length) { @@ -83,9 +84,9 @@ class Params extends React.PureComponent { } return ( -
@@ -106,7 +107,7 @@ class Params extends React.PureComponent {
{children}
-
+ ); } @@ -149,76 +150,4 @@ class Params extends React.PureComponent { } } -export default translate( - styled(Params as React.ComponentClass)` - &.withBorder { - border-left: 0.25rem solid #f2f2f2; - } - - &.withoutBorder { - margin-left: -1.75rem; - padding: 0; - } - - .ui--Param .ui--Labelled label { - text-transform: none !important; - font-family: monospace; - } - - .ui--row { - flex-wrap: wrap; - } - - .ui--Param-Address { - font-family: monospace; - } - - .ui--Params-Content { - box-sizing: border-box; - padding: 0 0 0 1.75rem; - } - - .ui--Param-text { - display: inline-block; - font-size: 1rem; - line-height: 1.714rem; - overflow: hidden; - text-overflow: ellipsis; - } - - .ui--Param-text .icon { - margin-right: 0.5rem !important; - } - - .ui--Param-text * { - vertical-align: middle; - } - - .ui--Param-text.nowrap { - white-space: nowrap; - } - - .ui--Param-text.name { - color: rgba(0, 0, 0, .6); - font-style: italic; - } - - .ui--Param-text + .ui--Param-text { - margin-left: 0.5rem; - } - - .ui--Param-Vector-buttons { - text-align: right; - } - - .ui--Param-composite { - position: relative; - - .ui--Param-overlay { - position: absolute; - top: 0.5rem; - right: 3.5rem; - } - } - ` -); +export default translate(Params);