ghost-portal/packages/ui-app/src/Output.tsx
YJ 57800cdb83 Fixes #103: Convert functional components to pure (#135)
* ui-signer pureComponentify

* ui-react pureCompify

* Status queue prop

* ui-app Button

* ui-app InputExtrinsic

* apps, app-rpc, ui-app, ui-react

* app-extrinsics, app-explorer, apps

* fixes for tslint

* more linter fixes

* Update index.tsx

* Update index.tsx

* Update Nonce.tsx

* Update index.tsx

* Update Results.tsx

* Update index.tsx

* Update Queries.tsx

* Update NodeInfo.tsx

* Update index.tsx

* Update Item.tsx

* style fixes

* TSLINTs
2018-07-13 07:40:31 +02:00

50 lines
1.2 KiB
TypeScript

// Copyright 2017-2018 @polkadot/ui-app authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { BareProps } from './types';
import React from 'react';
import CopyButton from './CopyButton';
import Labelled from './Labelled';
import classes from './util/classes';
type Props = BareProps & {
children?: React.ReactNode,
isError?: boolean,
isHidden?: boolean,
label?: any, // node?
value?: any,
withCopy?: boolean,
withLabel?: boolean
};
export default class Output extends React.PureComponent<Props> {
render () {
const { className, children, isError = false, isHidden, label, style, value, withCopy = false, withLabel } = this.props;
return (
<Labelled
className={className}
isHidden={isHidden}
label={label}
style={style}
withLabel={withLabel}
>
<div className={classes('ui--output', isError && 'error')}>
{value}
{children}
{
withCopy
? (
<CopyButton className='ui--output-button' value={value} />
)
: null
}
</div>
</Labelled>
);
}
}