chore(web): Implement new ArtistPage and add new TracksList component #243

This commit is contained in:
Prayag Prajapati committed 2024-01-19 18:56:27 +05:30
1 parent 9e73421540
commit 9149792ed9
21 files changed
+704 -284

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import { useEffect, useRef, useState } from "react";
const ShowMoreText = ({ content, collapsedLines, extraProps }) => {
const [displayFull, setDisplayFull] = useState(false);
const [isOverflowing, setIsOverflowing] = useState(false);
const textRef = useRef(null);
useEffect(() => {
if (textRef.current) {
if (textRef.current.offsetHeight < textRef.current.scrollHeight) {
setIsOverflowing(true);
} else {
setIsOverflowing(false);
}
// textRef.current.
}
}, []);
return (
<div
className="flex flex-column"
{...extraProps}
style={{
alignItems: "flex-end",
gap: "1em",
}}
>
<Typography
ref={textRef}
key={displayFull}
style={{
display: "-webkit-box",
textOverflow: "ellipsis",
overflow: "hidden",
WebkitLineClamp: displayFull ? "none" : collapsedLines ?? 2,
WebkitBoxOrient: "vertical",
width: "100%",
}}
>
{content}
</Typography>
{content.length > 0 && isOverflowing && (
<Button
color="white"
variant="outlined"
onClick={() => setDisplayFull((state) => !state)}
// key={displayFull}
>
{displayFull ? "Show less" : "Show more"}
</Button>
)}
</div>
);
};
export default ShowMoreText;