1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-21 14:47:41 +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>; if (!canLink) return <span>{content}</span>;
return ( return (
<Link <div
to={link}
tabIndex={-1} tabIndex={-1}
className={classNames( className={classNames("tabbable", props.closable ? "hover:cursor-default" : "")}
"tabbable", onClick={props.onClick}
props.closable ? "hover:cursor-default" : "",
)}
> >
{content} {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 { usePlayerStore } from "@/stores/player/store";
import { useProgressStore } from "@/stores/progress"; import { useProgressStore } from "@/stores/progress";
@ -7,6 +7,7 @@ import {
shouldShowProgress, shouldShowProgress,
} from "@/stores/progress/utils"; } from "@/stores/progress/utils";
import { MediaItem } from "@/utils/mediaTypes"; import { MediaItem } from "@/utils/mediaTypes";
import { PopupModal } from "./PopupModal";
import { MediaCard } from "./MediaCard"; import { MediaCard } from "./MediaCard";
@ -38,11 +39,12 @@ export function WatchedMediaCard(props: WatchedMediaCardProps) {
const percentage = itemToDisplay?.show const percentage = itemToDisplay?.show
? (itemToDisplay.progress.watched / itemToDisplay.progress.duration) * 100 ? (itemToDisplay.progress.watched / itemToDisplay.progress.duration) * 100
: undefined; : undefined;
const setPlayingTitle = usePlayerStore((state) => state.setPlayingTitle); const setPlayingTitle = usePlayerStore((state) => state.setPlayingTitle);
const [isPopupVisible, setIsPopupVisible] = useState(false);
const handleClick = useCallback(() => { const handleClick = useCallback(() => {
setPlayingTitle(props.media.id, props.media.title, props.media.type); setPlayingTitle(props.media.id, props.media.title, props.media.type);
setIsPopupVisible(!isPopupVisible);
console.log( console.log(
usePlayerStore.getState().playingTitle.title, usePlayerStore.getState().playingTitle.title,
usePlayerStore.getState().playingTitle.id, usePlayerStore.getState().playingTitle.id,
@ -50,7 +52,9 @@ export function WatchedMediaCard(props: WatchedMediaCardProps) {
); );
}, [setPlayingTitle, props.media.id, props.media.title, props.media.type]); }, [setPlayingTitle, props.media.id, props.media.title, props.media.type]);
return ( return (
<>
<MediaCard <MediaCard
media={props.media} media={props.media}
series={formatSeries(itemToDisplay)} series={formatSeries(itemToDisplay)}
@ -60,5 +64,7 @@ export function WatchedMediaCard(props: WatchedMediaCardProps) {
closable={props.closable} closable={props.closable}
onClick={handleClick} onClick={handleClick}
/> />
<PopupModal isVisible={isPopupVisible} onClose={() => setIsPopupVisible(false)} />
</>
); );
} }