2023-02-18 13:11:01 +03:00
|
|
|
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons';
|
2021-02-19 20:55:03 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2023-02-18 13:11:01 +03:00
|
|
|
import type { FC } from 'react';
|
2023-07-31 22:36:44 +03:00
|
|
|
import { SimpleCard, ToggleSwitch } from '../../shlink-frontend-kit/src';
|
2023-08-04 09:56:06 +03:00
|
|
|
import type { Settings, UiSettings } from '../../shlink-web-component/src';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { Theme } from '../utils/theme';
|
|
|
|
import { changeThemeInMarkup } from '../utils/theme';
|
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>
|
|
|
|
);
|