Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap v4 prep #402

Merged
merged 5 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions src/components/AddressInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import classnames from 'classnames';

import CountryInput from './CountryInput';
import StateInput from './StateInput';
import ValidatedFormGroup from './ValidatedFormGroup';
import FormLabelGroup from './FormLabelGroup';
import Col from './Col';
import Input from './Input';
import Row from './Row';
Expand Down Expand Up @@ -67,9 +67,10 @@ class AddressInput extends React.Component {

return (
<div id={id}>
<ValidatedFormGroup
<FormLabelGroup
label={showLabels ? labels.address1 : null}
error={error.address1}
feedback={error.address1}
stacked
>
<Input
id={id ? `${id}_address1` : null}
Expand All @@ -83,10 +84,12 @@ class AddressInput extends React.Component {
disabled={disabled}
getRef={this.bindAddress1}
/>
</ValidatedFormGroup>
<ValidatedFormGroup
</FormLabelGroup>
<FormLabelGroup
label={showLabels ? labels.address2 : null}
error={error.address2}
feedback={error.address2}
stacked
>
<Input
id={id ? `${id}_address2` : null}
Expand All @@ -99,13 +102,14 @@ class AddressInput extends React.Component {
onChange={flow([readEvent, this.onChange])}
disabled={disabled}
/>
</ValidatedFormGroup>
</FormLabelGroup>
<Row className="no-gutters">
<Col sm={6} xs={5}>
<ValidatedFormGroup
className={classnames('pr-3', { 'mb-0': !showCountry })}
error={error.city}
<FormLabelGroup
rowClassName={classnames({ 'mb-0': !showCountry })}
feedback={error.city}
label={showLabels ? labels.city : null}
stacked
>
<Input
id={id ? `${id}_city` : null}
Expand All @@ -118,31 +122,34 @@ class AddressInput extends React.Component {
onChange={flow([readEvent, this.onChange])}
disabled={disabled}
/>
</ValidatedFormGroup>
</FormLabelGroup>
</Col>
<Col sm={2} xs={3}>
<ValidatedFormGroup
className={classnames('pr-3', { 'mb-0': !showCountry })}
error={error.state}
<Col sm={2} xs={3} className="px-3">
<FormLabelGroup
rowClassName={classnames({ 'mb-0': !showCountry })}
feedback={error.state}
label={showLabels ? labels.state : null}
stacked
>
<StateInput
className="w-100"
id={id ? `${id}_state` : null}
name="state"
placeholder={labels.state}
{...this.propsFor('state')}
state={error.state && 'danger'}
onBlur={() => onBlur('state')}
onChange={state => this.onChange({ state })}
disabled={disabled}
/>
</ValidatedFormGroup>
</FormLabelGroup>
</Col>
<Col sm={4} xs={4}>
<ValidatedFormGroup
className={classnames({ 'mb-0': !showCountry })}
<FormLabelGroup
rowClassName={classnames({ 'mb-0': !showCountry })}
label={showLabels ? labels.postal : null}
error={error.postal}
feedback={error.postal}
stacked
>
<Input
id={id ? `${id}_postal` : null}
Expand All @@ -155,26 +162,28 @@ class AddressInput extends React.Component {
onChange={flow([readEvent, this.onChange])}
disabled={disabled}
/>
</ValidatedFormGroup>
</FormLabelGroup>
</Col>
</Row>
{showCountry &&
<ValidatedFormGroup
error={error.countryCode}
className="mb-0"
<FormLabelGroup
feedback={error.countryCode}
rowClassName="mb-0"
label={showLabels ? labels.countryCode : null}
stacked
>
<CountryInput
className="w-100"
id={id ? `${id}_countryCode` : null}
name="countryCode"
placeholder={labels.countryCode}
{...this.propsFor('countryCode')}
state={error.countryCode && 'danger'}
onBlur={() => onBlur('countryCode')}
onChange={countryCode => this.onChange({ countryCode })}
disabled={disabled}
/>
</ValidatedFormGroup>
</FormLabelGroup>
}
</div>
);
Expand Down
7 changes: 4 additions & 3 deletions src/components/ConfirmationButton.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import onClickOutside from 'react-onclickoutside';
import Button from './Button';

class ConfirmationButton extends React.Component {
static propTypes = {
children: React.PropTypes.node,
confirmation: React.PropTypes.string,
onClick: React.PropTypes.func
children: PropTypes.node,
confirmation: PropTypes.string,
onClick: PropTypes.func
}

static defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/FormRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ const FormRow = (props) => {
{...attributes}
{...childFeedback}
/>
{hint && <FormText color="muted">{hint}</FormText>}
{baseFeedback && <FormFeedback>{baseFeedback}</FormFeedback>}
</Col>
</Row>
{hint ? <FormText color="muted" children={hint} /> : null}
{baseFeedback ? <FormFeedback children={baseFeedback} /> : null}
</Col>
</FormGroup>
);
Expand Down
6 changes: 3 additions & 3 deletions test/components/AddressInput.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ describe('<AddressInput />', () => {
countryCode: 'Foxtrot'
};
const component = mount(<AddressInput showLabels labels={labels} />);
Object.keys(labels).forEach(key => {
assert(component.contains(<Label>{labels[key]}</Label>));
});
const formLabels = component.find(Label);
assert.equal(formLabels.length, 6);
formLabels.forEach(label => assert(Object.values(labels).includes(label.text())));
});

it('should not show custom labels when disabled', () => {
Expand Down