Commit a6b371b2 by Sarah Fischmann

checkbox is setup

parent 17417b0d
import React from 'react';
import { Input } from 'reactstrap';
import PropTypes from 'prop-types';
import asInput, { inputProps } from './utils/asInput';
class CheckBox extends React.Component {
constructor(props) {
super(props);
this.state = {
pressed: "false"
};
}
handleClick() {
if (this.state.pressed == "true") {
this.setState({
pressed: "false",
}) } else {
this.setState({
pressed: "true"
});
}
}
render() {
const props = {...this.props};
return (
<form>
<label class="form-check-label">
<input
type="checkbox"
class="form-check-input"
name={props.name}
aria-descrivedby={props.describedby}
aria-checked={this.state.pressed}
tabindex="0"
onClick={() => this.handleClick()}
/>
{props.checkLabel}
</label>
</form>
);
}
}
CheckBox.propTypes = {
...inputProps,
checkLabel : PropTypes.string.isRequired
};
export default CheckBox;
...@@ -4,6 +4,7 @@ import { storiesOf, linkTo } from '@kadira/storybook'; ...@@ -4,6 +4,7 @@ import { storiesOf, linkTo } from '@kadira/storybook';
import TextInput from '../src/TextInput'; import TextInput from '../src/TextInput';
import SelectInput from '../src/SelectInput'; import SelectInput from '../src/SelectInput';
import CheckBox from '../src/CheckBox'
import Welcome from './Welcome'; import Welcome from './Welcome';
storiesOf('Welcome', module) storiesOf('Welcome', module)
...@@ -124,3 +125,13 @@ storiesOf('SelectInput', module) ...@@ -124,3 +125,13 @@ storiesOf('SelectInput', module)
}} }}
/> />
)); ));
storiesOf('CheckBox', module)
.add('basic usage', () => (
<CheckBox
name="checkbox"
label="CheckBox"
describedBy="checkbox"
checkLabel="check me out"
/>
));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment