import React from 'react';
import PropTypes from 'prop-types';
import { c } from 'ttag';

import Checkbox from '../input/Checkbox';
import Icon from '../icon/Icon';

const label = (key) => {
    const I18N = {
        on: c('Toggle button').t`On`,
        off: c('Toggle button').t`Off`
    };

    return (
        <span className="pm-toggle-label-text">
            <Icon name={key} alt={I18N[key]} className="pm-toggle-label-img" />
        </span>
    );
};

const Toggle = ({ id, checked, onChange }) => {
    return (
        <>
            <Checkbox id={id} checked={checked} className="pm-toggle-checkbox" onChange={onChange} />
            <label htmlFor={id} className="pm-toggle-label">
                {label('on')}
                {label('off')}
            </label>
        </>
    );
};

Toggle.propTypes = {
    id: PropTypes.string.isRequired,
    checked: PropTypes.bool.isRequired,
    onChange: PropTypes.func.isRequired
};

Toggle.defaultProps = {
    id: 'toggle',
    checked: false
};

export default Toggle;

@@ -87,50 +87,8 @@
 ';%0A%0A
-import Checkbox from '../input/Checkbox';%0A
 impo
@@ -434,33 +434,13 @@
  = (
-%7B id, checked, onChange %7D
+props
 ) =%3E
@@ -483,42 +483,40 @@
    %3C
-Checkbox id=%7Bid%7D checked=%7B
+input %7B...props%7D type=%22
 check
-ed%7D
+box%22
  cla
@@ -546,28 +546,8 @@
 box%22
- onChange=%7BonChange%7D
  /%3E%0A
@@ -574,16 +574,22 @@
 tmlFor=%7B
+props.
 id%7D clas

Fix broken toggle - broken adjacent selector