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-09-25 09:20:56 +03:00
|
|
|
import { FormGroup } from 'reactstrap';
|
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 }) => (
|
2021-03-06 19:30:21 +03:00
|
|
|
<SimpleCard title="User interface" className="h-100">
|
2021-09-25 09:20:56 +03:00
|
|
|
<FormGroup>
|
|
|
|
<FontAwesomeIcon icon={ui?.theme === 'dark' ? faMoon : faSun} className="user-interface__theme-icon" />
|
|
|
|
<ToggleSwitch
|
|
|
|
checked={ui?.theme === 'dark'}
|
|
|
|
onChange={(useDarkTheme) => {
|
|
|
|
const theme: Theme = useDarkTheme ? 'dark' : 'light';
|
2021-02-16 21:25:23 +03:00
|
|
|
|
2021-09-25 09:20:56 +03:00
|
|
|
setUiSettings({ ...ui, theme });
|
|
|
|
changeThemeInMarkup(theme);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Use dark theme.
|
|
|
|
</ToggleSwitch>
|
|
|
|
</FormGroup>
|
2021-02-16 21:25:23 +03:00
|
|
|
</SimpleCard>
|
|
|
|
);
|