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

52 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-10-30 14:34:24 +00:00
import { makeStyles } from "@material-ui/core/styles";
2019-06-19 14:40:52 +00:00
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-30 14:34:24 +00:00
const useStyles = makeStyles(
theme => ({
checked: {
"& svg": {
background: theme.palette.primary.main,
color: theme.palette.background.paper
}
2019-06-19 14:40:52 +00:00
},
2019-10-30 14:34:24 +00:00
colorPrimary: {},
root: {
"& svg": {
background: theme.palette.primary.main,
borderRadius: "100%",
height: 20,
width: 20
2019-11-04 13:36:25 +00:00
}
},
track: {
"$colorPrimary$checked + &": {
backgroundColor: theme.palette.background.paper
2019-10-30 14:34:24 +00:00
},
2019-11-04 13:36:25 +00:00
background: theme.palette.background.paper
2019-10-30 14:34:24 +00:00
}
}),
{
name: "ThemeSwitch"
2019-06-19 14:40:52 +00:00
}
2019-10-30 14:34:24 +00:00
);
const ThemeSwitch: React.FC<SwitchProps> = props => {
const classes = useStyles(props);
return (
<Switch
{...props}
classes={classes}
color="primary"
icon={<SunIcon />}
checkedIcon={<MoonIcon />}
/>
);
};
2019-06-19 14:40:52 +00:00
ThemeSwitch.displayName = "ThemeSwitch";
export default ThemeSwitch;