diff --git a/src/renderer/components/switch/form-switcher.tsx b/src/renderer/components/switch/form-switcher.tsx
index 8f2a8a231c..4d256ddca8 100644
--- a/src/renderer/components/switch/form-switcher.tsx
+++ b/src/renderer/components/switch/form-switcher.tsx
@@ -7,6 +7,7 @@ import React from "react";
import type { FormControlLabelProps } from "@material-ui/core/FormControlLabel";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import { makeStyles } from "@material-ui/styles";
+import { Switch } from "./switch";
const useStyles = makeStyles({
root: {
@@ -23,15 +24,12 @@ const useStyles = makeStyles({
/**
* @deprecated Use instead from "../switch.tsx".
*/
-export function FormSwitch(props: FormControlLabelProps) {
+export function FormSwitch(props: FormControlLabelProps & { children?: React.ReactNode }) {
const classes = useStyles();
- return (
-
- );
+ const ClonedElement = React.cloneElement(props.control, {
+ children: props.label,
+ });
+
+ return ClonedElement;
}
diff --git a/src/renderer/components/switch/switcher.tsx b/src/renderer/components/switch/switcher.tsx
index 21b2cddb22..39f3b7eb13 100644
--- a/src/renderer/components/switch/switcher.tsx
+++ b/src/renderer/components/switch/switcher.tsx
@@ -4,10 +4,8 @@
*/
import React from "react";
-import type { Theme } from "@material-ui/core/styles";
-import { createStyles, withStyles } from "@material-ui/core/styles";
import type { SwitchClassKey, SwitchProps } from "@material-ui/core/Switch";
-import Switch from "@material-ui/core/Switch";
+import { Switch } from "./switch";
interface Styles extends Partial> {
focusVisible?: string;
@@ -15,64 +13,21 @@ interface Styles extends Partial> {
export interface SwitcherProps extends SwitchProps {
classes: Styles;
+ children?: React.ReactNode;
}
/**
* @deprecated Use instead from "../switch.tsx".
*/
-export const Switcher = withStyles((theme: Theme) =>
- createStyles({
- root: {
- width: 40,
- height: 24,
- padding: 0,
- margin: "0 0 0 8px",
- },
- switchBase: {
- padding: 1,
- paddingLeft: 4,
- "&$checked": {
- transform: "translateX(14px)",
- color: "white",
- "& + $track": {
- backgroundColor: "#52d869",
- opacity: 1,
- border: "none",
- },
- },
- "&$focusVisible $thumb": {
- color: "#52d869",
- border: "6px solid #fff",
- },
- },
- thumb: {
- width: 18,
- height: 18,
- marginTop: 2,
- boxShadow: "none",
- },
- track: {
- borderRadius: 26 / 2,
- backgroundColor: "#72767b",
- opacity: 1,
- transition: theme.transitions.create(["background-color", "border"]),
- },
- checked: {},
- focusVisible: {},
- }),
-)(({ classes, ...props }: SwitcherProps) => {
+export const Switcher = () => (({ disabled, checked, onChange, name, children }: SwitcherProps) => {
return (
+ disabled={disabled}
+ checked={checked}
+ name={name}
+ onChange={(checked, event) => onChange?.(event, checked)}
+ >
+ {children}
+
);
});