import { highFpsAtom, siAtom } from '@/atoms'; import { Switch } from '@/components/switch'; import { useAnimationFrame } from '@/hooks/use-animation-frame'; import { useSetTheme } from '@/hooks/use-set-theme'; import { useQuery } from '@tanstack/react-query'; import { useAtom } from 'jotai'; import { useState } from 'react'; import './static.css'; const formatUptime = (value: number) => { const seconds = String(Math.floor(value % 60)).padStart(2, '0'); const minutes = String(Math.floor((value / 60) % 60)).padStart(2, '0'); const hours = String(Math.floor((value / (60 * 60)) % 24)).padStart(2, '0'); const days = Math.floor((value / (60 * 60 * 24)) % 365); const years = Math.floor(value / (60 * 60 * 24 * 365)); let formatted = ''; if (years >= 1) { formatted += `${years}y `; } if (days >= 1 || years >= 1) { formatted += `${days}d `; } return `${formatted}${hours}:${minutes}:${seconds}`; }; const Uptime = ({ boot_time }: Pick) => { const [uptime, setUptime] = useState(formatUptime(Date.now() / 1000 - boot_time)); useAnimationFrame(() => setUptime(formatUptime(Date.now() / 1000 - boot_time)), 1); return ( <> Uptime

{uptime}

); }; export const Static = () => { const { data: staticData } = useQuery({ queryKey: ['static'] }); const [dark, setDark] = useState(window.matchMedia('(prefers-color-scheme: dark)').matches); const [highFps, setHighFps] = useAtom(highFpsAtom); const [isSi, setIsSi] = useAtom(siAtom); useSetTheme(dark); return ( staticData && (

{staticData.host_name}

OS

{staticData.name} {staticData.os_version}

Kernel

{staticData.kernel_version}

{staticData.boot_time && }
setDark(target.checked)} /> setHighFps(target.checked)} /> setIsSi(target.checked)} />
) ); };