1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

really shitty popup setup

This commit is contained in:
Captain Jack Sparrow 2024-06-13 17:45:34 +00:00
parent 9708817ca4
commit caefbb54fc
3 changed files with 38 additions and 18 deletions

View file

@ -201,15 +201,12 @@ export function MediaCard(props: MediaCardProps) {
if (!canLink) return <span>{content}</span>;
return (
<Link
to={link}
<div
tabIndex={-1}
className={classNames(
"tabbable",
props.closable ? "hover:cursor-default" : "",
)}
className={classNames("tabbable", props.closable ? "hover:cursor-default" : "")}
onClick={props.onClick}
>
{content}
</Link>
</div>
);
}

View file

@ -0,0 +1,17 @@
import React from 'react';
interface PopupModalProps {
isVisible: boolean;
onClose: () => void;
}
export function PopupModal({ isVisible, onClose }: PopupModalProps) {
if (!isVisible) return null;
return (
<div className="popup-overlay">
<button onClick={onClose}>Close</button>
</div>
);
}

View file

@ -1,4 +1,4 @@
import { useCallback, useMemo } from "react";
import { useCallback, useMemo, useState } from "react";
import { usePlayerStore } from "@/stores/player/store";
import { useProgressStore } from "@/stores/progress";
@ -7,6 +7,7 @@ import {
shouldShowProgress,
} from "@/stores/progress/utils";
import { MediaItem } from "@/utils/mediaTypes";
import { PopupModal } from "./PopupModal";
import { MediaCard } from "./MediaCard";
@ -38,11 +39,12 @@ export function WatchedMediaCard(props: WatchedMediaCardProps) {
const percentage = itemToDisplay?.show
? (itemToDisplay.progress.watched / itemToDisplay.progress.duration) * 100
: undefined;
const setPlayingTitle = usePlayerStore((state) => state.setPlayingTitle);
const [isPopupVisible, setIsPopupVisible] = useState(false);
const handleClick = useCallback(() => {
setPlayingTitle(props.media.id, props.media.title, props.media.type);
setIsPopupVisible(!isPopupVisible);
console.log(
usePlayerStore.getState().playingTitle.title,
usePlayerStore.getState().playingTitle.id,
@ -50,15 +52,19 @@ export function WatchedMediaCard(props: WatchedMediaCardProps) {
);
}, [setPlayingTitle, props.media.id, props.media.title, props.media.type]);
return (
<MediaCard
media={props.media}
series={formatSeries(itemToDisplay)}
linkable
percentage={percentage}
onClose={props.onClose}
closable={props.closable}
onClick={handleClick}
/>
<>
<MediaCard
media={props.media}
series={formatSeries(itemToDisplay)}
linkable
percentage={percentage}
onClose={props.onClose}
closable={props.closable}
onClick={handleClick}
/>
<PopupModal isVisible={isPopupVisible} onClose={() => setIsPopupVisible(false)} />
</>
);
}