Add YesNo component

[MAILPOET-2773]
This commit is contained in:
Ján Mikláš
2020-05-19 13:54:34 +02:00
committed by Veljko V
parent eca9817b9e
commit d89969417c
2 changed files with 44 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ const Toggle = ({
onCheck,
...attributes
}: Props) => (
<label
<div
className={
classnames({
'mailpoet-form-toggle': true,
@@ -25,7 +25,7 @@ const Toggle = ({
{...attributes}
/>
<span className="mailpoet-form-toggle-control" />
</label>
</div>
);
export default Toggle;

View File

@@ -0,0 +1,42 @@
import React, { InputHTMLAttributes } from 'react';
import classnames from 'classnames';
type Props = InputHTMLAttributes<HTMLInputElement> & {
name: string,
onCheck: (isChecked: boolean) => void,
showError?: boolean,
};
const YesNo = ({
onCheck,
showError,
...attributes
}: Props) => (
<div
className={
classnames({
'mailpoet-form-yesno': true,
'mailpoet-form-yesno-error': showError,
})
}
>
<label>
<input
type="radio"
onChange={(e) => onCheck(true)}
{...attributes}
/>
<span className="mailpoet-form-yesno-control mailpoet-form-yesno-yes" />
</label>
<label>
<input
type="radio"
onChange={(e) => onCheck(false)}
{...attributes}
/>
<span className="mailpoet-form-yesno-control mailpoet-form-yesno-no" />
</label>
</div>
);
export default YesNo;