diff --git a/src/utils/BooleanControl.js b/src/utils/BooleanControl.js
new file mode 100644
index 00000000..3daa7d9f
--- /dev/null
+++ b/src/utils/BooleanControl.js
@@ -0,0 +1,36 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import classNames from 'classnames';
+import { v4 as uuid } from 'uuid';
+
+export const basePropTypes = {
+ checked: PropTypes.bool.isRequired,
+ onChange: PropTypes.func.isRequired,
+ children: PropTypes.oneOfType([ PropTypes.string, PropTypes.node ]),
+ className: PropTypes.string,
+};
+
+const propTypes = {
+ ...basePropTypes,
+ type: PropTypes.oneOf([ 'switch', 'checkbox' ]).isRequired,
+};
+
+const BooleanControl = ({ checked, onChange, className, children, type }) => {
+ const id = uuid();
+ const onChecked = (e) => onChange(e.target.checked, e);
+ const typeClasses = {
+ 'custom-switch': type === 'switch',
+ 'custom-checkbox': type === 'checkbox',
+ };
+
+ return (
+
+
+
+
+ );
+};
+
+BooleanControl.propTypes = propTypes;
+
+export default BooleanControl;
diff --git a/src/utils/Checkbox.js b/src/utils/Checkbox.js
index 0c39e5e4..b253bdfc 100644
--- a/src/utils/Checkbox.js
+++ b/src/utils/Checkbox.js
@@ -1,27 +1,8 @@
import React from 'react';
-import PropTypes from 'prop-types';
-import classNames from 'classnames';
-import { v4 as uuid } from 'uuid';
+import BooleanControl, { basePropTypes } from './BooleanControl';
-const propTypes = {
- checked: PropTypes.bool.isRequired,
- onChange: PropTypes.func.isRequired,
- children: PropTypes.oneOfType([ PropTypes.string, PropTypes.node ]),
- className: PropTypes.string,
-};
+const Checkbox = (props) => ;
-const Checkbox = ({ checked, onChange, className, children }) => {
- const id = uuid();
- const onChecked = (e) => onChange(e.target.checked, e);
-
- return (
-
-
-
-
- );
-};
-
-Checkbox.propTypes = propTypes;
+Checkbox.propTypes = basePropTypes;
export default Checkbox;
diff --git a/src/utils/ToggleSwitch.js b/src/utils/ToggleSwitch.js
index b64407e1..8f45e96f 100644
--- a/src/utils/ToggleSwitch.js
+++ b/src/utils/ToggleSwitch.js
@@ -1,27 +1,8 @@
import React from 'react';
-import PropTypes from 'prop-types';
-import classNames from 'classnames';
-import { v4 as uuid } from 'uuid';
+import BooleanControl, { basePropTypes } from './BooleanControl';
-const propTypes = {
- checked: PropTypes.bool.isRequired,
- onChange: PropTypes.func.isRequired,
- children: PropTypes.oneOfType([ PropTypes.string, PropTypes.node ]),
- className: PropTypes.string,
-};
+const ToggleSwitch = (props) => ;
-const ToggleSwitch = ({ checked, onChange, className, children }) => {
- const id = uuid();
- const onChecked = (e) => onChange(e.target.checked, e);
-
- return (
-
-
-
-
- );
-};
-
-ToggleSwitch.propTypes = propTypes;
+ToggleSwitch.propTypes = basePropTypes;
export default ToggleSwitch;