mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-14 21:21:56 +03:00
77c6ef6d98
Issue: - https://github.com/StanGirard/quivr/issues/1700 - https://github.com/StanGirard/quivr/issues/1722 Follow-up: - https://github.com/StanGirard/quivr/issues/1753 Demo: https://github.com/StanGirard/quivr/assets/63923024/1e2f8ed9-2a08-48fa-ac19-60910feb4f8d
44 lines
973 B
TypeScript
44 lines
973 B
TypeScript
/* eslint-disable */
|
|
"use client";
|
|
import { HTMLAttributes } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
import Tooltip from "./Tooltip";
|
|
|
|
interface EllipsisProps extends HTMLAttributes<HTMLDivElement> {
|
|
children: string;
|
|
maxCharacters: number;
|
|
tooltip?: boolean;
|
|
}
|
|
|
|
const Ellipsis = ({
|
|
children: originalContent,
|
|
className,
|
|
maxCharacters,
|
|
tooltip = false,
|
|
}: EllipsisProps): JSX.Element => {
|
|
const renderedContent =
|
|
originalContent.length > maxCharacters
|
|
? `${originalContent.slice(0, maxCharacters)}...`
|
|
: originalContent;
|
|
|
|
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;
|