Skip to content

Commit eafc737

Browse files
authored
Merge pull request #45 from codaco/ui/inline-toggle
Adds inline property to toggle component.
2 parents d3f9f72 + f2ea156 commit eafc737

26 files changed

+197
-175
lines changed

docs/containers/FormPage.js

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,52 @@ import {
88
ContextInput,
99
ToggleGroup,
1010
RadioInput,
11-
RadioGroup
11+
RadioGroup,
1212
} from 'Components';
1313

1414
class FormPage extends Component {
1515
state = {
16-
formValues: {}
16+
formValues: {},
1717
}
1818

1919
handleTextChange = (e) => {
2020
this.setState({
2121
formValues: {
2222
...this.state.formValues,
23-
[e.target.name]: e.target.value
24-
}
25-
})
23+
[e.target.name]: e.target.value,
24+
},
25+
});
2626
}
2727

2828
handleCheckboxChange = (e, checkVal) => {
29-
console.log(checkVal)
30-
console.log(e.target.name)
3129
this.setState({
3230
formValues: {
3331
...this.state.formValues,
34-
[e.target.name]: checkVal
35-
}
36-
})
32+
[e.target.name]: checkVal,
33+
},
34+
});
3735
}
3836

3937
handleRadioChange = (e) => {
40-
console.log(e.target)
4138
this.setState({
4239
formValues: {
4340
...this.state.formValues,
44-
[e.target.name]: e.target.value
45-
}
46-
})
41+
[e.target.name]: e.target.value,
42+
},
43+
});
4744
}
4845

4946
handleToggleGroupChange = (e, checked, option) => {
50-
5147
const groupName = e.target.name;
5248
this.setState({
5349
formValues: {
5450
...this.state.formValues,
5551
[groupName]: {
5652
...this.state.formValues[groupName],
57-
[option]: checked
58-
}
59-
}
60-
})
53+
[option]: checked,
54+
},
55+
},
56+
});
6157
}
6258

6359
render() {
@@ -84,6 +80,15 @@ class FormPage extends Component {
8480
color="neon-carrot"
8581
checked={this.state.formValues.likesHedgehogs}
8682
/>
83+
<ToggleInput
84+
name="likesHedgehogs"
85+
containerClassName="custom"
86+
onCheck={this.handleCheckboxChange}
87+
label="Do you like them next to you?"
88+
color="neon-carrot"
89+
inline
90+
checked={this.state.formValues.likesHedgehogs}
91+
/>
8792
</div>
8893
<h3 className="type--page-title-large">Context</h3>
8994
<div className="grid__item">
@@ -97,7 +102,7 @@ class FormPage extends Component {
97102
name="likesPizza"
98103
onCheck={this.handleCheckboxChange}
99104
label="Pizza"
100-
color='kiwi'
105+
color="kiwi"
101106
checked={this.state.formValues.likesPizza}
102107
/>
103108
</div>
@@ -126,7 +131,7 @@ class FormPage extends Component {
126131
name="age"
127132
label="Age"
128133
placeholder="Baby Wurm Age"
129-
isNumericOnly={true}
134+
isNumericOnly
130135
errorText={this.state.formValues.age ? '' : 'Required'}
131136
onChange={this.handleTextChange}
132137
value={this.state.formValues.age}

lib/components/Inputs/InputLabel.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/components/Inputs/InputLabel.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/components/Inputs/ToggleInput.js

Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)