import { cn } from "@lume/utils"; import { HTMLProps, useContext, useEffect, useState } from "react"; import { WindowButton } from "../components/button"; import { WindowIcons } from "../components/icons"; import { AppWindowContext } from "../context"; export function MacOS({ className, ...props }: HTMLProps) { const { minimizeWindow, maximizeWindow, fullscreenWindow, closeWindow } = useContext(AppWindowContext); const [isAltKeyPressed, setIsAltKeyPressed] = useState(false); const [isHovering, setIsHovering] = useState(false); const last = isAltKeyPressed ? ( ) : ( ); const key = "Alt"; const handleMouseEnter = () => { setIsHovering(true); }; const handleMouseLeave = () => { setIsHovering(false); }; const handleAltKeyDown = (e: KeyboardEvent) => { if (e.key === key) { setIsAltKeyPressed(true); } }; const handleAltKeyUp = (e: KeyboardEvent) => { if (e.key === key) { setIsAltKeyPressed(false); } }; useEffect(() => { // Attach event listeners when the component mounts window.addEventListener("keydown", handleAltKeyDown); window.addEventListener("keyup", handleAltKeyUp); }, []); return (
{isHovering && } {isHovering && } {isHovering && last}
); }