Skip to content

Commit d13650e

Browse files
committed
chore: add copy badge button
1 parent a13807e commit d13650e

File tree

3 files changed

+56
-10
lines changed

3 files changed

+56
-10
lines changed

e2e-report/app/page.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
/* eslint-disable @next/next/no-img-element */
12
import Image from 'next/image'
23
import Table from '@/components/table'
34
import ComponentSwitcher from '@/components/switcher'
45
import StatsRow from '@/components/stats'
56
import testData from '@/utils/data'
7+
import { CopyIcon } from '@/components/icons'
8+
import CopyBadgeButton from '@/components/copy-badge'
69

710
export default function Home() {
811
// User can switch between two test suite tables: one with all non-empty suites,
@@ -25,16 +28,22 @@ export default function Home() {
2528

2629
function Header() {
2730
return (
28-
<div className="flex w-full items-center gap-4 bg-primary text-base-100 p-2 md:p-4 justify-center">
29-
<Image
30-
alt="netlify logo"
31-
src="/logo.svg"
32-
width={97}
33-
height={40}
34-
className="hidden md:block"
35-
/>
36-
<span className="md:text-lg font-bold uppercase">
37-
Next.js E2E Tests on Netlify Runtime v5
31+
<div className="flex w-full items-center gap-4 bg-primary text-base-100 p-2 md:p-4 justify-center md:justify-between">
32+
<span className="flex gap-4 items-center">
33+
<Image
34+
alt="netlify logo"
35+
src="/logo.svg"
36+
width={97}
37+
height={40}
38+
className="hidden md:block"
39+
/>
40+
<span className="md:text-lg font-bold">Next.js E2E Tests on Netlify Runtime v5</span>
41+
</span>
42+
<span className="hidden md:flex gap-2 items-center">
43+
<a href="/" target="_blank">
44+
<img src="/badge" width="200" height="30" alt="Netlify Next.js runtime v5 test status" />
45+
</a>
46+
<CopyBadgeButton />
3847
</span>
3948
</div>
4049
)

e2e-report/components/copy-badge.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use client'
2+
import { CopyIcon } from './icons'
3+
4+
const host = 'https://runtime-e2e-report.netlify.app' // fixed
5+
const badgeLink = `<a href="${host}/" target="_blank"><img src="${host}/badge" width="200" height="30" alt="Netlify Next.js runtime v5 test status" /></a>`
6+
7+
export default function CopyBadgeButton() {
8+
return (
9+
<button
10+
className="btn btn-xs btn-outline text-white rounded px-0.5"
11+
onClick={() => {
12+
navigator.clipboard.writeText(badgeLink)
13+
}}
14+
>
15+
<CopyIcon className="size-4" />
16+
</button>
17+
)
18+
}

e2e-report/components/icons.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,22 @@ export function GithubIcon({ className }) {
6464
</svg>
6565
)
6666
}
67+
68+
export function CopyIcon({ className }) {
69+
return (
70+
<svg
71+
xmlns="http://www.w3.org/2000/svg"
72+
fill="none"
73+
viewBox="0 0 24 24"
74+
strokeWidth={1.5}
75+
stroke="currentColor"
76+
className={className}
77+
>
78+
<path
79+
strokeLinecap="round"
80+
strokeLinejoin="round"
81+
d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z"
82+
/>
83+
</svg>
84+
)
85+
}

0 commit comments

Comments
 (0)