This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/dashboard-v2/src/components/Switch/Switch.js

38 lines
769 B
JavaScript
Raw Normal View History

2022-02-18 08:20:47 +00:00
import PropTypes from "prop-types";
import "./Switch.css";
/**
* Primary UI component for user interaction
*/
export const Switch = ({ isOn, handleToggle }) => {
return (
<>
<input
checked={isOn}
onChange={handleToggle}
className="react-switch-checkbox"
id={`react-switch-new`}
type="checkbox"
/>
2022-02-18 08:20:47 +00:00
<label className={"react-switch-label"} htmlFor={`react-switch-new`}>
<span className={`react-switch-button ${isOn ? "bg-primary" : "bg-palette-200"}`} />
</label>
</>
2022-02-18 08:20:47 +00:00
);
};
Switch.propTypes = {
/**
* Switch's current value
*/
isOn: PropTypes.bool,
/**
* Function to execute on change
*/
handleToggle: PropTypes.func,
2022-02-18 08:20:47 +00:00
};
Switch.defaultProps = {
isOn: false,
2022-02-18 08:20:47 +00:00
};