Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
fix: dark prose and stpg theme (#1484)
Maximilian Kaskedf2672935764
diff --git a/apps/dashboard/src/app/(dashboard)/overview/page.tsx b/apps/dashboard/src/app/(dashboard)/overview/page.tsxindex e1803381f..5f9172d39 100644--- a/apps/dashboard/src/app/(dashboard)/overview/page.tsx+++ b/apps/dashboard/src/app/(dashboard)/overview/page.tsx@@ -103,13 +103,17 @@ export default async function Page() {icon: List,},{- title: lastIncident?.resolvedAt ? "Recent Incident" : "Active Incident",+ title:+ lastIncident?.resolvedAt === undefined && lastIncident+ ? "Active Incident"+ : "Recent Incident",value: incidentDistance,disabled: !lastIncident?.monitorId,href: `/monitors/${lastIncident?.monitorId}/incidents`,- variant: lastIncident?.resolvedAt- ? ("default" as const)- : ("warning" as const),+ variant:+ lastIncident?.resolvedAt === undefined && lastIncident+ ? ("warning" as const)+ : ("default" as const),icon: Search,},{diff --git a/apps/dashboard/src/components/data-table/maintenances/columns.tsx b/apps/dashboard/src/components/data-table/maintenances/columns.tsxindex 07201803a..cb405916a 100644--- a/apps/dashboard/src/components/data-table/maintenances/columns.tsx+++ b/apps/dashboard/src/components/data-table/maintenances/columns.tsx@@ -16,6 +16,9 @@ export const columns: ColumnDef<Maintenance>[] = [header: "Title",enableSorting: false,enableHiding: false,+ meta: {+ cellClassName: "max-w-[200px] truncate",+ },},{accessorKey: "message",@@ -25,7 +28,7 @@ export const columns: ColumnDef<Maintenance>[] = [cell: ({ row }) => {const value = String(row.getValue("message"));return (- <div className="prose prose-sm line-clamp-3 max-w-[200px] truncate text-muted-foreground">+ <div className="prose dark:prose-invert prose-sm line-clamp-3 max-w-[200px] truncate text-muted-foreground"><ProcessMessage value={value} /></div>);diff --git a/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx b/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsxindex 1cbb98220..f0e18b894 100644--- a/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx+++ b/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx@@ -111,7 +111,7 @@ export function DataTable({</div></TableCell><TableCell>- <div className="prose prose-sm line-clamp-3 text-wrap">+ <div className="prose dark:prose-invert prose-sm line-clamp-3 text-wrap text-muted-foreground"><ProcessMessage value={update.message} /></div></TableCell>diff --git a/apps/dashboard/src/components/data-table/status-reports/columns.tsx b/apps/dashboard/src/components/data-table/status-reports/columns.tsxindex bfa205db1..1f6462461 100644--- a/apps/dashboard/src/components/data-table/status-reports/columns.tsx+++ b/apps/dashboard/src/components/data-table/status-reports/columns.tsx@@ -53,6 +53,9 @@ export const columns: ColumnDef<StatusReport>[] = [header: "Title",enableSorting: false,enableHiding: false,+ meta: {+ cellClassName: "max-w-[200px] truncate",+ },},{accessorKey: "status",diff --git a/apps/dashboard/src/components/forms/maintenance/form.tsx b/apps/dashboard/src/components/forms/maintenance/form.tsxindex af9c47c64..a3aeff075 100644--- a/apps/dashboard/src/components/forms/maintenance/form.tsx+++ b/apps/dashboard/src/components/forms/maintenance/form.tsx@@ -370,7 +370,7 @@ export function FormMaintenance({<TabsContent value="tab-2"><div className="grid gap-2"><Label>Preview</Label>- <div className="prose prose-sm rounded-md border px-3 py-2 text-foreground text-sm">+ <div className="prose dark:prose-invert prose-sm rounded-md border px-3 py-2 text-foreground text-sm"><ProcessMessage value={watchMessage} /></div></div>diff --git a/apps/dashboard/src/components/forms/status-report-update/form.tsx b/apps/dashboard/src/components/forms/status-report-update/form.tsxindex 592d1b484..217f16572 100644--- a/apps/dashboard/src/components/forms/status-report-update/form.tsx+++ b/apps/dashboard/src/components/forms/status-report-update/form.tsx@@ -278,7 +278,7 @@ export function FormStatusReportUpdate({<TabsContent value="tab-2"><div className="grid gap-2"><Label>Preview</Label>- <div className="prose prose-sm rounded-md border px-3 py-2 text-foreground text-sm">+ <div className="prose prose-sm dark:prose-invert rounded-md border px-3 py-2 text-foreground text-sm"><ProcessMessage value={watchMessage} /></div></div>diff --git a/apps/dashboard/src/components/forms/status-report/form.tsx b/apps/dashboard/src/components/forms/status-report/form.tsxindex 7d52f160b..3b11c3315 100644--- a/apps/dashboard/src/components/forms/status-report/form.tsx+++ b/apps/dashboard/src/components/forms/status-report/form.tsx@@ -317,7 +317,7 @@ export function FormStatusReport({<TabsContent value="tab-2"><div className="grid gap-2"><Label>Preview</Label>- <div className="prose prose-sm rounded-md border px-3 py-2 text-foreground text-sm">+ <div className="prose dark:prose-invert prose-sm rounded-md border px-3 py-2 text-foreground text-sm"><ProcessMessage value={watchMessage} /></div></div>diff --git a/apps/status-page/src/app/(public)/client.tsx b/apps/status-page/src/app/(public)/client.tsxindex e2b23a86a..e42ada4df 100644--- a/apps/status-page/src/app/(public)/client.tsx+++ b/apps/status-page/src/app/(public)/client.tsx@@ -23,6 +23,7 @@ import { ThemeSelect } from "@/components/themes/theme-select";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { Separator } from "@/components/ui/separator";+import { Skeleton } from "@/components/ui/skeleton";import {Tooltip,TooltipContent,@@ -32,7 +33,11 @@ import {import { monitors } from "@/data/monitors";import { useTRPC } from "@/lib/trpc/client";import { cn } from "@/lib/utils";-import { THEMES, THEME_KEYS } from "@openstatus/theme-store";+import {+ THEMES,+ THEME_KEYS,+ generateThemeStyles,+} from "@openstatus/theme-store";import { useQuery } from "@tanstack/react-query";import { useTheme } from "next-themes";import { useQueryStates } from "nuqs";@@ -61,21 +66,11 @@ export function Client() {}, []);useEffect(() => {- const theme = resolvedTheme as "dark" | "light";- if (["dark", "light"].includes(theme)) {- const element = document.documentElement;- element.removeAttribute("style"); // reset the style- Object.keys(THEMES[t][theme]).forEach((key) => {- const value =- THEMES[t][theme][- key as keyof (typeof THEMES)[typeof t][typeof theme]- ];- if (value) {- element.style.setProperty(key, value as string);- }- });+ const themeStyles = document.getElementById("theme-styles");+ if (t && themeStyles) {+ themeStyles.innerHTML = generateThemeStyles(t);}- }, [resolvedTheme, t]);+ }, [t]);return (<SectionGroup>@@ -133,6 +128,7 @@ export function Client() {const style = mounted? theme[resolvedTheme as "dark" | "light"]: undefined;+return (<li key={k} className="group/theme-card space-y-1.5"><div@@ -149,13 +145,17 @@ export function Client() {}}}>- <div- className="absolute h-full w-full bg-background text-foreground"- style={style as React.CSSProperties}- inert- >- <ThemePlaygroundMonitor className="pointer-events-none scale-80" />- </div>+ {mounted ? (+ <div+ className="absolute h-full w-full bg-background text-foreground"+ style={style as React.CSSProperties}+ inert+ >+ <ThemePlaygroundMonitor className="pointer-events-none scale-80" />+ </div>+ ) : (+ <Skeleton className="absolute h-full w-full" />+ )}</div><div className="flex items-start justify-between gap-2"><div className="space-y-0.5">@@ -178,6 +178,15 @@ export function Client() {const backgroundColor = style? style[color.key]: undefined;++ if (!mounted) {+ return (+ <Skeleton+ key={color.key}+ className="size-3.5 rounded-sm"+ />+ );+ }return (<TooltipProvider key={color.key}><Tooltip>diff --git a/apps/status-page/src/app/(public)/layout.tsx b/apps/status-page/src/app/(public)/layout.tsxindex 5bc06a6ff..3619b5734 100644--- a/apps/status-page/src/app/(public)/layout.tsx+++ b/apps/status-page/src/app/(public)/layout.tsx@@ -1,6 +1,7 @@import { Link } from "@/components/common/link";import { ThemeProvider } from "@/components/themes/theme-provider";import { Toaster } from "@/components/ui/sonner";+import { generateThemeStyles } from "@openstatus/theme-store";import PlausibleProvider from "next-plausible";export default async function Layout({@@ -10,6 +11,11 @@ export default async function Layout({}) {return (<PlausibleProvider domain="themes.openstatus.dev">+ <style+ id="theme-styles"+ // biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>+ dangerouslySetInnerHTML={{ __html: generateThemeStyles() }}+ /><ThemeProvider attribute="class" enableSystem disableTransitionOnChange><main>{children}</main><footer className="flex items-center justify-center gap-4 p-4 text-center font-mono text-muted-foreground text-sm">diff --git a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx b/apps/status-page/src/app/(status-page)/[domain]/layout.tsxindex 9c3b566d7..dcd0c22a2 100644--- a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx+++ b/apps/status-page/src/app/(status-page)/[domain]/layout.tsx@@ -7,6 +7,11 @@ import { FloatingTheme } from "@/components/status-page/floating-theme";import { ThemeProvider } from "@/components/themes/theme-provider";import { Toaster } from "@/components/ui/sonner";import { HydrateClient, getQueryClient, trpc } from "@/lib/trpc/server";+import {+ THEME_KEYS,+ type ThemeKey,+ generateThemeStyles,+} from "@openstatus/theme-store";import type { Metadata } from "next";import { notFound } from "next/navigation";import { z } from "zod";@@ -15,7 +20,7 @@ export const schema = z.object({value: z.enum(["duration", "requests", "manual"]).default("duration"),type: z.enum(["absolute", "manual"]).default("absolute"),uptime: z.coerce.boolean().default(true),- theme: z.enum(["default"]).default("default"),+ theme: z.enum(THEME_KEYS as [ThemeKey, ...ThemeKey[]]).default("default"),});export default async function Layout({@@ -32,9 +37,17 @@ export default async function Layout({);const validation = schema.safeParse(page?.configuration);+ const communityTheme = validation.data?.theme;return (<HydrateClient>+ <style+ id="theme-styles"+ // biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>+ dangerouslySetInnerHTML={{+ __html: generateThemeStyles(communityTheme),+ }}+ /><ThemeProviderattribute="class"defaultTheme={page?.forceTheme ?? "system"}diff --git a/apps/status-page/src/components/status-page/floating-button.tsx b/apps/status-page/src/components/status-page/floating-button.tsxindex 440a2e4d8..89320f74f 100644--- a/apps/status-page/src/components/status-page/floating-button.tsx+++ b/apps/status-page/src/components/status-page/floating-button.tsx@@ -25,9 +25,12 @@ import {} from "@/components/ui/select";import { Separator } from "@/components/ui/separator";import { cn } from "@/lib/utils";-import { THEMES, THEME_KEYS } from "@openstatus/theme-store";+import {+ THEMES,+ THEME_KEYS,+ generateThemeStyles,+} from "@openstatus/theme-store";import { Check, ChevronsUpDown, Settings } from "lucide-react";-import { useTheme } from "next-themes";import { parseAsString, useQueryState } from "nuqs";import type React from "react";import { createContext, useContext, useEffect, useState } from "react";@@ -46,8 +49,6 @@ export type BarType = (typeof BAR_TYPE)[number];export const COMMUNITY_THEME = THEME_KEYS;export type CommunityTheme = (typeof COMMUNITY_THEME)[number];-export const RADIUS = ["square", "rounded"] as const;-export type Radius = (typeof RADIUS)[number];interface StatusPageContextType {cardType: CardType;setCardType: (cardType: CardType) => void;@@ -57,8 +58,6 @@ interface StatusPageContextType {setShowUptime: (showUptime: boolean) => void;communityTheme: CommunityTheme;setCommunityTheme: (communityTheme: CommunityTheme) => void;- radius: Radius;- setRadius: (radius: Radius) => void;}const StatusPageContext = createContext<StatusPageContextType | null>(null);@@ -77,52 +76,26 @@ export function StatusPageProvider({defaultBarType = "absolute",defaultShowUptime = true,defaultCommunityTheme = "default",- defaultRadius = "square",}: {children: React.ReactNode;defaultCardType?: CardType;defaultBarType?: BarType;defaultShowUptime?: boolean;defaultCommunityTheme?: CommunityTheme;- defaultRadius?: Radius;}) {const [cardType, setCardType] = useState<CardType>(defaultCardType);const [barType, setBarType] = useState<BarType>(defaultBarType);const [showUptime, setShowUptime] = useState<boolean>(defaultShowUptime);- const [radius, setRadius] = useState<Radius>(defaultRadius);- const { resolvedTheme } = useTheme();const [communityTheme, setCommunityTheme] = useState<CommunityTheme>(defaultCommunityTheme,);useEffect(() => {- const theme = resolvedTheme as "dark" | "light";- if (["dark", "light"].includes(theme)) {- const element = document.documentElement;- element.removeAttribute("style"); // reset the style- Object.keys(THEMES[communityTheme][theme]).forEach((key) => {- const value =- THEMES[communityTheme][theme][- key as keyof (typeof THEMES)[typeof communityTheme][typeof theme]- ];- console.log(key, value);- if (value) {- element.style.setProperty(key, value as string);- }- });- }- }, [resolvedTheme, communityTheme]);-- useEffect(() => {- const computedRadius = getComputedStyle(- document.documentElement,- ).getPropertyValue("--radius");- if (radius === "square" && computedRadius !== "0rem") {- document.documentElement.style.setProperty("--radius", "0rem");- } else if (radius === "rounded" && computedRadius !== "0.625rem") {- document.documentElement.style.setProperty("--radius", "0.625rem");+ const themeStyles = document.getElementById("theme-styles");+ if (themeStyles) {+ themeStyles.innerHTML = generateThemeStyles(communityTheme);}- }, [radius]);+ }, [communityTheme]);return (<StatusPageContext.Provider@@ -135,21 +108,9 @@ export function StatusPageProvider({setShowUptime,communityTheme,setCommunityTheme,- radius,- setRadius,}}>- <div- style={- communityTheme- ? (THEMES[communityTheme][- resolvedTheme as "dark" | "light"- ] as React.CSSProperties)- : undefined- }- >- {children}- </div>+ {children}</StatusPageContext.Provider>);}@@ -172,8 +133,6 @@ export function FloatingButton({setShowUptime,communityTheme,setCommunityTheme,- radius,- setRadius,} = useStatusPage();const [display, setDisplay] = useState(false);const [configToken, setConfigToken] = useQueryState(@@ -294,26 +253,6 @@ export function FloatingButton({</SelectContent></Select></div>- {IS_DEV ? (- <div className="space-y-2">- <Label htmlFor="radius">Radius</Label>- <Select- value={radius}- onValueChange={(v) => setRadius(v as Radius)}- >- <SelectTrigger id="radius" className="w-full capitalize">- <SelectValue />- </SelectTrigger>- <SelectContent>- {RADIUS.map((v) => (- <SelectItem key={v} value={v} className="capitalize">- {v}- </SelectItem>- ))}- </SelectContent>- </Select>- </div>- ) : null}{IS_DEV ? (<div className="space-y-2"><Label htmlFor="theme">Theme</Label>diff --git a/packages/theme-store/src/index.ts b/packages/theme-store/src/index.tsindex ebecd49da..7ea73e9de 100644--- a/packages/theme-store/src/index.ts+++ b/packages/theme-store/src/index.ts@@ -19,3 +19,22 @@ export const THEMES = THEMES_LIST.reduce<ThemeMap>((acc, theme) => {export const THEME_KEYS = THEMES_LIST.map((theme) => theme.id);export type ThemeKey = (typeof THEME_KEYS)[number];++export function generateThemeStyles(themeKey: ThemeKey = "default") {+ const theme = THEMES[themeKey];+ const lightVars = Object.entries(theme.light)+ .map(([key, value]) => `${key}: ${value};`)+ .join("\n ");+ const darkVars = Object.entries(theme.dark)+ .map(([key, value]) => `${key}: ${value};`)+ .join("\n ");++ return `+ :root {+ ${lightVars}+ }+ .dark {+ ${darkVars}+ }+ `;+}