saleor-dashboard/src/components/AppLayout/ThemeSwitch.tsx

44 lines
1,011 B
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import { Theme, withStyles } from "@material-ui/core/styles";
import Switch, { SwitchProps } from "@material-ui/core/Switch";
2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
import MoonIcon from "../../icons/Moon";
import SunIcon from "../../icons/Sun";
2019-10-28 16:16:49 +00:00
const switchStyles = theme => ({
2019-06-19 14:40:52 +00:00
bar: {
"$colorPrimary$checked + &": {
backgroundColor: theme.palette.background.paper
},
background: theme.palette.background.paper
},
checked: {
"& svg": {
background: theme.palette.primary.main,
color: theme.palette.background.paper
}
},
colorPrimary: {},
root: {
"& svg": {
background: theme.palette.primary.main,
borderRadius: "100%",
height: 20,
width: 20
},
width: 58
}
});
const ThemeSwitch = withStyles(switchStyles, {
name: "ThemeSwitch"
})((props: SwitchProps) => (
<Switch
{...props}
color="primary"
icon={<SunIcon />}
checkedIcon={<MoonIcon />}
/>
));
ThemeSwitch.displayName = "ThemeSwitch";
export default ThemeSwitch;