Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
Deprecate components replaced by FormControl#1888
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b0f890c2923c06f546a4f579cb9b52b02c38908ab07ae7c7e3ac28e4ac1ea92ad1656bd4d7c4af7feaf3f73f5f5d58622583c6740File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,7 +7,7 @@ source: https://github.com/primer/react/blob/main/src/InputField/InputField.tsx | ||
| storybook: '/react/storybook?path=/story/forms-inputfield--text-input-field' | ||
| --- | ||
| import {InputField, TextInputWithTokens, Autocomplete, Select} from '@primer/react' | ||
| import {TextInputWithTokens, Autocomplete, Select} from '@primer/react' | ||
| ## Deprecation | ||
| @@ -17,7 +17,7 @@ Use [FormControl](/FormControl) instead. | ||
| ### Basic | ||
| ```jsx live | ||
| ```jsx live deprecated | ||
mperrotti marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| <InputField> | ||
| <InputField.Label>Name</InputField.Label> | ||
| <TextInput /> | ||
| @@ -26,7 +26,7 @@ Use [FormControl](/FormControl) instead. | ||
| ### Required | ||
| ```jsx live | ||
| ```jsx live deprecated | ||
| <InputField required> | ||
| <InputField.Label>Name</InputField.Label> | ||
| <TextInput /> | ||
| @@ -35,7 +35,7 @@ Use [FormControl](/FormControl) instead. | ||
| ### Disabled | ||
| ```jsx live | ||
| ```jsx live deprecated | ||
| <InputField disabled> | ||
| <InputField.Label>Name</InputField.Label> | ||
| <TextInput /> | ||
| @@ -44,7 +44,7 @@ Use [FormControl](/FormControl) instead. | ||
| ### Using different input components | ||
| ```javascript live noinline | ||
| ```javascript live noinline deprecated | ||
| const TextInputWithTokensExample = () => { | ||
| const [tokens, setTokens] = React.useState([ | ||
| {text: 'zero', id: 0}, | ||
| @@ -115,7 +115,7 @@ Every input must have a corresponding label to be accessible to assistive techno | ||
| </Note> | ||
| ```jsx live | ||
| ```jsx live deprecated | ||
| <InputField> | ||
| <InputField.Label visuallyHidden>Name</InputField.Label> | ||
| <TextInput /> | ||
| @@ -124,7 +124,7 @@ Every input must have a corresponding label to be accessible to assistive techno | ||
| ### With a caption | ||
| ```jsx live | ||
| ```jsx live deprecated | ||
| <InputField> | ||
| <InputField.Label>Name</InputField.Label> | ||
| <TextInput /> | ||
| @@ -134,7 +134,7 @@ Every input must have a corresponding label to be accessible to assistive techno | ||
| ### With validation | ||
| ```javascript live noinline | ||
| ```javascript live noinline deprecated | ||
| const ValidationExample = () => { | ||
| const [value, setValue] = React.useState('mona lisa') | ||
| const [validationResult, setValidationResult] = React.useState() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -164,9 +164,11 @@ | ||
| - title: Flex | ||
| url: /deprecated/Flex | ||
| - title: FormGroup | ||
| url: /FormGroup | ||
| url: /deprecated/FormGroup | ||
| - title: Grid | ||
| url: /deprecated/Grid | ||
| - title: InputField | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General feedback about the docs for these deprecated components: I think you'll need to move the .md files to `docs/content/deprecated as otherwise they will 404 based on the path below 👇 | ||
| url: /deprecated/InputField | ||
mperrotti marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| - title: Position | ||
| url: /deprecated/Position | ||
| - title: SelectMenu | ||
| 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']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A TODO for later.. but @siddharthkp has done the codemod for these, which we can mention here too.