this timer is stupud im not doing it
This commit is contained in:
parent
ddfb2ec900
commit
bb68711a48
2 changed files with 3 additions and 61 deletions
|
|
@ -1,54 +0,0 @@
|
|||
import { useState, useEffect } from "preact/hooks";
|
||||
|
||||
const CurrentTime = () => {
|
||||
const [currentTime, setCurrentTime] = useState('');
|
||||
const [currentMinutes, setCurrentMinutes] = useState('');
|
||||
const [opacity, setOpacity] = useState(0);
|
||||
|
||||
useEffect(() => { // LITERAL HELL
|
||||
const updateCurrentTime = () => {
|
||||
const now = new Date();
|
||||
const dayOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][now.getDay()];
|
||||
let hours = now.getHours();
|
||||
hours = hours % 12 || 12; // 12 hour format
|
||||
const minutes = now.getMinutes();
|
||||
|
||||
const formattedTime = `${dayOfWeek}, ${hours < 10 ? '0' : ''}${hours}`;
|
||||
setCurrentTime(formattedTime);
|
||||
};
|
||||
|
||||
const updateCurrentMinutes = () => {
|
||||
const now = new Date();
|
||||
const minutes = now.getMinutes();
|
||||
const formattedMinutes = `${minutes < 10 ? '0' : ''}${minutes}`;
|
||||
setCurrentMinutes(formattedMinutes);
|
||||
};
|
||||
|
||||
updateCurrentTime();
|
||||
updateCurrentMinutes();
|
||||
|
||||
const timeIntervalId = setInterval(updateCurrentTime, 60000);
|
||||
const minutesIntervalId = setInterval(updateCurrentMinutes, 1000);
|
||||
return () => {
|
||||
clearInterval(timeIntervalId);
|
||||
clearInterval(minutesIntervalId);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
setOpacity((prevOpacity) => (prevOpacity === 0 ? 1 : 0));
|
||||
}, 1000);
|
||||
return () => clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div class="flex flex-row">
|
||||
<div>{currentTime}</div>
|
||||
<div style={{ opacity }}>:</div>
|
||||
<div>{currentMinutes} PM</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CurrentTime;
|
||||
|
|
@ -2,21 +2,17 @@ import { useLocation } from "preact-iso";
|
|||
import LinkSvg from "../assets/link.svg";
|
||||
import LogoSvg from "../assets/logo.svg";
|
||||
import { useState, useEffect } from "preact/hooks"
|
||||
import Clock from "./Clock";
|
||||
|
||||
export function Header() {
|
||||
const { url } = useLocation();
|
||||
|
||||
return (
|
||||
<div id="navbar" className="h-16 px-4 bg-navbar-color flex flex-row items-center justify-between">
|
||||
<div className="flex flex-row items-center w-1/3">
|
||||
<div className="flex flex-row items-center w-1/2">
|
||||
<img src="/logo.png" className="h-16 w-16"></img>
|
||||
<h1 className="font-roboto text-text-color text-4xl">nebula.</h1>
|
||||
</div>
|
||||
|
||||
<div className="w-1/3">
|
||||
<Clock />
|
||||
</div>
|
||||
<div className="w-1/3">
|
||||
<div className="w-1/2">
|
||||
<span className="">Games</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue