import React, { useCallback, useMemo } from 'react' import { Button, useTheme, Spacer } from 'components' import useConfigs from 'lib/states/use-config' import MoonIcon from './icons/moon' import SunIcon from './icons/sun' import GithubIcon from './icons/github' const Controls: React.FC<{}> = React.memo(({ }) => { const theme = useTheme() const config = useConfigs() const isDark = useMemo(() => theme.type === 'dark', [theme.type]) const switchThemes = useCallback(() => { const isDark = theme.type === 'dark' config.onChange && config.onChange(!isDark) }, [theme.type]) const redirectGithub = () => { if (typeof window !== 'undefined') { window.open('https://github.com/zeit-ui/react') } } return (