)
}
// Places the selected-tab pill (`.install__os::before`) under the chosen tab.
// Until the first measurement the selected tab paints its own background, so
// the prerendered page and a page without scripts still show the selection.
// The pill slides only after a click (`data-animate`), so the OS picked from
// the user agent on load doesn't animate in from macOS.
function useTabIndicator(list: RefObject, selected: Os) {
useLayoutEffect(() => {
const element = list.current
if (!element) return
const place = () => {
const tab = element.querySelector('[aria-selected="true"]')
if (!tab) return
element.style.setProperty("--tab-x", `${tab.offsetLeft}px`)
element.style.setProperty("--tab-width", `${tab.offsetWidth}px`)
element.dataset.measured = ""
}
place()
// Tab widths change when Inter finishes loading or the viewport resizes.
const observer = new ResizeObserver(place)
observer.observe(element)
return () => observer.disconnect()
}, [list, selected])
}
export default function Download({ platform }: { platform: Platform }) {
const [chosenOs, setOs] = useState()
const os = chosenOs ?? osOf(platform)
const [chosenArch, setArch] = useState()
const arch = chosenArch ?? archOf(platform)
const [pkg, setPkg] = useState("deb")
const choices = { arch, setArch, pkg, setPkg }
const tabs = useRef(null)
useTabIndicator(tabs, os)
return (
{OSES.map((entry) => (
))}
{/* Every OS's stack shares one grid cell, so the tallest reserves the
height and switching tabs never moves the page. */}