Openstatus
www.openstatus.dev
1export const statusCodes = [
2 {
3 code: 200 as const,
4 bg: "bg-success",
5 text: "text-success",
6 name: "OK",
7 },
8 {
9 code: 500 as const,
10 bg: "bg-destructive",
11 text: "text-destructive",
12 name: "Internal Server Error",
13 },
14];
15
16export type StatusCode = (typeof statusCodes)[number]["code"];
17
18export const getStatusCodeVariant = (code?: number | null) => {
19 if (!code) return "muted";
20 if (code.toString().startsWith("2")) return "success";
21 if (code.toString().startsWith("3")) return "info";
22 if (code.toString().startsWith("4")) return "warning";
23 if (code.toString().startsWith("5")) return "destructive";
24 return "muted";
25};
26
27export const bgColors = {
28 success: "bg-success",
29 info: "bg-info",
30 warning: "bg-warning",
31 destructive: "bg-destructive",
32 muted: "bg-muted",
33};
34
35export const textColors = {
36 success: "text-success",
37 info: "text-info",
38 warning: "text-warning",
39 destructive: "text-destructive",
40 muted: "text-muted-foreground",
41};