lbry-desktop/ui/component/common/truncated-text.jsx
2019-11-11 13:27:29 -05:00

25 lines
531 B
JavaScript

// @flow
import * as React from 'react';
type Props = {
text?: ?string,
lines: number,
showTooltip?: boolean,
children?: React.Node,
};
const TruncatedText = (props: Props) => {
const { text, children, lines, showTooltip } = props;
const tooltip = showTooltip ? children || text : '';
return (
<span title={tooltip} className="truncated-text" style={{ WebkitLineClamp: lines }}>
{children || text}
</span>
);
};
TruncatedText.defaultProps = {
showTooltip: true,
};
export default TruncatedText;