2021-02-16 21:25:23 +03:00
|
|
|
import { FC } from 'react';
|
2021-02-19 20:55:03 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faSun, faMoon } from '@fortawesome/free-solid-svg-icons';
|
2021-02-16 21:25:23 +03:00
|
|
|
import { SimpleCard } from '../utils/SimpleCard';
|
|
|
|
import ToggleSwitch from '../utils/ToggleSwitch';
|
|
|
|
import { changeThemeInMarkup, Theme } from '../utils/theme';
|
|
|
|
import { Settings, UiSettings } from './reducers/settings';
|
2021-02-19 20:55:03 +03:00
|
|
|
import './UserInterface.scss';
|
2021-02-16 21:25:23 +03:00
|
|
|
|
|
|
|
interface UserInterfaceProps {
|
|
|
|
settings: Settings;
|
|
|
|
setUiSettings: (settings: UiSettings) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const UserInterface: FC<UserInterfaceProps> = ({ settings: { ui }, setUiSettings }) => (
|
|
|
|
<SimpleCard title="User interface">
|
2021-02-19 20:55:03 +03:00
|
|
|
<FontAwesomeIcon icon={ui?.theme === 'dark' ? faMoon : faSun} className="user-interface__theme-icon" />
|
2021-02-16 21:25:23 +03:00
|
|
|
<ToggleSwitch
|
|
|
|
checked={ui?.theme === 'dark'}
|
|
|
|
onChange={(useDarkTheme) => {
|
|
|
|
const theme: Theme = useDarkTheme ? 'dark' : 'light';
|
|
|
|
|
|
|
|
setUiSettings({ theme });
|
|
|
|
changeThemeInMarkup(theme);
|
|
|
|
}}
|
|
|
|
>
|
2021-02-16 21:31:16 +03:00
|
|
|
Use dark theme.
|
2021-02-16 21:25:23 +03:00
|
|
|
</ToggleSwitch>
|
|
|
|
</SimpleCard>
|
|
|
|
);
|