bigbuffet-rw/app/soapbox/features/ui/components/theme-toggle.tsx

27 lines
616 B
TypeScript
Raw Normal View History

2022-05-05 16:12:08 -07:00
import React from 'react';
2022-05-04 06:09:10 -07:00
import { useDispatch } from 'react-redux';
import { changeSetting } from 'soapbox/actions/settings';
import { useSettings } from 'soapbox/hooks';
2022-05-05 16:12:08 -07:00
import ThemeSelector from './theme-selector';
2022-05-04 06:09:10 -07:00
2022-05-05 16:12:08 -07:00
/** Stateful theme selector. */
const ThemeToggle: React.FC = () => {
2022-05-04 06:09:10 -07:00
const dispatch = useDispatch();
const themeMode = useSettings().get('themeMode');
2022-05-05 16:12:08 -07:00
const handleChange = (themeMode: string) => {
dispatch(changeSetting(['themeMode'], themeMode));
2022-05-04 06:09:10 -07:00
};
return (
2022-05-05 16:12:08 -07:00
<ThemeSelector
value={themeMode}
onChange={handleChange}
/>
2022-05-04 06:09:10 -07:00
);
};
export default ThemeToggle;