Skip to content

[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
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions docs/content/drafts/Label2.mdx
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 ↑
Copy link
Contributor Author

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


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
}}
/>
141 changes: 29 additions & 112 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading