mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-02 05:36:38 +00:00
Added components and logic to dynamically change theme
This commit is contained in:
committed by
Alejandro Celaya
parent
f313a39b81
commit
9dbf790cc8
26
src/settings/UserInterface.tsx
Normal file
26
src/settings/UserInterface.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { FC } from 'react';
|
||||
import { SimpleCard } from '../utils/SimpleCard';
|
||||
import ToggleSwitch from '../utils/ToggleSwitch';
|
||||
import { changeThemeInMarkup, Theme } from '../utils/theme';
|
||||
import { Settings, UiSettings } from './reducers/settings';
|
||||
|
||||
interface UserInterfaceProps {
|
||||
settings: Settings;
|
||||
setUiSettings: (settings: UiSettings) => void;
|
||||
}
|
||||
|
||||
export const UserInterface: FC<UserInterfaceProps> = ({ settings: { ui }, setUiSettings }) => (
|
||||
<SimpleCard title="User interface">
|
||||
<ToggleSwitch
|
||||
checked={ui?.theme === 'dark'}
|
||||
onChange={(useDarkTheme) => {
|
||||
const theme: Theme = useDarkTheme ? 'dark' : 'light';
|
||||
|
||||
setUiSettings({ theme });
|
||||
changeThemeInMarkup(theme);
|
||||
}}
|
||||
>
|
||||
Use dark theme
|
||||
</ToggleSwitch>
|
||||
</SimpleCard>
|
||||
);
|
||||
Reference in New Issue
Block a user