Static output formatting adjustments (#2566)

This commit is contained in:
Jaco Greeff 2020-04-14 10:05:14 +02:00 committed by GitHub
parent 06be45d23f
commit 4950250b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -53,6 +53,7 @@ function Output ({ children, className, help, isError, isHidden, isMonospace, la
export default React.memo(styled(Output)`
pre {
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
}

View File

@ -5,6 +5,7 @@
import { Props as BareProps, RawParam } from '../types';
import React from 'react';
import styled from 'styled-components';
import { Static } from '@polkadot/react-components';
import { useTranslation } from '../translate';
@ -19,7 +20,11 @@ interface Props extends BareProps {
function StaticParam ({ asHex, children, className, defaultValue, label, style }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const value = defaultValue && defaultValue.value && defaultValue.value[asHex ? 'toHex' : 'toString']();
const value = defaultValue && defaultValue.value && (
asHex
? defaultValue.value.toHex()
: JSON.stringify(defaultValue.value.toHuman(), null, 2).replace(/"/g, '')
);
return (
<Bare
@ -29,11 +34,17 @@ function StaticParam ({ asHex, children, className, defaultValue, label, style }
<Static
className='full'
label={label}
value={value || t('<empty>')}
value={<pre>{value || t('<empty>')}</pre>}
/>
{children}
</Bare>
);
}
export default React.memo(StaticParam);
export default React.memo(styled(StaticParam)`
pre {
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
}
`);