blob: 514581610570db57ec2bc9dc9dddc047e8cc2688 (
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 '~/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';
const onColor = theme === 'dark' ? '#306081' : '#005caf';
return (
<Switch
onChange={onChange}
checked={checked}
uncheckedIcon={false}
checkedIcon={false}
offColor={offColor}
onColor={onColor}
offHandleColor="#fff"
onHandleColor="#fff"
handleDiameter={24}
height={28}
width={44}
className="rs"
name={name}
/>
);
}
export default connect((s: State) => ({ theme: getTheme(s) }))(SwitchThemed);
|