bigbuffet-rw/app/soapbox/features/ui/components/theme-toggle.tsx
2022-05-05 18:12:08 -05:00

26 lines
616 B
TypeScript

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