Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
- translate the interface into Russian - add picture-in-picture and video fit modes - derive skip segments from Jellyfin chapter markers - align player navigation and add a window drag region - keep audio playback alive across routes
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
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?: Record<string, any>;
|
|
}) => {
|
|
const [displayFull, setDisplayFull] = useState(false);
|
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
const textRef = useRef<HTMLDivElement>(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",
|
|
opacity: 0.8,
|
|
}}
|
|
>
|
|
<Typography
|
|
ref={textRef}
|
|
key={displayFull ? "full" : "collapsed"}
|
|
style={{
|
|
display: "-webkit-box",
|
|
textOverflow: "ellipsis",
|
|
overflow: "hidden",
|
|
WebkitLineClamp: displayFull ? "none" : (collapsedLines ?? 2),
|
|
WebkitBoxOrient: "vertical",
|
|
width: "100%",
|
|
}}
|
|
variant="subtitle2"
|
|
sx={{
|
|
fontWeight: 300,
|
|
}}
|
|
>
|
|
{content}
|
|
</Typography>
|
|
{content.length > 0 && isOverflowing && (
|
|
<Button
|
|
//@ts-ignore
|
|
color="white"
|
|
variant="outlined"
|
|
onClick={() => setDisplayFull((state) => !state)}
|
|
// key={displayFull}
|
|
>
|
|
{displayFull ? "Свернуть" : "Показать больше"}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
export default ShowMoreText;
|