Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
Update component docs (Header, Radio, Checkbox, Heading, Label, LabelGroup)#1708
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
f356d91b9ccc23f27b94a84bf8e704bbdf468e5ba058b8840e130ede6c06832dcc990d816121153647861098cb15e4c0e4d32dc872345eb6ff10c7cFile 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 |
|---|---|---|
| @@ -1,25 +1,24 @@ | ||
| --- | ||
| componentId: checkbox | ||
| title: Checkbox | ||
| description: Use checkboxes to toggle between checked and unchecked states in a list or as a standalone form field | ||
| status: Alpha | ||
| source: https://github.com/primer/react/blob/main/src/Checkbox.tsx | ||
| storybook: '/react/storybook?path=/story/forms-checkbox--default' | ||
| componentId: checkbox | ||
| --- | ||
| import {ComponentChecklist} from '../src/component-checklist' | ||
| ## Examples | ||
| <Note variant="warning"> | ||
| **Use [ChoiceInputField](/ChoiceInputField) to display an accessible checkbox form field**. This `Checkbox` component is intended only as an ingredient for other custom components, or as a drop-in replacement for native HTML checkboxes outside of form use-cases. | ||
| If you do use this component to build a custom checkbox, it should always be accompanied by a corresponding `<label>` to improve support for assistive technologies. | ||
| </Note> | ||
| ## Default example | ||
| The `Checkbox` component can be used in controlled and uncontrolled modes. | ||
| ```jsx live | ||
| @@ -53,10 +52,11 @@ The `Checkbox` component can be used in controlled and uncontrolled modes. | ||
| ``` | ||
| <Note variant="warning"> | ||
| Checkbox components should always be accompanied by a corresponding label to improve support for assistive technologies. | ||
| Checkbox components should always be accompanied by a corresponding label to improve support for assistive | ||
| technologies. | ||
| </Note> | ||
| ## Indeterminate example | ||
| ## Indeterminate | ||
| An `indeterminate` checkbox state should be used if the input value is neither true nor false. This can be useful in situations where you are required to display an incomplete state, or one that is dependent on other input selections to determine a value. | ||
| @@ -95,22 +95,59 @@ An `indeterminate` checkbox state should be used if the input value is neither t | ||
| </> | ||
| ``` | ||
| ## Component props | ||
| Native `<input>` attributes are forwarded to the underlying React `input` component and are not listed below. | ||
| | Name | Type | Default | Description | | ||
| | :------------- | :---------- | :-------: | :------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| | checked | Boolean | undefined | Optional. Modifies true/false value of the native checkbox | | ||
| | defaultChecked | Boolean | undefined | Optional. Checks the input by default in uncontrolled mode | | ||
| | onChange | ChangeEvent | undefined | Optional. A callback function that is triggered when the checked state has been changed. | | ||
| | disabled | Boolean | undefined | Optional. Modifies the native disabled state of the native checkbox | | ||
| | indeterminate | Boolean | undefined | Optional. Applies an [indeterminate](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#attr-indeterminate) state to the checkbox | | ||
| ## Component status | ||
| ## Props | ||
| <PropsTable> | ||
| <PropsTableRow | ||
| name="checked" | ||
| type="boolean" | ||
| description="Modifies true/false value of the native checkbox" | ||
| /> | ||
| <PropsTableRow | ||
| name="defaultChecked" | ||
| type="boolean" | ||
| description="Checks the input by default in uncontrolled mode" | ||
| /> | ||
| <PropsTableRow | ||
| name="onChange" | ||
| type="(event: React.ChangeEvent) => void" | ||
| description="A callback function that is triggered when the checked state has been changed" | ||
| /> | ||
| <PropsTableRow | ||
| name="disabled" | ||
| type="boolean" | ||
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. Does this have a default value? ContributorAuthor 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. It's an optional prop, so no. Or are you setting undefined explicitly? 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. Would it make sense to say this defaults to ContributorAuthor 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. I think that's misrepresenting the data type, as false !== undefined. I think literally | ||
| description="Modifies the native disabled state of the native checkbox" | ||
| /> | ||
| <PropsTableRow | ||
| name="indeterminate" | ||
| type="boolean" | ||
rezrah marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| defaultValue="false" | ||
| description={ | ||
| <> | ||
| Applies an{' '} | ||
| <Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#attr-indeterminate"> | ||
| indeterminate state | ||
| </Link>{' '} | ||
| to the checkbox | ||
| </> | ||
| } | ||
| /> | ||
| <PropsTableBasePropRows | ||
| elementType="input" | ||
| refType="HTMLInputElement" | ||
| passthroughPropsLink={ | ||
| <Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#additional_attributes"> | ||
| MDN | ||
| </Link> | ||
| } | ||
| /> | ||
| </PropsTable> | ||
| ## Status | ||
| <ComponentChecklist | ||
| items={{ | ||
| items={{ | ||
| propsDocumented: true, | ||
| noUnnecessaryDeps: true, | ||
| adaptsToThemes: true, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| --- | ||
| componentId: header | ||
| title: Header | ||
| description: Use the Header component to create a header that has all of its items aligned vertically with consistent horizontal spacing | ||
| status: Alpha | ||
| source: https://github.com/primer/react/blob/main/src/Header.tsx | ||
| componentId: header | ||
| --- | ||
| Use the `Header` component to create a header that has all of its items aligned vertically with consistent horizontal spacing. | ||
| ## Default example | ||
| ## Examples | ||
colebemis marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| All items directly under the Header component should be a `Header.Item` component. Inside these components can be anything (text, forms, images...), and the `Header.Item` component will make sure these elements vertically align with each other. | ||
| @@ -27,7 +27,7 @@ All items directly under the Header component should be a `Header.Item` componen | ||
| </Header> | ||
| ``` | ||
| ## Header with full-size item example | ||
| ### With full-size item | ||
| ```jsx live | ||
| <Header> | ||
| @@ -39,7 +39,7 @@ All items directly under the Header component should be a `Header.Item` componen | ||
| </Header> | ||
| ``` | ||
| ## Header with links example | ||
| ### With links | ||
| ```jsx live | ||
| <Header> | ||
| @@ -55,25 +55,49 @@ All items directly under the Header component should be a `Header.Item` componen | ||
| </Header> | ||
| ``` | ||
| ## Component props | ||
| ## Props | ||
| ### Header | ||
| | Name | Type | Default | Description | | ||
| | :--- | :---------------- | :-----: | :----------------------------------- | | ||
| | sx | SystemStyleObject | {} | Style to be applied to the component | | ||
| <PropsTable> | ||
| <PropsTableSxRow /> | ||
| </PropsTable> | ||
| ### Header.Item | ||
| | Name | Type | Default | Description | | ||
| | :--- | :---------------- | :-----: | :----------------------------------------- | | ||
| | full | Boolean | | stretches item to fill the available space | | ||
| | sx | SystemStyleObject | {} | Style to be applied to the component | | ||
| <PropsTable> | ||
| <PropsTableRow name="full" type="string" description="Stretches item to fill the available space" /> | ||
| <PropsTableSxRow /> | ||
| </PropsTable> | ||
| ### Header.Link | ||
| | Name | Type | Default | Description | | ||
| | :--- | :---------------- | :-----: | :----------------------------------- | | ||
| | as | String | | sets the HTML tag for the component | | ||
| | href | String | | URL to be used for the Link | | ||
| | sx | SystemStyleObject | {} | Style to be applied to the component | | ||
| <PropsTable> | ||
| <PropsTableRow name="href" type="string" description="URL to be used for the Link" /> | ||
| <PropsTableBasePropRows | ||
| elementType="a" | ||
| passthroughPropsLink={ | ||
| <Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes">MDN</Link> | ||
| } | ||
| /> | ||
| </PropsTable> | ||
colebemis marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ## Status | ||
| <ComponentChecklist | ||
| items={{ | ||
| propsDocumented: true, | ||
| noUnnecessaryDeps: true, | ||
| adaptsToThemes: true, | ||
| adaptsToScreenSizes: false, | ||
| fullTestCoverage: false, | ||
| usedInProduction: false, | ||
| usageExamplesDocumented: true, | ||
| designReviewed: false, | ||
| a11yReviewed: false, | ||
| stableApi: false, | ||
| addressedApiFeedback: false, | ||
| hasDesignGuidelines: false, | ||
| hasFigmaComponent: false | ||
| }} | ||
| /> | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: Heading | ||
| description: Use Heading to structure your content and provide an accessible experience for users of assistive technologies. | ||
| source: https://github.com/primer/react/blob/main/src/Heading.tsx | ||
| status: Alpha | ||
rezrah marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| componentId: heading | ||
| --- | ||
| The Heading component will render an html `h2` tag without any default styling. Other heading level elements `h1-h6` are available through use of the `as` prop (see [System Props](/system-props) for additional explanation). Please reference the [w3 recommendations for headings](https://www.w3.org/WAI/tutorials/page-structure/headings/) to ensure your headings provide an accessible experience for screen reader users. | ||
| **Attention:** Make sure to include a valid heading element to render a Heading component other than `h2` (`<Heading as="h1">H1 Element</Heading>`). | ||
| ## Example | ||
| ```jsx live | ||
| <Heading sx={{fontSize: 1, mb: 2}}>H2 heading with fontSize={1}</Heading> | ||
| ``` | ||
| ## Props | ||
| <PropsTable> | ||
| <PropsTableAsRow defaultElementType="h2" /> | ||
| <PropsTableSxRow /> | ||
| </PropsTable> | ||
colebemis marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ## Status | ||
| <ComponentChecklist | ||
| items={{ | ||
| propsDocumented: true, | ||
| noUnnecessaryDeps: true, | ||
| adaptsToThemes: true, | ||
| adaptsToScreenSizes: false, | ||
| fullTestCoverage: true, | ||
| usedInProduction: false, | ||
| usageExamplesDocumented: true, | ||
| designReviewed: false, | ||
| a11yReviewed: false, | ||
| stableApi: false, | ||
| addressedApiFeedback: false, | ||
| hasDesignGuidelines: false, | ||
| hasFigmaComponent: false | ||
| }} | ||
| /> | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
The heading of prop tables is usually the name of the component:
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.
The example heading in the Issue description here shows it as Props, which feels sensible given the content it describes... or am I misunderstanding this? What was the reasoning behind repeating the component name here?