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-08-05 12:14:03 +03:00
|
|
|
import type { Theme } from '@shlinkio/shlink-frontend-kit';
|
|
|
|
import { changeThemeInMarkup, SimpleCard, ToggleSwitch } from '@shlinkio/shlink-frontend-kit';
|
2023-08-04 23:59:33 +03:00
|
|
|
import type { Settings, UiSettings } from '@shlinkio/shlink-web-component';
|
2023-02-18 13:11:01 +03:00
|
|
|
import type { FC } from 'react';
|
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>
|
|
|
|
);
|