Skip to content

Commit

Permalink
feat(v5): Add FormControl color support (#5349)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Jul 31, 2020
1 parent 5e96e51 commit 5c5e7ec
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const FormControl: BsPrefixRefForwardingComponent<
classes,
isValid && `is-valid`,
isInvalid && `is-invalid`,
type === 'color' && `${bsPrefix}-color`,
)}
/>
);
Expand Down
6 changes: 6 additions & 0 deletions test/FormControlSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ describe('<FormControl>', () => {
);
});

it('should support type=color', () => {
mount(<FormControl type="color" />).assertSingle(
'input.form-control.form-control-color',
);
});

it('should use controlId for id', () => {
mount(
<FormGroup controlId="foo">
Expand Down
1 change: 1 addition & 0 deletions tests/simple-types-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ const MegaComponent = () => (
/>

<Form.Switch label="Switch" disabled />
<Form.Control type="color" />
</Form>
<Image fluid rounded roundedCircle thumbnail bsPrefix="img" style={style} />
<div>
Expand Down
9 changes: 9 additions & 0 deletions www/src/examples/Form/ColorPicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<>
<Form.Label htmlFor="exampleColorInput">Color picker</Form.Label>
<Form.Control
type="color"
id="exampleColorInput"
value="#563d7c"
title="Choose your color"
/>
</>;
5 changes: 5 additions & 0 deletions www/src/pages/components/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import FormBasic from '../../examples/Form/Basic';
import Check from '../../examples/Form/Check';
import CheckApi from '../../examples/Form/CheckApi';
import CheckInline from '../../examples/Form/CheckInline';
import ColorPicker from '../../examples/Form/ColorPicker';
import FormFile from '../../examples/Form/FormFile';
import FormFileSizes from '../../examples/Form/FormFileSizes';
import FormDisabled from '../../examples/Form/FormDisabled';
Expand Down Expand Up @@ -106,6 +107,10 @@ export default withLayout(function FormControlsSection({ data }) {
default form field styling and preserve the correct margin and padding.
</p>
<ReactPlayground codeText={Plaintext} />
<LinkedHeading h="3" id="forms-color">
Color
</LinkedHeading>
<ReactPlayground codeText={ColorPicker} />
<LinkedHeading h="2" id="forms-form-check">
Checkboxes and Radios
</LinkedHeading>
Expand Down
1 change: 1 addition & 0 deletions www/src/pages/migrating.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Below is a _rough_ account of the breaking API changes as well as the minimal ch
- removed `custom`.
- removed `bsCustomPrefix`.
- dropped support for `type` supporting the `range` value in favor of FormRange.
- add color picker

### FormRow

Expand Down

0 comments on commit 5c5e7ec

Please sign in to comment.