Cleanup external display (#2591)
This commit is contained in:
parent
cf5f95ac6e
commit
f48581dfef
@ -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<Props> |
|
||||
}
|
||||
|
||||
return (
|
||||
<CallExpander
|
||||
<Holder
|
||||
className={className}
|
||||
labelHash={t('proposal hash')}
|
||||
value={preimage.proposal}
|
||||
withBorder
|
||||
withHash
|
||||
/>
|
||||
withPadding
|
||||
>
|
||||
<CallExpander
|
||||
labelHash={t('proposal hash')}
|
||||
value={preimage.proposal}
|
||||
withHash
|
||||
/>
|
||||
</Holder>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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<Props> {
|
||||
function CallExpander ({ children, className, labelHash, value, withHash }: Props): React.ReactElement<Props> {
|
||||
const { meta, method, section } = registry.findMetaCall(value.callIndex);
|
||||
|
||||
return (
|
||||
@ -29,7 +28,6 @@ function CallExpander ({ children, className, labelHash, value, withBorder, with
|
||||
<CallDisplay
|
||||
labelHash={labelHash}
|
||||
value={value}
|
||||
withBorder={withBorder}
|
||||
withHash={withHash}
|
||||
/>
|
||||
{children}
|
||||
|
||||
97
packages/react-params/src/Holder.tsx
Normal file
97
packages/react-params/src/Holder.tsx
Normal file
@ -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<Props> {
|
||||
return (
|
||||
<div className={`ui--Params ${className} ${withBorder ? 'withBorder' : 'withoutBorder'} ${withPadding && 'withPadding'}`}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
`);
|
||||
@ -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<Props, State> {
|
||||
public state: State = {
|
||||
params: null
|
||||
@ -75,7 +76,7 @@ class Params extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
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<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classes('ui--Params', className, withBorder ? 'withBorder' : 'withoutBorder')}
|
||||
style={style}
|
||||
<Holder
|
||||
className={className}
|
||||
withBorder={withBorder}
|
||||
>
|
||||
<ErrorBoundary onError={this.onRenderError}>
|
||||
<div className='ui--Params-Content'>
|
||||
@ -106,7 +107,7 @@ class Params extends React.PureComponent<Props, State> {
|
||||
</div>
|
||||
{children}
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
</Holder>
|
||||
);
|
||||
}
|
||||
|
||||
@ -149,76 +150,4 @@ class Params extends React.PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate(
|
||||
styled(Params as React.ComponentClass<Props>)`
|
||||
&.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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user