-
Notifications
You must be signed in to change notification settings - Fork 645
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
Changes from 3 commits
b0f890c
2923c06
f546a4f
579cb9b
52b02c3
8908ab0
7ae7c7e
3ac28e4
ac1ea92
ad1656b
d4d7c4a
f7feaf3
f73f5f5
d586225
83c6740
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| --- | ||
| '@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 | ||
| ``` | ||
|
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. A TODO for later.. but @siddharthkp has done the codemod for these, which we can mention here too. |
||
|
|
||
| </td> | ||
| </tr> | ||
| </table> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,5 +161,7 @@ | |
| url: /deprecated/Dropdown | ||
| - title: FormGroup | ||
| url: /FormGroup | ||
| - 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.
Show resolved
Hide resolved
|
||
| - title: SelectMenu | ||
| url: /deprecated/SelectMenu | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,14 @@ import {get} from './constants' | |
| import sx, {SxProp} from './sx' | ||
| import {ComponentProps} from './utils/types' | ||
|
|
||
| /** @deprecated Use FormControl instead. See https://primer.style/react/FormControl for more details. */ | ||
|
||
| const FormGroup = styled.div<SxProp>` | ||
| margin: ${get('space.3')} 0; | ||
| font-weight: ${get('fontWeights.normal')}; | ||
| ${sx}; | ||
| ` | ||
|
|
||
| /** @deprecated Use FormControl instead. See https://primer.style/react/FormControl for more details. */ | ||
| const FormGroupLabel = styled.label<SxProp>` | ||
| display: block; | ||
| margin: 0 0 ${get('space.2')}; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** This is the place where we keep components that are deprecated. | ||
| * We don't recommend using it in production. | ||
| * If you already use them, please move to the suggested alternative components | ||
| * | ||
| * But, they are published on npm and you can import them. | ||
| * example: import {FormGroup} from '@primer/react/deprecated | ||
| */ | ||
|
|
||
| export {default as BorderBox} from '../BorderBox' | ||
| export type {BorderBoxProps} from '../BorderBox' | ||
| export {default as Flex} from '../Flex' | ||
| export type {FlexProps} from '../Flex' | ||
| export {default as Grid} from '../Grid' | ||
| export type {GridProps} from '../Grid' | ||
| export {default as Position, Absolute, Fixed, Relative, Sticky} from '../Position' | ||
| export type {PositionProps, AbsoluteProps, FixedProps, RelativeProps, StickyProps} from '../Position' | ||
| export {default as Dialog} from '../Dialog' | ||
| export type {DialogProps, DialogHeaderProps} from '../Dialog' | ||
| export {ConfirmationDialog} from '../Dialog/ConfirmationDialog' | ||
| export {default as Dropdown} from '../Dropdown' | ||
| export type { | ||
| DropdownProps, | ||
| DropdownCaretProps, | ||
| DropdownButtonProps, | ||
| DropdownItemProps, | ||
| DropdownMenuProps | ||
| } from '../Dropdown' | ||
| export {default as FormGroup} from '../FormGroup' | ||
| export type {FormGroupProps, FormGroupLabelProps} from '../FormGroup' | ||
| export {default as InputField} from '../InputField' | ||
mperrotti marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export {default as SelectMenu} from '../SelectMenu' | ||
Uh oh!
There was an error while loading. Please reload this page.