From b365d89a11adf40d37b78292f121b890e960d0e8 Mon Sep 17 00:00:00 2001 From: Factiven Date: Thu, 13 Apr 2023 16:03:57 +0700 Subject: update 2nd --- components/footer.js | 2 +- components/hero/content.js | 119 ++++++++++++++++++++++++-------------------- components/media/aniList.js | 2 +- components/navbar.js | 22 +++++++- components/videoPlayer.js | 32 +++++++++++- 5 files changed, 120 insertions(+), 57 deletions(-) (limited to 'components') diff --git a/components/footer.js b/components/footer.js index 3143070..4284dcf 100644 --- a/components/footer.js +++ b/components/footer.js @@ -5,7 +5,7 @@ import Image from "next/image"; function Footer() { return ( -
+

moopa

diff --git a/components/hero/content.js b/components/hero/content.js index 532e4a6..a3db854 100644 --- a/components/hero/content.js +++ b/components/hero/content.js @@ -1,9 +1,12 @@ import Link from "next/link"; -import React from "react"; +import React, { useState } from "react"; import Image from "next/image"; import { MdChevronLeft, MdChevronRight } from "react-icons/md"; export default function Content({ ids, section, data }) { + const [scrollLeft, setScrollLeft] = useState(false); + const [scrollRight, setScrollRight] = useState(true); + const slideLeft = () => { var slider = document.getElementById(ids); slider.scrollLeft = slider.scrollLeft - 500; @@ -13,65 +16,75 @@ export default function Content({ ids, section, data }) { slider.scrollLeft = slider.scrollLeft + 500; }; + const handleScroll = (e) => { + const scrollLeft = e.target.scrollLeft > 31; + const scrollRight = + e.target.scrollLeft < e.target.scrollWidth - e.target.clientWidth; + setScrollLeft(scrollLeft); + setScrollRight(scrollRight); + }; + + // console.log({ left: scrollLeft, right: scrollRight }); + const array = data; const filteredData = array.filter((item) => item.status !== "Unknown"); return (
-

- {section} -

-
-
- -
- {filteredData.map((anime) => { - const url = encodeURIComponent( - anime.title.english || anime.title.romaji - ); - - return ( -
{section} +
+ +
+ {filteredData.map((anime) => { + return ( +
+ - - {anime.title.romaji - -
- ); - })} -
- + {anime.title.romaji + +
+ ); + })}
+
); diff --git a/components/media/aniList.js b/components/media/aniList.js index 3f319c2..5cf65ba 100644 --- a/components/media/aniList.js +++ b/components/media/aniList.js @@ -13,7 +13,7 @@ function AniList() { d="M27.825 21.773V2.977c0-1.077-.613-1.672-1.725-1.672h-3.795c-1.111 0-1.725.595-1.725 1.672v8.927c0 .251 2.5 1.418 2.565 1.665 1.904 7.21.414 12.982-1.392 13.251 2.952.142 3.277 1.517 1.078.578.337-3.848 1.65-3.84 5.422-.142.032.032.774 1.539.82 1.539h8.91c1.113 0 1.726-.594 1.726-1.672v-3.677c0-1.078-.614-1.672-1.725-1.672H27.825z" > diff --git a/components/navbar.js b/components/navbar.js index 3a8c5de..e0c1047 100644 --- a/components/navbar.js +++ b/components/navbar.js @@ -1,8 +1,11 @@ import React, { useState, useEffect } from "react"; import { useTheme } from "next-themes"; import Link from "next/link"; +import { useSession, signIn, signOut } from "next-auth/react"; +import Image from "next/image"; function Navbar(props) { + const { data: session, status } = useSession(); const [isVisible, setIsVisible] = useState(false); const [fade, setFade] = useState(false); const { systemTheme, theme, setTheme } = useTheme(); @@ -22,6 +25,8 @@ function Navbar(props) { setFade(false); }; + // console.log(session.user?.image); + return (
@@ -181,7 +186,7 @@ function Navbar(props) {
diff --git a/components/videoPlayer.js b/components/videoPlayer.js index c680430..e568772 100644 --- a/components/videoPlayer.js +++ b/components/videoPlayer.js @@ -1,10 +1,22 @@ import Player from "../lib/Artplayer"; import { useEffect, useState } from "react"; +import { useAniList } from "../lib/useAnilist"; -export default function VideoPlayer({ data, seek, titles, id }) { +export default function VideoPlayer({ + data, + seek, + titles, + id, + progress, + session, + aniId, +}) { const [url, setUrl] = useState(); const [source, setSource] = useState([]); const [loading, setLoading] = useState(true); + const { markProgress } = useAniList(session); + + // console.log(progress); useEffect(() => { async function compiler() { @@ -69,6 +81,24 @@ export default function VideoPlayer({ data, seek, titles, id }) { } }); + art.on("destroy", () => { + const currentTime = art.currentTime; + const duration = art.duration; + const percentage = currentTime / duration; + + if (percentage >= 0.9) { + // use >= instead of > + markProgress(aniId, progress); + } else { + console.log("Something went wrong"); + } + }); + + art.on("video:ended", () => { + art.destroy(); + console.log("Video ended"); + }); + art.on("destroy", () => { const lastPlayed = { id: id, -- cgit v1.2.3