Skip to content
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

Deprecate legacy Label component #1889

Merged
merged 19 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 10 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
43 changes: 43 additions & 0 deletions .changeset/heavy-points-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
'@primer/react': major
---

![NewLabels](https://user-images.githubusercontent.com/2313998/155384037-8a56c943-4cff-4349-925b-dc28247e3491.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOO shiny ✨ ... We should do this for the other components too if we're doing this here. Thoughts @mperrotti?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean show all the variations? That might not fit neatly into 1 header image 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, no I meant other components being deprecated in v35 don't have header images in their release notes, so this will stand out. We should either do it for all, or not at all IMO.


The Label component's API and visual design have been updated to be consistent with its counterpart in [Primer ViewComponents' Label component](https://primer.style/view-components/components/label).

Major changes in the new Label component:

- No more `medium` size - only `small` and `large`
- Labels are outlined by default, so the `outline` prop has been removed
- Custom text and background colors are discouraged, but still possible via the `sx` prop

If you were using the `Label` component to render issue/PR labels, use the [IssueLabelToken](https://primer.style/react/Token#issuelabeltoken) component instead.

<table>
<tr>
<th> Before </th> <th> After </th>
</tr>
<tr>
<td valign="top">

```jsx
import {Label} from "@primer/react"

<Label outline>default</Label>
<Label variant="small" outline sx={{borderColor: 'danger.emphasis', color: 'danger.fg'}}>danger</Label>
```

</td>
<td valign="top">

```jsx
import {Label} from "@primer/react"

<Label>default</Label>
<Label size="small" variant="danger">danger</Label>
```

</td>
</tr>
</table>
105 changes: 65 additions & 40 deletions docs/content/Label.mdx
Original file line number Diff line number Diff line change
@@ -1,65 +1,90 @@
---
title: Label
description: Use Label components to add contextual metadata to a design.
status: Alpha
source: https://github.com/primer/react/blob/main/src/Label.tsx
componentId: label
status: Alpha
source: https://github.com/primer/react/tree/main/src/Label
storybook: '/react/storybook?path=story/labels-label--label'
description: Use Label components to add contextual metadata to a design.
---

## Example
## Examples

```jsx live
<>
<Label variant="small" outline sx={{borderColor: 'danger.emphasis', mr: 2, color: 'danger.fg'}}>
small
</Label>
<Label variant="medium" sx={{mr: 2}}>
medium (default)
</Label>
<Label variant="large" sx={{mr: 2}}>
large
</Label>
<Label variant="xl">xl label</Label>
### Basic

<Box mt={4} />
<Label variant="medium" sx={{bg: '#A575FF', m: 1}}>
good first issue
</Label>
<Label variant="medium" sx={{bg: '#FF75C8', m: 1}}>
🚂 deploy: train
</Label>
<Label variant="medium" sx={{bg: '#1C90FA', m: 1}}>
css
</Label>
<Label variant="medium" sx={{bg: '#FFF06C', color: '#24292E', m: 1}}>
documentation
</Label>
<Label variant="medium" sx={{bg: '#656BFE', m: 1}}>
primer
</Label>
</>
```javascript live noinline
render(<Label>Default</Label>)
```

### Variants

```javascript live noinline
render(
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't rendering correctly in the docs. I imagine it's because next branch hasn't been pulled in yet?
Screenshot 2022-02-25 at 12 41 19

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is because the next branch isn't pulled in yet. It's currently rendering the legacy Label

<Label>Default</Label>
<Label variant="primary">Primary</Label>
<Label variant="secondary">Secondary</Label>
<Label variant="accent">Accent</Label>
<Label variant="success">Success</Label>
<Label variant="attention">Attention</Label>
<Label variant="severe">Severe</Label>
<Label variant="danger">Danger</Label>
<Label variant="done">Done</Label>
<Label variant="sponsors">Sponsors</Label>
</>
)
```

### Sizes

```javascript live noinline
render(
<>
<Label>Small (default)</Label>
<Label size="large">Large</Label>
</>
)
```

## Props

### Label

<PropsTable>
<PropsTableRow name="outline" type="boolean" defaultValue="false" description="Creates an outline style label" />
<PropsTableRow name="variant" type="'small' | 'medium' | 'large' | 'xl'" defaultValue="'medium'" />
<PropsTableRow name="dropshadow" type="boolean" defaultValue="false" description="Adds a dropshadow to the label" />
<PropsTableSxRow />
<PropsTableRow
name="variant"
type={`| 'default'
| 'primary'
| 'secondary'
| 'accent'
| 'success'
| 'attention'
| 'severe'
| 'danger'
| 'done'
| 'sponsors'`}
defaultValue="'default'"
description="The color of the label"
/>
<PropsTableRow
name="size"
type="'small' | 'large'"
defaultValue="'small'"
description="How large the label is rendered"
/>
</PropsTable>

## Status

<ComponentChecklist
items={{
propsDocumented: true,
noUnnecessaryDeps: false,
noUnnecessaryDeps: true,
adaptsToThemes: true,
adaptsToScreenSizes: false,
fullTestCoverage: false,
adaptsToScreenSizes: true,
fullTestCoverage: true,
usedInProduction: false,
usageExamplesDocumented: true,
hasStorybookStories: true,
designReviewed: false,
a11yReviewed: false,
stableApi: false,
Expand Down
74 changes: 74 additions & 0 deletions docs/content/Label_deprecated.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Label
description: Use Label components to add contextual metadata to a design.
status: Deprecated
source: https://github.com/primer/react/blob/main/src/Label.tsx
componentId: legacy_label
---

## Deprecation

Use the new [Label](/Label) instead.

## Example

```jsx live deprecated
<>
<Label variant="small" outline sx={{borderColor: 'danger.emphasis', mr: 2, color: 'danger.fg'}}>
small
</Label>
<Label variant="medium" sx={{mr: 2}}>
medium (default)
</Label>
<Label variant="large" sx={{mr: 2}}>
large
</Label>
<Label variant="xl">xl label</Label>

<Box mt={4} />
<Label variant="medium" sx={{bg: '#A575FF', m: 1}}>
good first issue
</Label>
<Label variant="medium" sx={{bg: '#FF75C8', m: 1}}>
🚂 deploy: train
</Label>
<Label variant="medium" sx={{bg: '#1C90FA', m: 1}}>
css
</Label>
<Label variant="medium" sx={{bg: '#FFF06C', color: '#24292E', m: 1}}>
documentation
</Label>
<Label variant="medium" sx={{bg: '#656BFE', m: 1}}>
primer
</Label>
</>
```

## Props

<PropsTable>
<PropsTableRow name="outline" type="boolean" defaultValue="false" description="Creates an outline style label" />
<PropsTableRow name="variant" type="'small' | 'medium' | 'large' | 'xl'" defaultValue="'medium'" />
<PropsTableRow name="dropshadow" type="boolean" defaultValue="false" description="Adds a dropshadow to the label" />
<PropsTableSxRow />
</PropsTable>

## Status

<ComponentChecklist
items={{
propsDocumented: true,
noUnnecessaryDeps: false,
adaptsToThemes: true,
adaptsToScreenSizes: false,
fullTestCoverage: false,
usedInProduction: false,
usageExamplesDocumented: true,
designReviewed: false,
a11yReviewed: false,
stableApi: false,
addressedApiFeedback: false,
hasDesignGuidelines: false,
hasFigmaComponent: false
}}
/>
102 changes: 0 additions & 102 deletions docs/content/drafts/Label2.mdx

This file was deleted.

2 changes: 2 additions & 0 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,7 @@
url: /deprecated/Dropdown
- title: FormGroup
url: /FormGroup
- title: Label
url: /Label
- title: SelectMenu
url: /deprecated/SelectMenu
Loading