Skip to content

Commit 384ae6b

Browse files
author
Andrew L
authored
Updated StateLabel to include issueClosedNotPlanned and fix issueClosed colour (#2171)
* Updated StateLabel * Add changeset * Update test * Update the test suites
1 parent 320f3e9 commit 384ae6b

File tree

5 files changed

+76
-7
lines changed

5 files changed

+76
-7
lines changed

.changeset/chilly-frogs-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Support issues closed as not planned, and correct the standard issue closed backgroud colour

docs/content/StateLabel.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Use StateLabel components to show the status of an issue or pull request.
1212
<>
1313
<StateLabel status="issueOpened">Open</StateLabel>
1414
<StateLabel status="issueClosed">Closed</StateLabel>
15+
<StateLabel status="issueClosedNotPlanned">Closed</StateLabel>
1516
<StateLabel status="pullOpened">Open</StateLabel>
1617
<StateLabel status="pullClosed">Closed</StateLabel>
1718
<StateLabel status="pullMerged">Merged</StateLabel>
@@ -22,8 +23,8 @@ Use StateLabel components to show the status of an issue or pull request.
2223

2324
## Component props
2425

25-
| Name | Type | Default | Description |
26-
| :------ | :---------------- | :------: | :------------------------------------------------------------------------------------------------------------- |
27-
| variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
28-
| status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, `draft` or `issueDraft`. |
29-
| sx | SystemStyleObject | {} | Style to be applied to the component |
26+
| Name | Type | Default | Description |
27+
| :------ | :---------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------- |
28+
| variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
29+
| status | String | | Can be one of `issueOpened`, `issueClosed`, `issueClosedNotPlanned`, `pullOpened`, `pullClosed`, `pullMerged`, `draft` or `issueDraft`. |
30+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/StateLabel.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
GitMergeIcon,
33
GitPullRequestIcon,
44
IssueClosedIcon,
5+
SkipIcon,
56
IssueDraftIcon,
67
IssueOpenedIcon,
78
QuestionIcon
@@ -18,6 +19,7 @@ const octiconMap = {
1819
issueOpened: IssueOpenedIcon,
1920
pullOpened: GitPullRequestIcon,
2021
issueClosed: IssueClosedIcon,
22+
issueClosedNotPlanned: SkipIcon,
2123
pullClosed: GitPullRequestIcon,
2224
pullMerged: GitMergeIcon,
2325
draft: GitPullRequestIcon,
@@ -28,7 +30,11 @@ const colorVariants = variant({
2830
prop: 'status',
2931
variants: {
3032
issueClosed: {
31-
backgroundColor: 'danger.emphasis',
33+
backgroundColor: 'done.emphasis',
34+
color: 'fg.onEmphasis'
35+
},
36+
issueClosedNotPlanned: {
37+
backgroundColor: 'neutral.emphasis',
3238
color: 'fg.onEmphasis'
3339
},
3440
pullClosed: {

src/__tests__/StateLabel.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('StateLabel', () => {
3434
it('respects the status prop', () => {
3535
expect(render(<StateLabel status="issueOpened" />)).toMatchSnapshot()
3636
expect(render(<StateLabel status="issueClosed" />)).toMatchSnapshot()
37+
expect(render(<StateLabel status="issueClosedNotPlanned" />)).toMatchSnapshot()
3738
expect(render(<StateLabel status="pullMerged" />)).toMatchSnapshot()
3839
})
3940

src/__tests__/__snapshots__/StateLabel.test.tsx.snap

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ exports[`StateLabel respects the status prop 2`] = `
189189
color: #ffffff;
190190
text-align: center;
191191
border-radius: 100px;
192-
background-color: #cf222e;
192+
background-color: #8250df;
193193
color: #ffffff;
194194
padding-left: 12px;
195195
padding-right: 12px;
@@ -231,6 +231,62 @@ exports[`StateLabel respects the status prop 3`] = `
231231
margin-right: 4px;
232232
}
233233
234+
.c0 {
235+
display: -webkit-inline-box;
236+
display: -webkit-inline-flex;
237+
display: -ms-inline-flexbox;
238+
display: inline-flex;
239+
-webkit-align-items: center;
240+
-webkit-box-align: center;
241+
-ms-flex-align: center;
242+
align-items: center;
243+
font-weight: 600;
244+
line-height: 16px;
245+
color: #ffffff;
246+
text-align: center;
247+
border-radius: 100px;
248+
background-color: #6e7781;
249+
color: #ffffff;
250+
padding-left: 12px;
251+
padding-right: 12px;
252+
padding-top: 8px;
253+
padding-bottom: 8px;
254+
font-size: 14px;
255+
}
256+
257+
<span
258+
className="c0"
259+
>
260+
<svg
261+
aria-hidden="true"
262+
className="c1"
263+
dangerouslySetInnerHTML={
264+
Object {
265+
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm3.28 5.78a.75.75 0 00-1.06-1.06l-5.5 5.5a.75.75 0 101.06 1.06l5.5-5.5z\\"></path>",
266+
}
267+
}
268+
fill="currentColor"
269+
height={16}
270+
role="img"
271+
style={
272+
Object {
273+
"display": "inline-block",
274+
"overflow": "visible",
275+
"userSelect": "none",
276+
"verticalAlign": "text-bottom",
277+
}
278+
}
279+
viewBox="0 0 16 16"
280+
width={16}
281+
/>
282+
</span>
283+
`;
284+
285+
exports[`StateLabel respects the status prop 4`] = `
286+
.c1 {
287+
margin-right: 4px;
288+
}
289+
234290
.c0 {
235291
display: -webkit-inline-box;
236292
display: -webkit-inline-flex;

0 commit comments

Comments
 (0)