import { useLayoutEffect, useRef, useState } from "react" import Download, { OS_KEY_LEGENDS, OS_NAMES, OS_SHORTCUTS, PLATFORM_NAMES, SHORTCUTS, osOf, type Os } from "./Download" import { guessPlatform, refinePlatform, type Platform } from "./platform" import { OptionKey, SoundToggle, useShout } from "./Shout" import signature from "./footer-signature.svg" function HexMark() { return ( ) } function GitHubMark() { return ( ) } export default function App() { // The prerendered HTML is the Mac page; switch before the first paint, then // refine with client hints. const [platform, setPlatform] = useState("mac") useLayoutEffect(() => { let current = true const guess = guessPlatform() setPlatform(guess) void refinePlatform(guess).then((refined) => { if (current && refined !== guess) setPlatform(refined) }) return () => { current = false } }, []) // The install tabs and the hero's key are one choice: clicking a tab takes // the hero to that OS, until then it follows the detected platform. const [chosenOs, setChosenOs] = useState() const os = chosenOs ?? osOf(platform) const shortcut = chosenOs ? OS_SHORTCUTS[chosenOs] : SHORTCUTS[platform] const osName = chosenOs ? OS_NAMES[chosenOs] : PLATFORM_NAMES[platform] const root = useRef(null) const canvas = useRef(null) const head = useRef(null) const shout = useShout(root, canvas, head) return ( <>
) }