import React, { useMemo } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Icon, Select } from 'soapbox/components/ui'; const messages = defineMessages({ light: { id: 'theme_toggle.light', defaultMessage: 'Light' }, dark: { id: 'theme_toggle.dark', defaultMessage: 'Dark' }, system: { id: 'theme_toggle.system', defaultMessage: 'System' }, }); interface IThemeSelector { value: string, onChange: (value: string) => void, } /** Pure theme selector. */ const ThemeSelector: React.FC = ({ value, onChange }) => { const intl = useIntl(); const themeIconSrc = useMemo(() => { switch (value) { case 'system': return require('@tabler/icons/device-desktop.svg'); case 'light': return require('@tabler/icons/sun.svg'); case 'dark': return require('@tabler/icons/moon.svg'); default: return null; } }, [value]); const handleChange: React.ChangeEventHandler = e => { onChange(e.target.value); }; return ( ); }; export default ThemeSelector;