ghost-portal/packages/react-components/src/Output.tsx
Jaco Greeff 51b6956301
Add ui--Toggle overlay positioning (#3377)
* Add ui--Toggle overlay positioning

* adjust label classes

* Max bonded to unbond

* Update packages/page-parachains/src/Parachain/Details.tsx

* Update packages/page-parachains/src/Parachain/Deregister.tsx

* Apply suggestions from code review

* Adjust parachains

* Adjust

* Formatting

* Additional
2020-08-09 11:16:37 +02:00

66 lines
1.6 KiB
TypeScript

// 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';
import CopyButton from './CopyButton';
import Labelled from './Labelled';
import { classes } from './util';
interface Props {
children?: React.ReactNode;
className?: string;
help?: React.ReactNode;
isError?: boolean;
isFull?: boolean;
isHidden?: boolean;
isMonospace?: boolean;
isSmall?: boolean;
isTrimmed?: boolean;
label?: React.ReactNode;
value?: string;
withCopy?: boolean;
withLabel?: boolean;
}
function Output ({ children, className = '', help, isError, isFull, isHidden, isMonospace, isSmall, isTrimmed, label, value, withCopy = false, withLabel }: Props): React.ReactElement<Props> {
return (
<Labelled
className={className}
help={help}
isFull={isFull}
isHidden={isHidden}
isSmall={isSmall}
label={label}
withLabel={withLabel}
>
<div className={classes('ui--output', isError && 'error', isMonospace && 'monospace')}>
{isTrimmed && value && (value.length > 256)
? `${value.substr(0, 96)}…${value.substr(-96)}`
: value
}
{children}
{withCopy
? (
<CopyButton
className='ui--output-button'
value={value}
/>
)
: null
}
</div>
</Labelled>
);
}
export default React.memo(styled(Output)`
pre {
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
}
`);