Add more info to episodeCards
This commit is contained in:
3 files changed
+147
-13
No files matched your search
@@ -4,6 +4,8 @@ import PropTypes from "prop-types";
|
|||||||
|
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import MuiCard from "@mui/material/Card";
|
import MuiCard from "@mui/material/Card";
|
||||||
import CardContent from "@mui/material/CardContent";
|
import CardContent from "@mui/material/CardContent";
|
||||||
@@ -30,9 +32,13 @@ import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api";
|
|||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import { MdiHeartOutline } from "../icons/mdiHeartOutline";
|
import { MdiHeartOutline } from "../icons/mdiHeartOutline";
|
||||||
import { MdiHeart } from "../icons/mdiHeart";
|
import { MdiHeart } from "../icons/mdiHeart";
|
||||||
|
import { endsAt, getRuntime } from "../../utils/date/time";
|
||||||
|
import { MdiStarHalfFull } from "../icons/mdiStarHalfFull";
|
||||||
|
|
||||||
export const EpisodeCard = ({
|
export const EpisodeCard = ({
|
||||||
itemName,
|
itemName,
|
||||||
|
itemRating,
|
||||||
|
itemTicks,
|
||||||
itemId,
|
itemId,
|
||||||
imageTags,
|
imageTags,
|
||||||
subText = "",
|
subText = "",
|
||||||
@@ -247,22 +253,103 @@ export const EpisodeCard = ({
|
|||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Typography
|
<Box
|
||||||
gutterBottom={false}
|
|
||||||
variant="h6"
|
|
||||||
component="div"
|
|
||||||
color="white"
|
|
||||||
fontWeight={500}
|
|
||||||
textAlign="left"
|
|
||||||
noWrap
|
|
||||||
width="fit-content"
|
|
||||||
maxWidth="100%"
|
|
||||||
sx={{
|
sx={{
|
||||||
|
display: "flex",
|
||||||
opacity: !!showName ? 0.75 : 1,
|
opacity: !!showName ? 0.75 : 1,
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
|
width="100%"
|
||||||
|
mb={0.5}
|
||||||
|
mt={0.5}
|
||||||
>
|
>
|
||||||
{itemName}
|
<Typography
|
||||||
</Typography>
|
gutterBottom={false}
|
||||||
|
variant="h6"
|
||||||
|
component="div"
|
||||||
|
color="white"
|
||||||
|
fontWeight={500}
|
||||||
|
textAlign="left"
|
||||||
|
noWrap
|
||||||
|
width="fit-content"
|
||||||
|
maxWidth="100%"
|
||||||
|
>
|
||||||
|
{itemName}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
gutterBottom={false}
|
||||||
|
variant="h6"
|
||||||
|
component="div"
|
||||||
|
color="white"
|
||||||
|
fontWeight={300}
|
||||||
|
textAlign="left"
|
||||||
|
noWrap
|
||||||
|
width="fit-content"
|
||||||
|
maxWidth="100%"
|
||||||
|
sx={{
|
||||||
|
opacity: 0.65,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{getRuntime(itemTicks)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Stack
|
||||||
|
alignItems="flex-start"
|
||||||
|
width="100%"
|
||||||
|
direction="row"
|
||||||
|
gap={1}
|
||||||
|
divider={
|
||||||
|
<Divider
|
||||||
|
flexItem
|
||||||
|
orientation="vertical"
|
||||||
|
variant="middle"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
mb={1}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
gutterBottom={false}
|
||||||
|
variant="subtitle1"
|
||||||
|
component="div"
|
||||||
|
color="white"
|
||||||
|
fontWeight={300}
|
||||||
|
textAlign="left"
|
||||||
|
noWrap
|
||||||
|
width="fit-content"
|
||||||
|
maxWidth="100%"
|
||||||
|
sx={{
|
||||||
|
opacity: 0.65,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MdiStarHalfFull
|
||||||
|
sx={{ fontSize: "1.2em", mr: "0.25em" }}
|
||||||
|
/>{" "}
|
||||||
|
{itemRating}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
gutterBottom={false}
|
||||||
|
variant="subtitle1"
|
||||||
|
component="div"
|
||||||
|
color="white"
|
||||||
|
fontWeight={300}
|
||||||
|
textAlign="left"
|
||||||
|
noWrap
|
||||||
|
width="fit-content"
|
||||||
|
maxWidth="100%"
|
||||||
|
sx={{
|
||||||
|
opacity: 0.65,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{endsAt(itemTicks)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
<Typography
|
<Typography
|
||||||
gutterBottom
|
gutterBottom
|
||||||
variant="body2"
|
variant="body2"
|
||||||
@@ -271,7 +358,13 @@ export const EpisodeCard = ({
|
|||||||
textAlign="left"
|
textAlign="left"
|
||||||
width="fit-content"
|
width="fit-content"
|
||||||
maxWidth="100%"
|
maxWidth="100%"
|
||||||
sx={{ opacity: 0.5 }}
|
sx={{
|
||||||
|
display: "-webkit-box",
|
||||||
|
overflow: "hidden",
|
||||||
|
WebkitBoxOrient: "vertical",
|
||||||
|
WebkitLineClamp: 3,
|
||||||
|
opacity: 0.45,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{subText}
|
{subText}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -294,4 +387,6 @@ EpisodeCard.propTypes = {
|
|||||||
favourite: PropTypes.bool,
|
favourite: PropTypes.bool,
|
||||||
showName: PropTypes.string,
|
showName: PropTypes.string,
|
||||||
episodeLocation: PropTypes.string,
|
episodeLocation: PropTypes.string,
|
||||||
|
itemTicks: PropTypes.number.isRequired,
|
||||||
|
itemRating: PropTypes.number.isRequired,
|
||||||
};
|
};
|
||||||
@@ -709,6 +709,12 @@ const ItemDetail = () => {
|
|||||||
currentUser={
|
currentUser={
|
||||||
user.data
|
user.data
|
||||||
}
|
}
|
||||||
|
itemTicks={
|
||||||
|
mitem.RunTimeTicks
|
||||||
|
}
|
||||||
|
itemRating={
|
||||||
|
mitem.CommunityRating
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Grid2>
|
</Grid2>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ const ticksToMs = (ticks) => {
|
|||||||
return Math.round(ticks / 10000);
|
return Math.round(ticks / 10000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @format
|
||||||
|
* @param {number} ticks - C# ticks of a particular item
|
||||||
|
* @return {number} Converted ticks to Hhr Mmin formate
|
||||||
|
*/
|
||||||
export const getRuntime = (ticks) => {
|
export const getRuntime = (ticks) => {
|
||||||
let time = ticksToMs(ticks);
|
let time = ticksToMs(ticks);
|
||||||
let formatedTime = "";
|
let formatedTime = "";
|
||||||
@@ -23,6 +28,11 @@ export const getRuntime = (ticks) => {
|
|||||||
return formatedTime;
|
return formatedTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @format
|
||||||
|
* @param {number} ticks - C# ticks of a particular item
|
||||||
|
* @return {number} Converted ticks to H hour M minutes formate
|
||||||
|
*/
|
||||||
export const getRuntimeFull = (ticks) => {
|
export const getRuntimeFull = (ticks) => {
|
||||||
let time = ticksToMs(ticks);
|
let time = ticksToMs(ticks);
|
||||||
let formatedTime = "";
|
let formatedTime = "";
|
||||||
@@ -37,3 +47,26 @@ export const getRuntimeFull = (ticks) => {
|
|||||||
}
|
}
|
||||||
return formatedTime;
|
return formatedTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @format
|
||||||
|
* @param {number} ticks - C# ticks of a particular item
|
||||||
|
* @return {number} End time of an item
|
||||||
|
*/
|
||||||
|
export const endsAt = (ticks) => {
|
||||||
|
let current = new Date();
|
||||||
|
let currentTime =
|
||||||
|
current.getHours() * 3600000 + current.getMinutes() * 60000;
|
||||||
|
let time = ticksToMs(ticks);
|
||||||
|
let calculatedTime = currentTime + time;
|
||||||
|
let hr = Math.floor(calculatedTime / 3600000);
|
||||||
|
calculatedTime -= hr * 3600000;
|
||||||
|
let min = Math.floor(calculatedTime / 60000);
|
||||||
|
let formated = new Date(calculatedTime).toLocaleTimeString([], {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
});
|
||||||
|
// let formated = `${hr - 12}:${min}`;
|
||||||
|
// return `Ends at ${formated.getHours()}:${formated.getMinutes()}`;
|
||||||
|
return `Ends at ${formated}`;
|
||||||
|
};
|
||||||
Reference in new issue
Block a user