lbry-desktop/ui/component/common/truncated-text.jsx

26 lines
531 B
React
Raw Normal View History

2018-03-26 14:32:43 -07:00
// @flow
import * as React from 'react';
type Props = {
2019-06-09 00:57:51 -06:00
text?: ?string,
2018-09-24 19:08:24 -04:00
lines: number,
2019-06-09 00:57:51 -06:00
showTooltip?: boolean,
children?: React.Node,
2018-03-26 14:32:43 -07:00
};
2019-06-09 00:57:51 -06:00
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,
};
2018-03-26 14:32:43 -07:00
export default TruncatedText;