Create toggle component

[MAILPOET-2738]
This commit is contained in:
Pavel Dohnal
2020-03-17 09:33:22 +01:00
committed by Veljko V
parent f9aca4fe57
commit c77a9f3137
4 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import React from 'react';
type Props = {
checked: boolean,
onCheck: (checked: boolean) => void,
name?: string,
};
const Toggle = ({ checked, onCheck, name }: Props) => (
<>
<input
className="mailpoet-toggle mailpoet-toggle-light"
id={`mailpoet-toggle-${name}`}
type="checkbox"
checked={checked}
onChange={(event) => onCheck(event.target.checked)}
key={`toggle-input-${name}`}
/>
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
<label
className="mailpoet-toggle-button"
htmlFor={`mailpoet-toggle-${name}`}
key={`toggle-label-${name}`}
/>
</>
);
export default Toggle;