blob: 7289bd2c1081294722652403d749a8f68ea332d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import * as React from 'react';
import ReactSwitch from 'react-switch';
import { State } from '$src/store/types';
import { getTheme } from '../store/app';
import { connect } from './StateProvider';
// workaround https://github.com/vitejs/vite/issues/2139#issuecomment-802981228
// @ts-ignore
const Switch = ReactSwitch.default ? ReactSwitch.default : ReactSwitch;
function SwitchThemed({ checked = false, onChange, theme, name }) {
const offColor = theme === 'dark' ? '#393939' : '#e9e9e9';
return (
<Switch
onChange={onChange}
checked={checked}
uncheckedIcon={false}
checkedIcon={false}
offColor={offColor}
onColor="#047aff"
offHandleColor="#fff"
onHandleColor="#fff"
handleDiameter={24}
height={28}
width={44}
className="rs"
name={name}
/>
);
}
export default connect((s: State) => ({ theme: getTheme(s) }))(SwitchThemed);
|