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

feat(Input): Use form-control-range for range inputs #1772

Merged
merged 1 commit into from Jan 28, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/lib/examples/InputType.js
Expand Up @@ -126,6 +126,10 @@ const Example = (props) => {
It's a bit lighter and easily wraps to a new line.
</FormText>
</FormGroup>
<FormGroup>
<Label for="exampleRange">Range</Label>
<Input type="range" name="range" id="exampleRange" />
</FormGroup>
<FormGroup check>
<Label check>
<Input type="radio" /> Option one is this and that—be sure to
Expand Down
3 changes: 3 additions & 0 deletions src/Input.js
Expand Up @@ -69,6 +69,7 @@ class Input extends React.Component {
const fileInput = type === 'file';
const textareaInput = type === 'textarea';
const selectInput = type === 'select';
const rangeInput = type === 'range';
let Tag = tag || (selectInput || textareaInput ? type : 'input');

let formControlClass = 'form-control';
Expand All @@ -78,6 +79,8 @@ class Input extends React.Component {
Tag = tag || 'input';
} else if (fileInput) {
formControlClass = `${formControlClass}-file`;
} else if (rangeInput) {
formControlClass = `${formControlClass}-range`;
} else if (checkInput) {
if (addon) {
formControlClass = null;
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/Input.spec.js
Expand Up @@ -221,4 +221,11 @@ describe('Input', () => {
expect(input.find('[type="select"]').exists()).toBe(false);
expect(textarea.find('[type="textarea"]').exists()).toBe(false);
});

it('should render with "form-control-range" not "form-control" class when type is range', () => {
const wrapper = shallow(<Input type="range" />);

expect(wrapper.hasClass('form-control-range')).toBe(true);
expect(wrapper.hasClass('form-control')).toBe(false);
});
});