nominate animation

This commit is contained in:
2025-08-03 13:56:41 +02:00
parent 80eb434cde
commit 5ee177e4cf
3 changed files with 41 additions and 29 deletions
+19 -9
View File
@@ -1,6 +1,6 @@
"use client";
import "./style.css";
import { useState } from "react";
import { useState, createContext, useContext } from "react";
import { AuthProvider } from "react-oidc-context";
import { oidcConfig, userManager } from "muzak/config/auth";
import { Source_Sans_3, Nunito } from "next/font/google";
@@ -8,10 +8,22 @@ import AuthStatus from "muzak/components/AuthStatus";
import NavigationBar from "muzak/components/NavigationBar";
import Quota from "muzak/components/Quota";
const sourceSans = Source_Sans_3({
weight: ["400"],
subsets: ["latin"],
});
interface AnimationContextType {
isAnimate: boolean;
setIsAnimate: React.Dispatch<React.SetStateAction<boolean>>;
}
const AnimationContext = createContext<AnimationContextType | undefined>(
undefined,
);
export const useAnimation = () => {
const context = useContext(AnimationContext);
if (context === undefined) {
throw new Error("useAnimation must be used within an AnimationProvider");
}
return context;
};
const nunito = Nunito({
subsets: ["latin"],
@@ -52,16 +64,14 @@ export default function RootLayout({
<html lang="en" className={nunito.className}>
<body className={`bg-game-show ${isAnimate ? "animate" : ""} h-screen`}>
<AuthProvider {...oidcConfig}>
<AnimationContext.Provider value={{ isAnimate, setIsAnimate }}>
<LayoutContent
children={children}
quota={quota}
setQuota={setQuota}
/>
</AnimationContext.Provider>
</AuthProvider>
<button
className={`absolute top-1 left-1 ${isAnimate ? "pause" : "play"}`}
onClick={toggleAnimation}
></button>
</body>
</html>
);
+10 -8
View File
@@ -2,30 +2,32 @@
import { useState } from "react";
import { Nunito } from "next/font/google";
import { api } from "muzak/data/fetcher";
import { useAnimation } from "../layout";
const nunito = Nunito({
weight: "900",
subsets: ["latin"],
});
async function nominate(spotifyLink: string) {
console.log(spotifyLink);
export default function Nominations() {
const { isAnimate, setIsAnimate } = useAnimation();
const [songURL, setSongURL] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [message, setMessage] = useState("");
async function nominate(spotifyLink: string) {
try {
setIsAnimate(false);
const response = await api.tracks.nominate({
spotify_link: spotifyLink,
});
console.log("Nomination successful:", response);
setIsAnimate(true);
return { success: true, data: response.data };
} catch (error) {
console.error("Nomination failed:", error);
return { success: false, error };
}
}
export default function Nominations() {
const [songURL, setSongURL] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [message, setMessage] = useState("");
}
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
+1 -1
View File
@@ -15,7 +15,7 @@
}
.bg-game-show.animate {
animation: rotate_bg 5s cubic-bezier(0.55, 0.45, 0.45, 0.55) infinite;
animation: rotate_bg 1.5s ease-in-out;
}
@keyframes rotate_bg {