ghost-telemetry-frontend/src/components/Truncate.tsx
Uncle Fatso e63dad2106
initial commit for public repo
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2024-12-23 15:01:54 +03:00

31 lines
593 B
TypeScript

import * as React from 'react';
interface TruncateProps {
text: string;
chars?: number;
}
export class Truncate extends React.Component<TruncateProps> {
public shouldComponentUpdate(nextProps: TruncateProps): boolean {
return this.props.text !== nextProps.text;
}
public render() {
const { text, chars } = this.props;
if (!text) {
return '-';
}
if (chars != null && text.length <= chars) {
return text;
}
return chars ? (
`${text.substr(0, chars - 1)}`
) : (
<div className="Column-truncate">{text}</div>
);
}
}