From b93a7573d482f4a5b077aae020c4565f032f23a5 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Tue, 15 Oct 2019 20:49:00 -0500 Subject: [PATCH] feat(checkboxes): add ability to click on label to select #62 --- src/components/Checkbox/Checkbox.tsx | 17 ++++++++++++----- stories/checkbox.stories.tsx | 12 ++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx index 69e6bf2b..628ea917 100644 --- a/src/components/Checkbox/Checkbox.tsx +++ b/src/components/Checkbox/Checkbox.tsx @@ -2,15 +2,17 @@ import React, { Component } from 'react' import FormCheck from 'react-bootstrap/FormCheck' interface Props { + /** The id for the checkbox */ + id?: string /** The label to render next to the checkbox */ label: string /* Determines the side of the checkbox to render the label on. By default right */ labelSide?: 'right' | 'left' - /* Gives the checkbox a name */ + /** Gives the checkbox a name */ name?: string - /* Determines if the checkbox should be disabled or not. By default false */ + /** Determines if the checkbox should be disabled or not. By default false */ disabled?: boolean - /* Determines if the checkbox should render inline or not. By default false. */ + /** Determines if the checkbox should render inline or not. By default false. */ inline?: boolean /** The onChange listener */ onChange?: (event: React.ChangeEvent) => void @@ -26,13 +28,18 @@ class Checkbox extends Component { return ( - {labelSide === 'left' && {this.props.label}} + {labelSide === 'left' && ( + {this.props.label} + )} - {labelSide === 'right' && {this.props.label}} + {labelSide === 'right' && ( + {this.props.label} + )} ) } diff --git a/stories/checkbox.stories.tsx b/stories/checkbox.stories.tsx index 8a6d5638..c206de7b 100644 --- a/stories/checkbox.stories.tsx +++ b/stories/checkbox.stories.tsx @@ -12,13 +12,13 @@ storiesOf('Checkbox', module) .add('Checkbox', () => (

Vertical

- - - + + +

Horizontal

- - - + + +
))