17 lines
336 B
TypeScript
17 lines
336 B
TypeScript
type AbbrProps = {
|
|
children: string
|
|
maxLen?: number
|
|
}
|
|
|
|
export function Abbr({ children, maxLen = 30, ...props }: AbbrProps) {
|
|
if (children.length <= maxLen) {
|
|
return <abbr {...props}>{children}</abbr>
|
|
}
|
|
|
|
return (
|
|
<abbr title={children} {...props}>
|
|
{children.substring(0, maxLen).concat('...')}
|
|
</abbr>
|
|
)
|
|
}
|