refactor: move more components to ts

This commit is contained in:
Prayag Prajapati committed 2024-12-03 19:01:17 +05:30
1 parent e049ce9ad6
commit 97526e29b4
12 files changed
+180 -267

No files matched your search

+9 -3
View File
@@ -1,15 +1,20 @@
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import React from "react";
import { useEffect, useRef, useState } from "react";
const ShowMoreText = ({
content,
collapsedLines,
extraProps,
}: { content: string; collapsedLines: number; extraProps?: unknown }) => {
}: {
content: string;
collapsedLines: number;
extraProps?: Record<string, any>;
}) => {
const [displayFull, setDisplayFull] = useState(false);
const [isOverflowing, setIsOverflowing] = useState(false);
const textRef = useRef(null);
const textRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (textRef.current) {
@@ -33,7 +38,7 @@ const ShowMoreText = ({
>
<Typography
ref={textRef}
key={displayFull}
key={displayFull ? "full" : "collapsed"}
style={{
display: "-webkit-box",
textOverflow: "ellipsis",
@@ -49,6 +54,7 @@ const ShowMoreText = ({
</Typography>
{content.length > 0 && isOverflowing && (
<Button
//@ts-ignore
color="white"
variant="outlined"
onClick={() => setDisplayFull((state) => !state)}