-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate components replaced by FormControl (#1888)
* moves InputField to deprecated package * adds jsdoc comments for deprecation * adds changeset * fixes bad autoformatting in changeset * fixes import path in test file * addresses PR feedback * fixes FormGroup import in test * addresses PR feedback * moves tests to depreacted directory * removes docs header image * fixes bad formatting in changelog markdown
- Loading branch information
Showing
19 changed files
with
148 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
'@primer/react': major | ||
--- | ||
|
||
The `FormControl` component will be used to deprecate the `FormGroup`, `InputField`, and `ChoiceInputField` components. It has the ability to render contextual content with your inputs: labels, validation statuses, captions. It also handles the ARIA attributes that make the form controls accessible to assistive technology. | ||
|
||
<table> | ||
<tr> | ||
<th> Before </th> <th> After </th> | ||
</tr> | ||
<tr> | ||
<td valign="top"> | ||
|
||
```jsx | ||
import {FormControl, Checkbox, TextInput} from "@primer/react" | ||
|
||
|
||
<FormGroup> | ||
<FormGroup.Label htmlFor="example-text">Example text</FormGroup.Label> | ||
<TextInput id="example-text" /> | ||
</FormGroup> | ||
|
||
// OR | ||
|
||
<InputField> | ||
<InputField.Label>Example text</InputField.Label> | ||
<TextInput /> | ||
</InputField> | ||
|
||
// OR | ||
|
||
<ChoiceInputField> | ||
<ChoiceInputField.Label>Example text</ChoiceInputField.Label> | ||
<Checkbox /> | ||
</ChoiceInputField> | ||
|
||
``` | ||
|
||
</td> | ||
<td valign="top"> | ||
|
||
```jsx | ||
import {FormGroup, TextInput} from "@primer/react" | ||
|
||
<FormControl> | ||
<FormControl.Label>Example text</FormControl.Label> | ||
<TextInput /> | ||
</FormControl> | ||
|
||
// OR | ||
|
||
<FormControl> | ||
<FormControl.Label>Example text</FormControl.Label> | ||
<Checkbox /> | ||
</FormControl> | ||
|
||
``` | ||
|
||
</td> | ||
</tr> | ||
<tr> | ||
<td valign="top"> | ||
|
||
```jsx | ||
import {InputField} from '@primer/react' | ||
<InputField> | ||
<InputField.Label>Example text</InputField.Label> | ||
<TextInput /> | ||
</InputField> | ||
``` | ||
|
||
</td> | ||
<td valign="top"> | ||
|
||
```jsx | ||
import {FormControl} from '@primer/react' | ||
<FormControl> | ||
<FormControl.Label>Example Text</FormControl.Label> | ||
<TextInput /> | ||
</FormControl> | ||
``` | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
<table style="display: table"> | ||
<tr><th>Migration steps to FormControl</th></tr> | ||
<tr> | ||
<td> | ||
|
||
<strong>Upgrade to the new</strong> `FormControl` component by referring to the [examples in our documentation](https://primer.style/react/FormControl). | ||
|
||
or | ||
|
||
<strong>Continue using the deprecated</strong> `FormGroup`, `ChoiceInputField` or `InputField` : | ||
|
||
```js | ||
import {FormGroup, ChoiceInputField, InputField} from '@primer/react/deprecated' // change your import statements | ||
``` | ||
|
||
Codemods: | ||
|
||
- InputField codemod: https://github.com/primer/react-migrate/blob/main/src/use-deprecated-inputfield.js | ||
- ChoiceInputField https://github.com/primer/react-migrate/blob/main/src/use-deprecated-choiceinputfield.js | ||
- FormGroup codemod: https://github.com/primer/react-migrate/blob/main/src/use-deprecated-formgroup.js | ||
|
||
</td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/InputField/_InputFieldCaption.tsx → ...recated/InputField/_InputFieldCaption.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/InputField/_InputFieldLabel.tsx → ...eprecated/InputField/_InputFieldLabel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import createSlots from '../utils/create-slots' | ||
import createSlots from '../../utils/create-slots' | ||
|
||
export const {Slots, Slot} = createSlots(['Caption', 'Input', 'Label', 'LeadingVisual']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters