Skip to content

Open-source status page, incident response and uptime monitoring

🐛 fix badge size (#845)

Thibault Le Ouayf0f510840f50
diff --git a/apps/docs/synthetic/features/status-page.mdx b/apps/docs/synthetic/features/status-page.mdx
index 006497075..ba63920e8 100644
--- a/apps/docs/synthetic/features/status-page.mdx
+++ b/apps/docs/synthetic/features/status-page.mdx
@@ -38,3 +38,15 @@ If you want the dark version of the badge, you can use the following URL:
```html
<img src="https://YOUR-SLUG.openstatus.dev/badge?theme=dark" />
```
+
+You can also customize the size of the badge by adding a `size` parameter:
+
+- `sm
+- `md`
+- `lg`
+- `xl`
+
+
+```html
+<img src="https://YOUR-SLUG.openstatus.dev/badge?theme=dark&size=xl" />
+```
\ No newline at end of file
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index 54fc017d6..fe19b395d 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -33,6 +33,10 @@ const nextConfig = {
protocol: "https",
hostname: "screenshot.openstat.us",
},
+ {
+ protocol: "https",
+ hostname: "www.openstatus.dev",
+ },
],
},
};
diff --git a/apps/web/src/app/status-page/[domain]/badge/route.tsx b/apps/web/src/app/status-page/[domain]/badge/route.tsx
index 934479bc3..83beb18c1 100644
--- a/apps/web/src/app/status-page/[domain]/badge/route.tsx
+++ b/apps/web/src/app/status-page/[domain]/badge/route.tsx
@@ -36,30 +36,47 @@ const statusDictionary: Record<Status, { label: string; color: string }> = {
},
} as const;
-const SIZE = { width: 120, height: 34 };
-
+// const SIZE = { width: 120, height: 34 };
+const SIZE: Record<string, { width: number; height: number }> = {
+ sm: { width: 120, height: 34 },
+ md: { width: 160, height: 46 },
+ lg: { width: 200, height: 56 },
+ xl: { width: 240, height: 68 },
+};
export async function GET(
req: NextRequest,
- { params }: { params: { domain: string } },
+ { params }: { params: { domain: string } }
) {
const { status } = await getStatus(params.domain);
const theme = req.nextUrl.searchParams.get("theme");
-
+ const size = req.nextUrl.searchParams.get("size");
+ console.log(size);
+ let s = SIZE.sm;
+ if (size) {
+ if (SIZE[size]) {
+ s = SIZE[size];
+ }
+ }
const { label, color } = statusDictionary[status];
-
+ console.log(s);
const light = "border-gray-200 text-gray-700 bg-white";
const dark = "border-gray-800 text-gray-300 bg-gray-900";
return new ImageResponse(
- <div
- tw={`flex items-center justify-center rounded-md border px-3 py-1 text-sm ${
- theme === "dark" ? dark : light
- }`}
- style={{ ...SIZE }}
- >
- {label}
- <div tw={`flex h-2 w-2 rounded-full ml-2 ${color}`} />
- </div>,
- { ...SIZE },
+ (
+ <div
+ tw={`flex items-center justify-center rounded-md border px-3 py-1
+ ${size === "sm" && "text-sm"}${size === "md" && "text-md"} ${
+ size === "lg" && "text-lg"
+ } ${size === "xl" && "text-xl"} ${!size && "text-sm"} ${
+ theme === "dark" ? dark : light
+ }`}
+ style={{ ...s }}
+ >
+ {label}
+ <div tw={`flex h-2 w-2 rounded-full ml-2 ${color}`} />
+ </div>
+ ),
+ { ...s }
);
}
diff --git a/packages/api/src/router/invitation.ts b/packages/api/src/router/invitation.ts
index 96d26ae02..340dd51b2 100644
--- a/packages/api/src/router/invitation.ts
+++ b/packages/api/src/router/invitation.ts
@@ -72,10 +72,16 @@ export const invitationRouter = createTRPCRouter({
body: JSON.stringify({
to: email,
from: "OpenStatus <[email protected]>",
- subject: `You have been invited to join OpenStatus.dev`,
- html: `<p>You have been invited by ${opts.ctx.user.email} ${!!opts.ctx.workspace.name ? `to join the workspace '${opts.ctx.workspace.name}'.` : "to join a workspace."}</p>
+ subject: "You have been invited to join OpenStatus.dev",
+ html: `<p>You have been invited by ${opts.ctx.user.email} ${
+ opts.ctx.workspace.name
+ ? `to join the workspace '${opts.ctx.workspace.name}'.`
+ : "to join a workspace."
+ }</p>
<br>
- <p>Click here to access the workspace: <a href='https://openstatus.dev/app/invite?token=${_invitation.token}'>accept invitation</a>.</p>
+ <p>Click here to access the workspace: <a href='https://openstatus.dev/app/invite?token=${
+ _invitation.token
+ }'>accept invitation</a>.</p>
<p>If you don't have an account yet, it will require you to create one.</p>
`,
}),
diff --git a/packages/api/src/router/monitor.ts b/packages/api/src/router/monitor.ts
index 275e1e552..13ec400ed 100644
--- a/packages/api/src/router/monitor.ts
+++ b/packages/api/src/router/monitor.ts
@@ -41,7 +41,7 @@ export const monitorRouter = createTRPCRouter({
await opts.ctx.db.query.monitor.findMany({
where: and(
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
+ isNull(monitor.deletedAt)
),
})
).length;
@@ -104,7 +104,7 @@ export const monitorRouter = createTRPCRouter({
const allNotifications = await opts.ctx.db.query.notification.findMany({
where: and(
eq(notification.workspaceId, opts.ctx.workspace.id),
- inArray(notification.id, notifications),
+ inArray(notification.id, notifications)
),
});
@@ -120,7 +120,7 @@ export const monitorRouter = createTRPCRouter({
const allTags = await opts.ctx.db.query.monitorTag.findMany({
where: and(
eq(monitorTag.workspaceId, opts.ctx.workspace.id),
- inArray(monitorTag.id, tags),
+ inArray(monitorTag.id, tags)
),
});
@@ -136,7 +136,7 @@ export const monitorRouter = createTRPCRouter({
const allPages = await opts.ctx.db.query.page.findMany({
where: and(
eq(page.workspaceId, opts.ctx.workspace.id),
- inArray(page.id, pages),
+ inArray(page.id, pages)
),
});
@@ -163,7 +163,7 @@ export const monitorRouter = createTRPCRouter({
where: and(
eq(monitor.id, opts.input.id),
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
+ isNull(monitor.deletedAt)
),
with: {
monitorTagsToMonitors: { with: { monitorTag: true } },
@@ -199,7 +199,7 @@ export const monitorRouter = createTRPCRouter({
where: and(
eq(monitor.id, opts.input.id),
isNull(monitor.deletedAt),
- eq(monitor.public, true),
+ eq(monitor.public, true)
),
});
if (!_monitor) return undefined;
@@ -211,7 +211,7 @@ export const monitorRouter = createTRPCRouter({
});
const hasPageRelation = _page?.monitorsToPages.find(
- ({ monitorId }) => _monitor.id === monitorId,
+ ({ monitorId }) => _monitor.id === monitorId
);
if (!hasPageRelation) return undefined;
@@ -271,8 +271,8 @@ export const monitorRouter = createTRPCRouter({
and(
eq(monitor.id, opts.input.id),
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
- ),
+ isNull(monitor.deletedAt)
+ )
)
.returning()
.get();
@@ -287,7 +287,7 @@ export const monitorRouter = createTRPCRouter({
(x) =>
!currentMonitorNotifications
.map(({ notificationId }) => notificationId)
- ?.includes(x),
+ ?.includes(x)
);
if (addedNotifications.length > 0) {
@@ -311,9 +311,9 @@ export const monitorRouter = createTRPCRouter({
eq(notificationsToMonitors.monitorId, currentMonitor.id),
inArray(
notificationsToMonitors.notificationId,
- removedNotifications,
- ),
- ),
+ removedNotifications
+ )
+ )
)
.run();
}
@@ -328,7 +328,7 @@ export const monitorRouter = createTRPCRouter({
(x) =>
!currentMonitorTags
.map(({ monitorTagId }) => monitorTagId)
- ?.includes(x),
+ ?.includes(x)
);
if (addedTags.length > 0) {
@@ -350,8 +350,8 @@ export const monitorRouter = createTRPCRouter({
.where(
and(
eq(monitorTagsToMonitors.monitorId, currentMonitor.id),
- inArray(monitorTagsToMonitors.monitorTagId, removedTags),
- ),
+ inArray(monitorTagsToMonitors.monitorTagId, removedTags)
+ )
)
.run();
}
@@ -363,7 +363,7 @@ export const monitorRouter = createTRPCRouter({
.all();
const addedPages = pages.filter(
- (x) => !currentMonitorPages.map(({ pageId }) => pageId)?.includes(x),
+ (x) => !currentMonitorPages.map(({ pageId }) => pageId)?.includes(x)
);
if (addedPages.length > 0) {
@@ -385,8 +385,8 @@ export const monitorRouter = createTRPCRouter({
.where(
and(
eq(monitorsToPages.monitorId, currentMonitor.id),
- inArray(monitorsToPages.pageId, removedPages),
- ),
+ inArray(monitorsToPages.pageId, removedPages)
+ )
)
.run();
}
@@ -401,8 +401,8 @@ export const monitorRouter = createTRPCRouter({
.where(
and(
eq(monitor.id, opts.input.id),
- eq(monitor.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(monitor.workspaceId, opts.ctx.workspace.id)
+ )
)
.get();
if (!monitorToDelete) return;
@@ -433,7 +433,7 @@ export const monitorRouter = createTRPCRouter({
const monitors = await opts.ctx.db.query.monitor.findMany({
where: and(
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
+ isNull(monitor.deletedAt)
),
with: {
monitorTagsToMonitors: { with: { monitorTag: true } },
@@ -446,7 +446,7 @@ export const monitorRouter = createTRPCRouter({
monitorTagsToMonitors: z
.array(z.object({ monitorTag: selectMonitorTagSchema }))
.default([]),
- }),
+ })
)
.parse(monitors);
}),
@@ -461,8 +461,8 @@ export const monitorRouter = createTRPCRouter({
and(
eq(monitor.id, opts.input.id),
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
- ),
+ isNull(monitor.deletedAt)
+ )
)
.get();
@@ -481,8 +481,8 @@ export const monitorRouter = createTRPCRouter({
.where(
and(
eq(monitor.id, opts.input.id),
- eq(monitor.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(monitor.workspaceId, opts.ctx.workspace.id)
+ )
)
.run();
}),
@@ -510,8 +510,8 @@ export const monitorRouter = createTRPCRouter({
notification,
and(
eq(notificationsToMonitors.notificationId, notification.id),
- eq(notification.workspaceId, opts.ctx.workspace.id),
- ),
+ eq(notification.workspaceId, opts.ctx.workspace.id)
+ )
)
.where(eq(notificationsToMonitors.monitorId, opts.input.id))
.all();
@@ -524,7 +524,7 @@ export const monitorRouter = createTRPCRouter({
await opts.ctx.db.query.monitor.findMany({
where: and(
eq(monitor.workspaceId, opts.ctx.workspace.id),
- isNull(monitor.deletedAt),
+ isNull(monitor.deletedAt)
),
})
).length;