2023-02-18 12:40:37 +03:00
|
|
|
import type { 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';
|
2022-05-28 11:34:12 +03:00
|
|
|
import { ToggleSwitch } from '../utils/ToggleSwitch';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { Theme } from '../utils/theme';
|
|
|
|
import { changeThemeInMarkup } from '../utils/theme';
|
|
|
|
import type { Settings, UiSettings } from './reducers/settings';
|
2021-12-25 12:49:12 +03:00
|
|
|
import './UserInterfaceSettings.scss';
|
2021-02-16 21:25:23 +03:00
|
|
|
|
|
|
|
interface UserInterfaceProps {
|
|
|
|
settings: Settings;
|
|
|
|
setUiSettings: (settings: UiSettings) => void;
|
|
|
|
}
|
|
|
|
|
2021-12-25 12:49:12 +03:00
|
|
|
export const UserInterfaceSettings: FC<UserInterfaceProps> = ({ settings: { ui }, setUiSettings }) => (
|
2021-03-06 19:30:21 +03:00
|
|
|
<SimpleCard title="User interface" className="h-100">
|
2022-02-14 22:28:28 +03:00
|
|
|
<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
|
|
|
|
2022-02-14 22:28:28 +03:00
|
|
|
setUiSettings({ ...ui, theme });
|
|
|
|
changeThemeInMarkup(theme);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Use dark theme.
|
|
|
|
</ToggleSwitch>
|
2021-02-16 21:25:23 +03:00
|
|
|
</SimpleCard>
|
|
|
|
);
|