Openstatus www.openstatus.dev

chore: changelog and variant status badge v2 (#1316)

* chore: add changelog

* fix: dashboard sidebar badge

* chore: variant outline

* fix: border

* chore: update docs

authored by

Maximilian Kaske and committed by
GitHub
29205a45 dbac8cd4

+60 -12
+23 -8
apps/dashboard/src/app/(dashboard)/status-pages/[id]/sidebar.tsx
··· 10 10 TooltipProvider, 11 11 TooltipTrigger, 12 12 } from "@/components/ui/tooltip"; 13 + import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"; 13 14 import { useTRPC } from "@/lib/trpc/client"; 14 15 import { useQuery } from "@tanstack/react-query"; 15 16 import { ExternalLink } from "lucide-react"; 16 17 import { useParams } from "next/navigation"; 17 18 18 - // NOTE: 19 - const BADGE_URL = 20 - "https://openstatus.dev/status-page/hello-world/badge?size=sm&theme=light"; 21 - 22 19 export function Sidebar() { 23 20 const { id } = useParams<{ id: string }>(); 24 21 const trpc = useTRPC(); 25 22 const { data: statusPage } = useQuery( 26 23 trpc.page.get.queryOptions({ id: Number.parseInt(id) }), 27 24 ); 25 + const { copy } = useCopyToClipboard(); 28 26 29 27 if (!statusPage) return null; 28 + 29 + const BADGE_URL = `https://${statusPage.slug}.openstatus.dev/badge/v2`; 30 30 31 31 return ( 32 32 <SidebarRight ··· 39 39 label: "Slug", 40 40 value: ( 41 41 <Link 42 - href={`https://${statusPage.customDomain || `${statusPage.slug}.openstatus.dev`}`} 42 + href={`https://${ 43 + statusPage.customDomain || 44 + `${statusPage.slug}.openstatus.dev` 45 + }`} 43 46 target="_blank" 44 47 > 45 48 {statusPage.slug} ··· 63 66 <TooltipProvider> 64 67 <Tooltip> 65 68 <TooltipTrigger className="align-middle"> 66 - <img className="h-5" src={BADGE_URL} alt="badge" /> 69 + <img 70 + className="h-5 border rounded-sm" 71 + src={BADGE_URL} 72 + alt="badge" 73 + /> 67 74 </TooltipTrigger> 68 - <TooltipContent>Learn more about the badge.</TooltipContent> 75 + <TooltipContent 76 + className="cursor-pointer" 77 + side="left" 78 + onClick={() => copy(BADGE_URL, { withToast: true })} 79 + > 80 + {BADGE_URL} 81 + </TooltipContent> 69 82 </Tooltip> 70 83 </TooltipProvider> 71 84 ), ··· 111 124 onClick: () => 112 125 typeof window !== "undefined" && 113 126 window.open( 114 - `https://${statusPage.customDomain || `${statusPage.slug}.openstatus.dev`}`, 127 + `https://${ 128 + statusPage.customDomain || `${statusPage.slug}.openstatus.dev` 129 + }`, 115 130 "_blank", 116 131 ), 117 132 children: (
+8 -2
apps/docs/src/content/docs/tools/status-badge.mdx
··· 44 44 This will return a PNG image with the status of your page. It will look like this: 45 45 <img src='https://status.openstatus.dev/badge/v2' /> 46 46 47 - You can customize the theme by adding `?theme=dark` and the size of it by adding `?size=lg`. 47 + You can customize the theme by adding `?theme=dark`, the size of it by adding `?size=lg` and the variant `?variant=outline` - use what fits best to you! 48 48 49 49 Supported themes: 50 - - `dark` 51 50 - `light` (default) 51 + - `dark` 52 52 53 53 Supported sizes: 54 54 - `sm` (default) 55 55 - `md` 56 56 - `lg` 57 57 - `xl` 58 + 59 + Supported variants: 60 + - `default` (default) 61 + - `outline` 62 + 63 + The **outline** variant simply adds a slightly rounded border to the svg `rect`. It mainly can be used for GitHub README or Markdown where styling is not supported. 58 64 59 65 Compared to the PNG badge, we let you define the `border` and `border-radius` of the SVG badge and the font is mono. 60 66
apps/web/public/assets/changelog/status-page-badge-v2.png

This is a binary file and will not be displayed.

+5 -1
apps/web/src/app/status-page/[domain]/badge/v2/route.ts
··· 62 62 const params = await props.params; 63 63 const { status } = await getStatus(params.domain); 64 64 const theme = req.nextUrl.searchParams.get("theme") ?? "light"; 65 + const variant = req.nextUrl.searchParams.get("variant") ?? "default"; 65 66 const size = req.nextUrl.searchParams.get("size") ?? "sm"; 66 67 67 68 const { height, padding, gap, radius, fontSize } = SIZE[size] ?? SIZE.sm; ··· 71 72 72 73 const textColor = theme === "dark" ? "#d1d5db" : "#374151"; 73 74 const bgColor = theme === "dark" ? "#111827" : "#ffffff"; 75 + const borderColor = variant === "outline" ? "#d1d5db" : "transparent"; 74 76 75 77 const svg = ` 76 78 <svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"> 77 - <rect width="${width}" height="${height}" fill="${bgColor}"/> 79 + <rect x="0.5" y="0.5" width="${width - 1}" height="${ 80 + height - 1 81 + }" fill="${bgColor}" stroke="${borderColor}" stroke-width="1" rx="${radius}" ry="${radius}" /> 78 82 <text x="${padding}" y="50%" dominant-baseline="middle" 79 83 font-family="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace" font-size="${fontSize}" font-weight="600" fill="${textColor}"> 80 84 ${label}
+23
apps/web/src/content/changelog/status-page-badge-v2.mdx
··· 1 + --- 2 + title: Status Page Badge (v2) 3 + description: Easily integrate the status of your service everywhere. 4 + image: /assets/changelog/status-page-badge-v2.png 5 + publishedAt: 2025-08-16 6 + --- 7 + 8 + Until now, the badge was a PNG image. Now we provide an SVG instead to make it crystal clear. We are reducing the default style to a minimum. 9 + 10 + Just copy the following code and paste it into your website or GitHub README: 11 + 12 + ```html 13 + <img src="https://YOUR-SLUG.openstatus.dev/badge/v2" className="border rounded-md overflow-hidden" /> 14 + ``` 15 + 16 + And it will look like this: 17 + 18 + <a href="https://status.openstatus.dev"> 19 + <img src="https://status.openstatus.dev/badge/v2" /> 20 + </a> 21 + 22 + 23 + Read more in our [documentation](https://docs.openstatus.dev/tools/status-badge/#svg-badge-v2).
+1 -1
apps/web/src/content/changelog/status-page-badge.mdx
··· 1 1 --- 2 - title: Status Page SVG Badge 2 + title: Status Page Badge 3 3 description: Easily integrate the status of your service everywhere. 4 4 image: /assets/changelog/status-page-badge.jpeg 5 5 publishedAt: 2024-05-02