mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-23 11:23:00 +03:00
1d7bc8a5bc
* 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
45 lines
1.0 KiB
TypeScript
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;
|