madiator.com/ui/component/common/truncated-text.jsx
2021-08-16 12:11:25 +02: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;