quivr/frontend/lib/components/ui/Ellipsis.tsx
Zineb El Bachiri 1d7bc8a5bc
Devx/add linter rules (#331)
* remove duplicate import

* 🚧 add new linter configuration

* 🧑‍💻  add and run prettier

* 🐛 add babel parser for linter

* 🧑‍💻 add lint-fix command

* 🚨 use lint-fix

* 🚨 remove 'FC' as a type. Use const and JSX.Element

* 🚨 enforce arrow function rule from linter

* 🔥 delete unused file

* 🚨 adding /* eslint-disable */ in failing files

* 💩 add ts-expect-error to Victory components
2023-06-15 11:52:46 +02:00

45 lines
1.0 KiB
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;
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;