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

26 lines
531 B
React
Raw Normal View History

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