Skip to content

Commit 16370d4

Browse files
committed
Standardize the "link out of the popup" component.
1 parent a0912d5 commit 16370d4

File tree

6 files changed

+43
-44
lines changed

6 files changed

+43
-44
lines changed

src/components/LinkOutOfPopup.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Link that opens outside of the popup
2+
export function LinkOutOfPopup(
3+
props: React.AnchorHTMLAttributes<HTMLAnchorElement>
4+
) {
5+
return (
6+
<a
7+
{...props}
8+
target="_blank"
9+
rel="noopener noreferrer"
10+
className="truncate hover:underline"
11+
>
12+
{props.children}
13+
</a>
14+
)
15+
}

src/lib/enhancers/github/GitHubIssueAppendEnhancer.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IssueOpenedIcon } from "@primer/octicons-react"
22
import OverType, { type OverTypeInstance } from "overtype"
33
import type React from "react"
4+
import { LinkOutOfPopup } from "@/components/LinkOutOfPopup"
45
import type {
56
CommentEnhancer,
67
CommentSpot,
@@ -92,12 +93,9 @@ export class GitHubIssueAppendEnhancer
9293
</span>
9394
<span>
9495
#{spot.number}{" "}
95-
<a
96-
href={`https://${spot.domain}/${spot.slug}`}
97-
className="truncate hover:underline"
98-
>
96+
<LinkOutOfPopup href={`https://${spot.domain}/${spot.slug}`}>
9997
{spot.slug}
100-
</a>
98+
</LinkOutOfPopup>
10199
</span>
102100
</>
103101
)

src/lib/enhancers/github/GitHubIssueCreateEnhancer.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IssueOpenedIcon } from "@primer/octicons-react"
22
import OverType, { type OverTypeInstance } from "overtype"
3+
import { LinkOutOfPopup } from "@/components/LinkOutOfPopup"
34
import type {
45
CommentEnhancer,
56
CommentSpot,
@@ -82,12 +83,9 @@ export class GitHubIssueCreateEnhancer
8283
</span>
8384
<span>
8485
&lt;draft&gt;{" "}
85-
<a
86-
href={`https://${spot.domain}/${spot.slug}`}
87-
className="truncate hover:underline"
88-
>
86+
<LinkOutOfPopup href={`https://${spot.domain}/${spot.slug}`}>
8987
{spot.slug}
90-
</a>
88+
</LinkOutOfPopup>
9189
</span>
9290
</>
9391
)

src/lib/enhancers/github/GitHubPrAppendEnhancer.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GitPullRequestIcon } from "@primer/octicons-react"
22
import OverType, { type OverTypeInstance } from "overtype"
33
import type React from "react"
4+
import { LinkOutOfPopup } from "@/components/LinkOutOfPopup"
45
import type {
56
CommentEnhancer,
67
CommentSpot,
@@ -91,12 +92,9 @@ export class GitHubPrAppendEnhancer
9192
</span>
9293
<span>
9394
#{spot.number}{" "}
94-
<a
95-
href={`https://${spot.domain}/${spot.slug}`}
96-
className="truncate hover:underline"
97-
>
95+
<LinkOutOfPopup href={`https://${spot.domain}/${spot.slug}`}>
9896
{spot.slug}
99-
</a>
97+
</LinkOutOfPopup>
10098
</span>
10199
</>
102100
)

src/lib/enhancers/github/GitHubPrCreateEnhancer.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { GitPullRequestIcon } from "@primer/octicons-react"
22
import OverType, { type OverTypeInstance } from "overtype"
3+
import { LinkOutOfPopup } from "@/components/LinkOutOfPopup"
34
import type {
45
CommentEnhancer,
56
CommentSpot,
@@ -97,12 +98,9 @@ export class GitHubPrCreateEnhancer
9798
</span>
9899
<span>
99100
&lt;draft&gt;{" "}
100-
<a
101-
href={`https://${spot.domain}/${spot.slug}`}
102-
className="truncate hover:underline"
103-
>
101+
<LinkOutOfPopup href={`https://${spot.domain}/${spot.slug}`}>
104102
{spot.slug}
105-
</a>
103+
</LinkOutOfPopup>
106104
</span>
107105
</>
108106
)

tests/lib/enhancers/__snapshots__/gh-ui.test.ts.snap

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ exports[`github ui > gh_issue:should render correct UI elements 1`] = `
1717
#
1818
523
1919
20-
<a
21-
className="truncate hover:underline"
20+
<LinkOutOfPopup
2221
href="https://github.com/diffplug/selfie"
2322
>
2423
diffplug/selfie
25-
</a>
24+
</LinkOutOfPopup>
2625
</span>
2726
</React.Fragment>,
2827
},
@@ -53,12 +52,11 @@ exports[`github ui > gh_issue_edit:should render correct UI elements 1`] = `
5352
#
5453
56
5554
56-
<a
57-
className="truncate hover:underline"
55+
<LinkOutOfPopup
5856
href="https://github.com/diffplug/gitcasso"
5957
>
6058
diffplug/gitcasso
61-
</a>
59+
</LinkOutOfPopup>
6260
</span>
6361
</React.Fragment>,
6462
},
@@ -96,12 +94,11 @@ exports[`github ui > gh_issue_edit_multiple:should render correct UI elements 1`
9694
#
9795
3
9896
99-
<a
100-
className="truncate hover:underline"
97+
<LinkOutOfPopup
10198
href="https://github.com/diffplug/testing-deletable"
10299
>
103100
diffplug/testing-deletable
104-
</a>
101+
</LinkOutOfPopup>
105102
</span>
106103
</React.Fragment>,
107104
},
@@ -124,12 +121,11 @@ exports[`github ui > gh_issue_new:should render correct UI elements 1`] = `
124121
<span>
125122
&lt;draft&gt;
126123
127-
<a
128-
className="truncate hover:underline"
124+
<LinkOutOfPopup
129125
href="https://github.com/diffplug/gitcasso"
130126
>
131127
diffplug/gitcasso
132-
</a>
128+
</LinkOutOfPopup>
133129
</span>
134130
</React.Fragment>,
135131
},
@@ -156,12 +152,11 @@ exports[`github ui > gh_pr:should render correct UI elements 1`] = `
156152
#
157153
517
158154
159-
<a
160-
className="truncate hover:underline"
155+
<LinkOutOfPopup
161156
href="https://github.com/diffplug/selfie"
162157
>
163158
diffplug/selfie
164-
</a>
159+
</LinkOutOfPopup>
165160
</span>
166161
</React.Fragment>,
167162
},
@@ -194,12 +189,11 @@ exports[`github ui > gh_pr_edit:should render correct UI elements 1`] = `
194189
#
195190
58
196191
197-
<a
198-
className="truncate hover:underline"
192+
<LinkOutOfPopup
199193
href="https://github.com/diffplug/gitcasso"
200194
>
201195
diffplug/gitcasso
202-
</a>
196+
</LinkOutOfPopup>
203197
</span>
204198
</React.Fragment>,
205199
},
@@ -238,12 +232,11 @@ exports[`github ui > gh_pr_edit_multiple:should render correct UI elements 1`] =
238232
#
239233
5
240234
241-
<a
242-
className="truncate hover:underline"
235+
<LinkOutOfPopup
243236
href="https://github.com/diffplug/testing-deletable"
244237
>
245238
diffplug/testing-deletable
246-
</a>
239+
</LinkOutOfPopup>
247240
</span>
248241
</React.Fragment>,
249242
},
@@ -266,12 +259,11 @@ exports[`github ui > gh_pr_new:should render correct UI elements 1`] = `
266259
<span>
267260
&lt;draft&gt;
268261
269-
<a
270-
className="truncate hover:underline"
262+
<LinkOutOfPopup
271263
href="https://github.com/diffplug/selfie"
272264
>
273265
diffplug/selfie
274-
</a>
266+
</LinkOutOfPopup>
275267
</span>
276268
</React.Fragment>,
277269
},

0 commit comments

Comments
 (0)