Skip to content

Commit 6221a6b

Browse files
committed
chore: badge - consts, smaller, get host name
1 parent d13650e commit 6221a6b

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

e2e-report/app/badge/route.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ImageResponse } from 'next/og'
22
import testData from '@/utils/data'
3+
import { badgeSettings, badgeSize } from '@/utils/consts'
34

45
export const dynamic = 'force-static'
56

@@ -21,21 +22,20 @@ export async function GET(request) {
2122

2223
const badge = (
2324
<Badge
24-
label="Next.js runtime v5"
25+
label={badgeSettings.label}
2526
labelStyle={labelStyle}
2627
value={testData.nextVersion}
2728
valueStyle={valueStyle}
2829
/>
2930
)
3031
return new ImageResponse(badge, {
31-
width: 400,
32-
height: 60,
32+
...badgeSettings.imageSize,
3333
})
3434
}
3535

3636
function Badge({ label, labelStyle, value, valueStyle }) {
3737
return (
38-
<div tw="flex items-center w-full h-full text-[28px] rounded-md overflow-hidden bg-transparent">
38+
<div tw="flex items-center w-full h-full text-[26px] rounded-md overflow-hidden bg-transparent">
3939
<span tw="items-center h-full p-3.5" style={labelStyle}>
4040
{label}
4141
</span>

e2e-report/app/page.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import StatsRow from '@/components/stats'
66
import testData from '@/utils/data'
77
import { CopyIcon } from '@/components/icons'
88
import CopyBadgeButton from '@/components/copy-badge'
9+
import { badgeSettings } from '@/utils/consts'
910

1011
export default function Home() {
1112
// User can switch between two test suite tables: one with all non-empty suites,
@@ -41,7 +42,12 @@ function Header() {
4142
</span>
4243
<span className="hidden md:flex gap-2 items-center">
4344
<a href="/" target="_blank">
44-
<img src="/badge" width="200" height="30" alt="Netlify Next.js runtime v5 test status" />
45+
<img
46+
src="/badge"
47+
width={badgeSettings.displaySize.width}
48+
height={badgeSettings.displaySize.height}
49+
alt={badgeSettings.alt}
50+
/>
4551
</a>
4652
<CopyBadgeButton />
4753
</span>

e2e-report/components/copy-badge.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
'use client'
2+
import { useEffect, useState } from 'react'
23
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>`
4+
import { badgeDisplaySize, badgeSettings } from '@/utils/consts'
65

76
export default function CopyBadgeButton() {
7+
const [host, setHost] = useState('')
8+
useEffect(() => {
9+
setHost(window?.location.origin || '')
10+
}, [])
11+
12+
const badgeLink = `
13+
<a href="${host}/" target="_blank">
14+
<img
15+
src="${host}/badge"
16+
width="${badgeSettings.displaySize.width}"
17+
height="${badgeSettings.displaySize.height}"
18+
alt="${badgeSettings.alt}"
19+
/>
20+
</a>`
21+
822
return (
923
<button
1024
className="btn btn-xs btn-outline text-white rounded px-0.5"

e2e-report/utils/consts.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const badgeSettings = {
2+
// Badge image resolution should be 2x display size for hi-res displays
3+
imageSize: { width: 370, height: 50 },
4+
displaySize: { width: 185, height: 25 },
5+
label: 'Next.js runtime v5',
6+
alt: 'Netlify Next.js runtime v5 test status',
7+
}

0 commit comments

Comments
 (0)