import React, { PureComponent } from 'react'; import _ from 'lodash'; export interface Props { label: string; checked: boolean; className?: string; labelClass?: string; switchClass?: string; transparent?: boolean; onChange: (event?: React.SyntheticEvent) => void; } export interface State { id: any; } export class Switch extends PureComponent { state = { id: _.uniqueId('check-'), }; internalOnChange = (event: React.FormEvent) => { event.stopPropagation(); this.props.onChange(event); }; render() { const { labelClass = '', switchClass = '', label, checked, transparent, className } = this.props; const labelId = this.state.id; const labelClassName = `gf-form-label ${labelClass} ${transparent ? 'gf-form-label--transparent' : ''} pointer`; const switchClassName = `gf-form-switch ${switchClass} ${transparent ? 'gf-form-switch--transparent' : ''}`; return (
); } }