Settings.js 785 B

12345678910111213141516171819202122232425
  1. import './Settings.css';
  2. import Select from 'react-select';
  3. const THEMES = [
  4. {value: 'light', label: 'Light'},
  5. {value: 'dark', label: 'Dark'}
  6. ];
  7. const LAYOUTS = [
  8. {value: 'bottom', label: 'Bottom controls'},
  9. {value: 'left', label: 'Left controls'},
  10. {value: 'right', label: 'Right controls'},
  11. ];
  12. export default function Settings({state, dispatch}) {
  13. const theme = THEMES.find(e => e.value === state.theme);
  14. const layout = LAYOUTS.find(e => e.value === state.layout);
  15. return (
  16. <div className="Settings">
  17. <Select defaultValue={theme} options={THEMES} onChange={(e)=>dispatch({type: 'THEME_SET', payload: e.value})} />
  18. <Select defaultValue={layout} options={LAYOUTS} onChange={(e)=>dispatch({type: 'LAYOUT_SET', payload: e.value})} />
  19. </div>
  20. );
  21. }