@react95/core
Version:
Windows 95 styleguide
35 lines (34 loc) • 930 B
JavaScript
import React, { useState, useEffect } from "react";
import { Frame } from "../Frame/Frame.mjs";
import { Tooltip } from "../Tooltip/Tooltip.mjs";
import { tooltip } from "./TaskBar.css.mjs";
const Clock = () => {
const [timer, setTimer] = useState("");
useEffect(() => {
function checkTime(i) {
return i < 10 ? `0${i}` : i;
}
const interval = setInterval(() => {
const today = /* @__PURE__ */ new Date();
const h = today.getHours();
const m = today.getMinutes();
setTimer(`${checkTime(h)}:${checkTime(m)}`);
});
return () => clearInterval(interval);
}, []);
return /* @__PURE__ */ React.createElement(
Frame,
{
boxShadow: "$in",
px: "$6",
py: "$2",
display: "flex",
justifyContent: "center",
alignItems: "center"
},
/* @__PURE__ */ React.createElement(Tooltip, { className: tooltip }, timer)
);
};
export {
Clock
};