import { __ } from '@wordpress/i18n';

export default function Toggle({ label, checked, onChange, help }) {
    return (
        <div className="shcb-field-group shcb-field-toggle">
            <label className="shcb-toggle-label">
                <div className="shcb-toggle-text">
                    <span className="shcb-field-label">
                        {label}
                    </span>
                    {help && <p className="shcb-field-help">{help}</p>}
                </div>
                <div className="shcb-toggle-control-wrap">
                    <input
                        type="checkbox"
                        checked={checked}
                        onChange={(e) => onChange(e.target.checked)}
                    />
                    <span className="shcb-toggle-slider"></span>
                </div>
            </label>
        </div>
    );
}
