feat: add suspend state and make all buttons related to state working

This commit is contained in:
Pihkaal
2024-09-11 17:32:57 +02:00
parent 14ef2317fa
commit 79902cb7f1
7 changed files with 36 additions and 17 deletions

View File

@@ -1,25 +1,31 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { useApp } from "~/hooks/useApp";
export const Off = () => {
const { setState } = useApp();
const [clicked, setClicked] = useState(false);
const { state, setState } = useApp();
const [booting, setBooting] = useState(state === "reboot");
const handleClick = () => {
setClicked(true);
useEffect(() => {
if (booting) {
const timout = setTimeout(() => {
if (state === "suspend") {
setState("login");
} else {
setState("boot");
}
}, 1000);
setTimeout(() => {
setState("boot");
}, 1000);
};
return () => clearTimeout(timout);
}
}, [booting]);
return (
<div className="flex h-screen w-screen items-center justify-center bg-black">
<button
className={`drop-shadow-white cursor-pointer transition-all ${
clicked ? "animate-disappear" : "animate-breathing"
booting ? "animate-disappear" : "animate-breathing"
}`}
onClick={handleClick}
onClick={() => setBooting(true)}
>
<svg viewBox="0 0 34 34" width="128">
<path