/** Very plain checkbox. */ import * as React from "react" import cx = require("classnames") export interface Props { className?: string labelBefore?: boolean onChange?: (checked: boolean, id: string, e: any) => void label: string title?: string id?: string [propName: string]: any checked?: boolean } /** * On change takes (checked status, id, evt). */ export const Checkbox: React.SFC = (props) => { const { className, labelBefore, onChange, checked, label, ...rest } = props const id: string = props.id || label const title: string = props.title || label const before = (labelBefore) ? : null const after = (!labelBefore) ? : null return (
{before} { if (onChange) onChange(e.target.checked, id, e) }} /> {after}
) } export default Checkbox