mirror of
https://github.com/StanGirard/quivr.git
synced 2025-01-03 16:57:52 +03:00
42 lines
1018 B
TypeScript
42 lines
1018 B
TypeScript
"use client";
|
|
import { cn } from "@/lib/utils";
|
|
import { FC, HTMLAttributes } from "react";
|
|
import Tooltip from "./Tooltip";
|
|
|
|
interface EllipsisProps extends HTMLAttributes<HTMLDivElement> {
|
|
children: string;
|
|
maxCharacters: number;
|
|
tooltip?: boolean;
|
|
}
|
|
|
|
const Ellipsis: FC<EllipsisProps> = ({
|
|
children: originalContent,
|
|
className,
|
|
maxCharacters,
|
|
tooltip = false,
|
|
}) => {
|
|
const renderedContent =
|
|
originalContent.length > maxCharacters
|
|
? `${originalContent.slice(0, maxCharacters)}...`
|
|
: originalContent;
|
|
console.log(originalContent, maxCharacters, tooltip, renderedContent);
|
|
|
|
if (tooltip && originalContent !== renderedContent) {
|
|
return (
|
|
<Tooltip tooltip={originalContent}>
|
|
<span aria-label={originalContent} className={cn("", className)}>
|
|
{renderedContent}
|
|
</span>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<span aria-label={originalContent} className={cn("", className)}>
|
|
{renderedContent}
|
|
</span>
|
|
);
|
|
};
|
|
|
|
export default Ellipsis;
|