Skip to content

Add support for draft issues to the StateLabel component #1604

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

Merged
merged 6 commits into from
Nov 15, 2021
Merged
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
5 changes: 5 additions & 0 deletions .changeset/state-label-draft-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

Add support for draft issues to the StateLabel component
9 changes: 5 additions & 4 deletions docs/content/StateLabel.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Use StateLabel components to show the status of an issue or pull request.
<StateLabel status="pullClosed">Closed</StateLabel>
<StateLabel status="pullMerged">Merged</StateLabel>
<StateLabel status="draft">Draft</StateLabel>
<StateLabel status="issueDraft">Draft</StateLabel>
</>
```

Expand All @@ -29,7 +30,7 @@ StateLabel components get `COMMON` system props. Read our [System Props](/system

## Component props

| Name | Type | Default | Description |
| :------ | :----- | :------: | :------------------------------------------------------------------------------------------------ |
| variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
| status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, or `draft`. |
| Name | Type | Default | Description |
| :------ | :----- | :------: | :------------------------------------------------------------------------------------------------------------- |
| variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
| status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, `draft` or `issueDraft`. |
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"author": "GitHub, Inc.",
"license": "MIT",
"dependencies": {
"@primer/octicons-react": "^13.0.0",
"@primer/octicons-react": "^16.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new icon I'm using here (IssueDraftIcon) was added here primer/octicons#614 and shipped with version 14. I'm not sure how we update dependencies in such cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is likely causing some test failures right now 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the snapshots are stale. Does running test:update command help the tests pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rezrah looks like they are passing now with dd6b246

"@primer/primitives": "6.1.0",
"@radix-ui/react-polymorphic": "0.0.14",
"@react-aria/ssr": "3.1.0",
Expand Down
16 changes: 14 additions & 2 deletions src/StateLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import {GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon, QuestionIcon} from '@primer/octicons-react'
import {
GitMergeIcon,
GitPullRequestIcon,
IssueClosedIcon,
IssueDraftIcon,
IssueOpenedIcon,
QuestionIcon
} from '@primer/octicons-react'
import React from 'react'
import styled from 'styled-components'
import {variant} from 'styled-system'
Expand All @@ -13,7 +20,8 @@ const octiconMap = {
issueClosed: IssueClosedIcon,
pullClosed: GitPullRequestIcon,
pullMerged: GitMergeIcon,
draft: GitPullRequestIcon
draft: GitPullRequestIcon,
issueDraft: IssueDraftIcon
}

const colorVariants = variant({
Expand Down Expand Up @@ -42,6 +50,10 @@ const colorVariants = variant({
draft: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis'
},
issueDraft: {
backgroundColor: 'neutral.emphasis',
color: 'fg.onEmphasis'
}
}
})
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/Autocomplete.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ Array [
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/CircleBadge.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exports[`CircleBadge CircleBadge.Icon renders consistently 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/CircleOcticon.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ exports[`CircleOcticon renders consistently 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/Dialog.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Array [
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/DropdownMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ exports[`DropdownMenu renders consistently 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/__snapshots__/SelectMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ exports[`SelectMenu right-aligned modal has right: 0px 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -383,6 +384,7 @@ exports[`SelectMenu right-aligned modal has right: 0px 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -418,6 +420,7 @@ exports[`SelectMenu right-aligned modal has right: 0px 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -448,6 +451,7 @@ exports[`SelectMenu right-aligned modal has right: 0px 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/SelectPanel.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ exports[`SelectPanel renders consistently 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
19 changes: 13 additions & 6 deletions src/__tests__/__snapshots__/StateLabel.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`StateLabel renders children 1`] = `
className="c1"
dangerouslySetInnerHTML={
Object {
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z\\"></path>",
"__html": "<path d=\\"M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z\\"></path><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z\\"></path>",
}
}
fill="currentColor"
Expand All @@ -45,6 +45,7 @@ exports[`StateLabel renders children 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -92,7 +93,7 @@ exports[`StateLabel renders consistently 1`] = `
className="c1"
dangerouslySetInnerHTML={
Object {
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z\\"></path>",
"__html": "<path d=\\"M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z\\"></path><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z\\"></path>",
}
}
fill="currentColor"
Expand All @@ -101,6 +102,7 @@ exports[`StateLabel renders consistently 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -148,7 +150,7 @@ exports[`StateLabel respects the status prop 1`] = `
className="c1"
dangerouslySetInnerHTML={
Object {
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z\\"></path>",
"__html": "<path d=\\"M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z\\"></path><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z\\"></path>",
}
}
fill="currentColor"
Expand All @@ -157,6 +159,7 @@ exports[`StateLabel respects the status prop 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -203,7 +206,7 @@ exports[`StateLabel respects the status prop 2`] = `
className="c1"
dangerouslySetInnerHTML={
Object {
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M1.5 8a6.5 6.5 0 0110.65-5.003.75.75 0 00.959-1.153 8 8 0 102.592 8.33.75.75 0 10-1.444-.407A6.5 6.5 0 011.5 8zM8 12a1 1 0 100-2 1 1 0 000 2zm0-8a.75.75 0 01.75.75v3.5a.75.75 0 11-1.5 0v-3.5A.75.75 0 018 4zm4.78 4.28l3-3a.75.75 0 00-1.06-1.06l-2.47 2.47-.97-.97a.749.749 0 10-1.06 1.06l1.5 1.5a.75.75 0 001.06 0z\\"></path>",
"__html": "<path d=\\"M11.28 6.78a.75.75 0 00-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 00-1.06 1.06l2 2a.75.75 0 001.06 0l3.5-3.5z\\"></path><path fill-rule=\\"evenodd\\" d=\\"M16 8A8 8 0 110 8a8 8 0 0116 0zm-1.5 0a6.5 6.5 0 11-13 0 6.5 6.5 0 0113 0z\\"></path>",
}
}
fill="currentColor"
Expand All @@ -212,6 +215,7 @@ exports[`StateLabel respects the status prop 2`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -267,6 +271,7 @@ exports[`StateLabel respects the status prop 3`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -313,7 +318,7 @@ exports[`StateLabel respects the variant prop 1`] = `
className="c1"
dangerouslySetInnerHTML={
Object {
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z\\"></path>",
"__html": "<path d=\\"M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z\\"></path><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z\\"></path>",
}
}
fill="currentColor"
Expand All @@ -322,6 +327,7 @@ exports[`StateLabel respects the variant prop 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down Expand Up @@ -368,7 +374,7 @@ exports[`StateLabel respects the variant prop 2`] = `
className="c1"
dangerouslySetInnerHTML={
Object {
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z\\"></path>",
"__html": "<path d=\\"M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z\\"></path><path fill-rule=\\"evenodd\\" d=\\"M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z\\"></path>",
}
}
fill="currentColor"
Expand All @@ -377,6 +383,7 @@ exports[`StateLabel respects the variant prop 2`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/StyledOcticon.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`StyledOcticon renders consistently 1`] = `
style={
Object {
"display": "inline-block",
"overflow": "visible",
"userSelect": "none",
"verticalAlign": "text-bottom",
}
Expand Down
Loading