Commit 3dae3894 by Ari Rizzitano

eslint ;(

parent ccbcd94d
...@@ -11,7 +11,7 @@ class SelectInput extends React.Component { ...@@ -11,7 +11,7 @@ class SelectInput extends React.Component {
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.state = { this.state = {
uuid: newId('textInput'), uuid: newId('textInput'),
value: this.props.value value: this.props.value,
}; };
} }
...@@ -26,14 +26,14 @@ class SelectInput extends React.Component { ...@@ -26,14 +26,14 @@ class SelectInput extends React.Component {
<span className="input-description" id={descriptionId}> <span className="input-description" id={descriptionId}>
{this.props.description} {this.props.description}
</span> </span>
) ),
} };
} }
return descriptionElements; return descriptionElements;
} }
handleChange(event) { handleChange(event) {
this.setState({value: event.target.value}); this.setState({ value: event.target.value });
this.props.onChange(event.target.value, this.props.name); this.props.onChange(event.target.value, this.props.name);
} }
...@@ -53,9 +53,7 @@ class SelectInput extends React.Component { ...@@ -53,9 +53,7 @@ class SelectInput extends React.Component {
return this.props.options.map((option, i) => { return this.props.options.map((option, i) => {
let section; let section;
if (option.options) { if (option.options) {
const groupOpts = option.options.map((opt, j) => { const groupOpts = option.options.map((opt, j) => this.getOption(opt, j));
return this.getOption(opt, j);
});
section = ( section = (
<optgroup label={option.label} key={`group-${i}`}> <optgroup label={option.label} key={`group-${i}`}>
{groupOpts} {groupOpts}
...@@ -70,7 +68,7 @@ class SelectInput extends React.Component { ...@@ -70,7 +68,7 @@ class SelectInput extends React.Component {
render() { render() {
const { descriptionId, description } = this.getDescriptionElements(), const { descriptionId, description } = this.getDescriptionElements(),
options = this.getOptions(); options = this.getOptions();
return ( return (
<div className={this.props.className}> <div className={this.props.className}>
...@@ -96,19 +94,19 @@ SelectInput.propTypes = { ...@@ -96,19 +94,19 @@ SelectInput.propTypes = {
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([ value: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.number PropTypes.number,
]), ]),
description: PropTypes.oneOfType([ description: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.element PropTypes.element,
]), ]),
options: PropTypes.array.isRequired, options: PropTypes.array.isRequired,
disabled: PropTypes.bool, disabled: PropTypes.bool,
onChange: PropTypes.func onChange: PropTypes.func,
}; };
SelectInput.defaultProps = { SelectInput.defaultProps = {
onChange: () => {} onChange: () => {},
}; };
export default SelectInput; export default SelectInput;
...@@ -12,14 +12,14 @@ class TabInterface extends React.Component { ...@@ -12,14 +12,14 @@ class TabInterface extends React.Component {
this.toggle = this.toggle.bind(this); this.toggle = this.toggle.bind(this);
this.state = { this.state = {
activeTab: 0, activeTab: 0,
uuid: newId('tabInterface') uuid: newId('tabInterface'),
}; };
} }
toggle(tab) { toggle(tab) {
if (this.state.activeTab !== tab) { if (this.state.activeTab !== tab) {
this.setState({ this.setState({
activeTab: tab activeTab: tab,
}); });
} }
} }
...@@ -77,7 +77,7 @@ class TabInterface extends React.Component { ...@@ -77,7 +77,7 @@ class TabInterface extends React.Component {
render() { render() {
const labels = this.buildLabels(), const labels = this.buildLabels(),
panels = this.buildPanels(); panels = this.buildPanels();
return ( return (
<div className={this.props.className}> <div className={this.props.className}>
...@@ -95,7 +95,7 @@ class TabInterface extends React.Component { ...@@ -95,7 +95,7 @@ class TabInterface extends React.Component {
// TODO: custom validator that ensures tabLabels and panels are the same length // TODO: custom validator that ensures tabLabels and panels are the same length
TabInterface.propTypes = { TabInterface.propTypes = {
tabLabels: PropTypes.array.isRequired, tabLabels: PropTypes.array.isRequired,
panels: PropTypes.array.isRequired panels: PropTypes.array.isRequired,
}; };
export default TabInterface; export default TabInterface;
...@@ -3,7 +3,7 @@ import { Input } from 'reactstrap'; ...@@ -3,7 +3,7 @@ import { Input } from 'reactstrap';
import asInput from './utils/asInput'; import asInput from './utils/asInput';
function TextField (props) { function TextField(props) {
return ( return (
<Input <Input
id={props.id} id={props.id}
...@@ -25,7 +25,7 @@ const TextInput = asInput(TextField); ...@@ -25,7 +25,7 @@ const TextInput = asInput(TextField);
TextInput.defaultProps = { TextInput.defaultProps = {
onChange: () => {}, onChange: () => {},
value: '' value: '',
}; };
export default TextInput; export default TextInput;
...@@ -5,5 +5,5 @@ import TextInput from './TextInput'; ...@@ -5,5 +5,5 @@ import TextInput from './TextInput';
export { export {
SelectInput, SelectInput,
TabInterface, TabInterface,
TextInput TextInput,
}; };
...@@ -4,11 +4,9 @@ import { Label, FormGroup, FormFeedback, FormText } from 'reactstrap'; ...@@ -4,11 +4,9 @@ import { Label, FormGroup, FormFeedback, FormText } from 'reactstrap';
import newId from './newId'; import newId from './newId';
const getDisplayName = WrappedComponent => { const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'Component';
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
};
const asInput = WrappedComponent => { const asInput = (WrappedComponent) => {
class NewComponent extends React.Component { class NewComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -17,7 +15,7 @@ const asInput = WrappedComponent => { ...@@ -17,7 +15,7 @@ const asInput = WrappedComponent => {
const id = newId('textInput'); const id = newId('textInput');
this.state = { this.state = {
id: id, id,
value: this.props.value, value: this.props.value,
isValid: true, isValid: true,
describedBy: [], describedBy: [],
...@@ -27,7 +25,7 @@ const asInput = WrappedComponent => { ...@@ -27,7 +25,7 @@ const asInput = WrappedComponent => {
} }
handleChange(event) { handleChange(event) {
this.setState({value: event.target.value}); this.setState({ value: event.target.value });
this.props.onChange(event.target.value, this.props.name); this.props.onChange(event.target.value, this.props.name);
} }
...@@ -40,9 +38,9 @@ const asInput = WrappedComponent => { ...@@ -40,9 +38,9 @@ const asInput = WrappedComponent => {
getDescriptions() { getDescriptions() {
// possible future work: multiple feedback msgs? // possible future work: multiple feedback msgs?
const errorId = `error-${this.state.id}`, const errorId = `error-${this.state.id}`,
descriptionId = `description-${this.state.id}`; descriptionId = `description-${this.state.id}`;
let desc = {}; const desc = {};
if (!this.state.isValid) { if (!this.state.isValid) {
desc.error = ( desc.error = (
...@@ -93,11 +91,11 @@ const asInput = WrappedComponent => { ...@@ -93,11 +91,11 @@ const asInput = WrappedComponent => {
value: PropTypes.string, value: PropTypes.string,
description: PropTypes.oneOfType([ description: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.element PropTypes.element,
]), ]),
disabled: PropTypes.bool, disabled: PropTypes.bool,
required: PropTypes.bool, required: PropTypes.bool,
onChange: PropTypes.func onChange: PropTypes.func,
}; };
return NewComponent; return NewComponent;
......
...@@ -22,8 +22,8 @@ const styles = { ...@@ -22,8 +22,8 @@ const styles = {
code: { code: {
fontSize: 15, fontSize: 15,
fontWeight: 600, fontWeight: 600,
padding: "2px 5px", padding: '2px 5px',
border: "1px solid #eae9e9", border: '1px solid #eae9e9',
borderRadius: 4, borderRadius: 4,
backgroundColor: '#f3f2f2', backgroundColor: '#f3f2f2',
color: '#3a3a3a', color: '#3a3a3a',
...@@ -31,13 +31,13 @@ const styles = { ...@@ -31,13 +31,13 @@ const styles = {
note: { note: {
opacity: 0.5, opacity: 0.5,
} },
}; };
export default class Welcome extends React.Component { export default class Welcome extends React.Component {
showApp(e) { showApp(e) {
e.preventDefault(); e.preventDefault();
if(this.props.showApp) this.props.showApp(); if (this.props.showApp) this.props.showApp();
} }
render() { render() {
...@@ -49,9 +49,9 @@ export default class Welcome extends React.Component { ...@@ -49,9 +49,9 @@ export default class Welcome extends React.Component {
</p> </p>
<p> <p>
We've added some basic stories inside the <code style={styles.code}>src/stories</code> directory. We've added some basic stories inside the <code style={styles.code}>src/stories</code> directory.
<br/> <br />
A story is a single state of one or more UI components. You can have as many stories as you want. A story is a single state of one or more UI components. You can have as many stories as you want.
<br/> <br />
(Basically a story is like a visual test case.) (Basically a story is like a visual test case.)
</p> </p>
<p> <p>
...@@ -67,12 +67,12 @@ export default class Welcome extends React.Component { ...@@ -67,12 +67,12 @@ export default class Welcome extends React.Component {
</p> </p>
<p> <p>
This is just one thing you can do with Storybook. This is just one thing you can do with Storybook.
<br/> <br />
Have a look at the <a style={styles.link} href="https://github.com/kadirahq/react-storybook" target="_blank">React Storybook</a> repo for more information. Have a look at the <a style={styles.link} href="https://github.com/kadirahq/react-storybook" target="_blank">React Storybook</a> repo for more information.
</p> </p>
<p style={styles.note}> <p style={styles.note}>
<b>NOTE:</b> <b>NOTE:</b>
<br/> <br />
Have a look at the <code style={styles.code}>.storybook/webpack.config.js</code> to add webpack Have a look at the <code style={styles.code}>.storybook/webpack.config.js</code> to add webpack
loaders and plugins you are using in this project. loaders and plugins you are using in this project.
</p> </p>
......
...@@ -7,7 +7,7 @@ import Welcome from './Welcome'; ...@@ -7,7 +7,7 @@ import Welcome from './Welcome';
storiesOf('Welcome', module) storiesOf('Welcome', module)
.add('to Storybook', () => ( .add('to Storybook', () => (
<Welcome showApp={linkTo('Button')}/> <Welcome showApp={linkTo('Button')} />
)); ));
storiesOf('TextInput', module) storiesOf('TextInput', module)
...@@ -28,8 +28,8 @@ storiesOf('TextInput', module) ...@@ -28,8 +28,8 @@ storiesOf('TextInput', module)
if (value.length < 3) { if (value.length < 3) {
feedback = { feedback = {
isValid: false, isValid: false,
validationMessage: 'Username must be at least 3 characters in length.' validationMessage: 'Username must be at least 3 characters in length.',
} };
} }
return feedback; return feedback;
}} }}
...@@ -46,7 +46,7 @@ storiesOf('SelectInput', module) ...@@ -46,7 +46,7 @@ storiesOf('SelectInput', module)
'apple', 'apple',
'orange', 'orange',
'strawberry', 'strawberry',
'banana' 'banana',
]} ]}
/> />
)) ))
...@@ -56,12 +56,12 @@ storiesOf('SelectInput', module) ...@@ -56,12 +56,12 @@ storiesOf('SelectInput', module)
label="New England States" label="New England States"
value="RI" value="RI"
options={[ options={[
{label: 'Connecticut', value: 'CN'}, { label: 'Connecticut', value: 'CN' },
{label: 'Maine', value: 'ME'}, { label: 'Maine', value: 'ME' },
{label: 'Massachusetts', value: 'MA'}, { label: 'Massachusetts', value: 'MA' },
{label: 'New Hampshire', value: 'NH'}, { label: 'New Hampshire', value: 'NH' },
{label: 'Rhode Island', value: 'RI'}, { label: 'Rhode Island', value: 'RI' },
{label: 'Vermont', value: 'VT'}, { label: 'Vermont', value: 'VT' },
]} ]}
/> />
)) ))
...@@ -74,25 +74,25 @@ storiesOf('SelectInput', module) ...@@ -74,25 +74,25 @@ storiesOf('SelectInput', module)
{ {
label: 'New England States', label: 'New England States',
options: [ options: [
{label: 'Connecticut', value: 'CN'}, { label: 'Connecticut', value: 'CN' },
{label: 'Maine', value: 'ME'}, { label: 'Maine', value: 'ME' },
{label: 'Massachusetts', value: 'MA'}, { label: 'Massachusetts', value: 'MA' },
{label: 'New Hampshire', value: 'NH'}, { label: 'New Hampshire', value: 'NH' },
{label: 'Rhode Island', value: 'RI'}, { label: 'Rhode Island', value: 'RI' },
{label: 'Vermont', value: 'VT'}, { label: 'Vermont', value: 'VT' },
], ],
}, },
{ {
label: 'Mid Atlantic States', label: 'Mid Atlantic States',
options: [ options: [
{label: 'Delaware', value: 'DE'}, { label: 'Delaware', value: 'DE' },
{label: 'Maryland', value: 'MD'}, { label: 'Maryland', value: 'MD' },
{label: 'New Jersey', value: 'NJ'}, { label: 'New Jersey', value: 'NJ' },
{label: 'New York', value: 'NY'}, { label: 'New York', value: 'NY' },
{label: 'Pennsylvania', value: 'PA'}, { label: 'Pennsylvania', value: 'PA' },
{label: 'Virginia', value: 'VA'}, { label: 'Virginia', value: 'VA' },
{label: 'Washington, DC', value: 'DC'}, { label: 'Washington, DC', value: 'DC' },
{label: 'West Virginia', value: 'WV'}, { label: 'West Virginia', value: 'WV' },
], ],
}, },
]} ]}
......
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