-
Notifications
You must be signed in to change notification settings - Fork 616
[WIP] Getting the Label component to beta #1790
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
20a94e2
introduces new label component
mperrotti 80e19e5
updates storybook stories and adds React docs for Label components
mperrotti ba00430
adds tests
mperrotti a49a484
uses hacky fix for rendering the correct Label component in the docs
mperrotti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,159 @@ | ||
--- | ||
title: Label | ||
componentId: label2 | ||
status: Alpha | ||
source: https://github.com/primer/react/tree/main/src/Label2 | ||
storybook: '/react/storybook?path=/story/label-label2--label' | ||
description: Use Label components to add contextual metadata to a design. | ||
--- | ||
|
||
import {MarkGithubIcon} from '@primer/octicons-react' | ||
|
||
## Examples | ||
|
||
### Text-only | ||
|
||
```javascript live noinline | ||
// import {Label} from '@primer/react/drafts' | ||
const {Label} = drafts // ignore docs silliness; import like that ↑ | ||
|
||
render(<Label>Default</Label>) | ||
``` | ||
|
||
### Filled | ||
|
||
```javascript live noinline | ||
// import {Label} from '@primer/react/drafts' | ||
const {Label} = drafts // ignore docs silliness; import like that ↑ | ||
|
||
render(<Label filled>Default</Label>) | ||
``` | ||
|
||
### With a leading visual | ||
|
||
```javascript live noinline | ||
// import {Label} from '@primer/react/drafts' | ||
const {Label} = drafts // ignore docs silliness; import like that ↑ | ||
|
||
render(<Label leadingVisual={MarkGithubIcon}>Default</Label>) | ||
``` | ||
|
||
### Appearances | ||
|
||
```javascript live noinline | ||
// import {Label} from '@primer/react/drafts' | ||
const {Label} = drafts // ignore docs silliness; import like that ↑ | ||
render( | ||
<> | ||
<Label>Default</Label> | ||
<Label appearance="primary">Primary</Label> | ||
<Label appearance="secondary">Secondary</Label> | ||
<Label appearance="accent">Info</Label> | ||
<Label appearance="success">Success</Label> | ||
<Label appearance="attention">Warning</Label> | ||
<Label appearance="severe">Severe</Label> | ||
<Label appearance="danger">Danger</Label> | ||
<Label appearance="done">Done</Label> | ||
<Label appearance="sponsors">Sponsors</Label> | ||
</> | ||
) | ||
``` | ||
|
||
### Sizes | ||
|
||
```javascript live noinline | ||
// import {Label} from '@primer/react/drafts' | ||
const {Label} = drafts // ignore docs silliness; import like that ↑ | ||
render( | ||
<> | ||
<Label size="sm">Small (default)</Label> | ||
<Label size="md">Medium</Label> | ||
<Label size="lg">Large</Label> | ||
</> | ||
) | ||
``` | ||
|
||
### StateLabel states | ||
|
||
```javascript live noinline | ||
// import {StateLabel} from '@primer/react/drafts' | ||
const {StateLabel} = drafts // ignore docs silliness; import like that ↑ | ||
render( | ||
<> | ||
<StateLabel status="issueOpened">Issue opened</StateLabel> | ||
<StateLabel status="issueClosed">Issue closed</StateLabel> | ||
<StateLabel status="pullOpened">Opened</StateLabel> | ||
<StateLabel status="pullClosed">Closed</StateLabel> | ||
<StateLabel status="pullMerged">Merged</StateLabel> | ||
<StateLabel status="draft">Draft</StateLabel> | ||
</> | ||
) | ||
``` | ||
|
||
## Props | ||
|
||
### Label | ||
|
||
<PropsTable> | ||
<PropsTableRow | ||
name="appearance" | ||
type="'default' | 'primary' | 'secondary' | 'accent' | 'success' | 'attention' | 'severe' | 'danger' | 'done' | 'sponsors'" | ||
defaultValue="'default'" | ||
description="The color of the label" | ||
/> | ||
<PropsTableRow | ||
name="size" | ||
type="'sm' | 'md' | 'lg'" | ||
defaultValue="'md'" | ||
description="How large the label is rendered" | ||
/> | ||
<PropsTableRow | ||
name="filled" | ||
type="boolean" | ||
defaultValue="false" | ||
description="Whether the label should be styled with a solid background color" | ||
/> | ||
<PropsTableRow | ||
name="leadingVisual" | ||
type="React.ComponentType<any>" | ||
description="The icon component to be rendered before the the label's text" | ||
/> | ||
</PropsTable> | ||
|
||
### StateLabel | ||
|
||
<PropsTable> | ||
<PropsTableRow | ||
name="appearance" | ||
type="'issueClosed' | 'pullClosed' | 'pullMerged' | 'issueOpened' | 'pullOpened' | 'draft'" | ||
defaultValue="'default'" | ||
description="Changes the visual design of the label to match the status that the label is communicating" | ||
/> | ||
<PropsTableRow | ||
name="size" | ||
type="'sm' | 'md' | 'lg'" | ||
defaultValue="'md'" | ||
description="How large the label is rendered" | ||
/> | ||
</PropsTable> | ||
|
||
## Status | ||
|
||
<ComponentChecklist | ||
items={{ | ||
propsDocumented: true, | ||
noUnnecessaryDeps: true, | ||
adaptsToThemes: true, | ||
adaptsToScreenSizes: true, | ||
fullTestCoverage: true, | ||
usedInProduction: false, | ||
usageExamplesDocumented: true, | ||
hasStorybookStories: true, | ||
designReviewed: false, | ||
a11yReviewed: false, | ||
stableApi: false, | ||
addressedApiFeedback: false, | ||
hasDesignGuidelines: false, | ||
hasFigmaComponent: false | ||
}} | ||
/> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We can remove these once #1785 is merged