Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add openstatus widget

Marc Seitz690813d4d0c0
diff --git a/components/web/footer.tsx b/components/web/footer.tsx
index 6368ac35..93518662 100644
--- a/components/web/footer.tsx
+++ b/components/web/footer.tsx
@@ -1,6 +1,7 @@
import GitHubIcon from "@/components/shared/icons/github";
import TwitterIcon from "@/components/shared/icons/twitter";
import LinkedinIcon from "@/components/shared/icons/linkedin";
+import { StatusWidget } from "./status-widget";
const navigation = {
product: [
@@ -88,6 +89,9 @@ export default function Footer() {
</a>
))}
</div>
+ <div className="w-fit">
+ <StatusWidget />
+ </div>
</div>
<div className="mt-16 grid grid-cols-2 gap-8 xl:col-span-2 xl:mt-0">
<div className="md:grid md:grid-cols-2 md:gap-8">
diff --git a/components/web/status-widget.tsx b/components/web/status-widget.tsx
new file mode 100644
index 00000000..4c28a5ea
--- /dev/null
+++ b/components/web/status-widget.tsx
@@ -0,0 +1,97 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+import { getStatus } from "@openstatus/react";
+import { useEffect, useState } from "react";
+
+export function StatusWidget() {
+ const [status, setStatus] = useState("operational");
+
+ useEffect(() => {
+ async function fetchData() {
+ try {
+ const response = await getStatus("papermark");
+
+ if (response) {
+ setStatus(response.status);
+ }
+ } catch {}
+ }
+
+ fetchData();
+ }, []);
+
+ const getStatusLevel = (level: string) => {
+ return {
+ operational: {
+ label: "All Systems Operational",
+ color: "bg-green-500",
+ color2: "bg-green-400",
+ },
+ degraded_performance: {
+ label: "Degraded Performance",
+ color: "bg-yellow-500",
+ color2: "bg-yellow-400",
+ },
+ partial_outage: {
+ label: "Partial Outage",
+ color: "bg-yellow-500",
+ color2: "bg-yellow-400",
+ },
+ major_outage: {
+ label: "Major Outage",
+ color: "bg-red-500",
+ color2: "bg-red-400",
+ },
+ unknown: {
+ label: "Unknown",
+ color: "bg-gray-500",
+ color2: "bg-gray-400",
+ },
+ incident: {
+ label: "Incident",
+ color: "bg-yellow-500",
+ color2: "bg-yellow-400",
+ },
+ under_maintenance: {
+ label: "Under Maintenance",
+ color: "bg-gray-500",
+ color2: "bg-gray-400",
+ },
+ }[level];
+ };
+
+ const level = getStatusLevel(status);
+
+ if (!level) {
+ return null;
+ }
+
+ return (
+ <a
+ className="flex justify-between space-x-2 items-center w-full border border-border rounded-md px-3 py-1"
+ href="https://papermark.openstatus.dev"
+ target="_blank"
+ rel="noreferrer"
+ >
+ <div>
+ <p className="text-sm">{level.label}</p>
+ </div>
+
+ <span className="relative ml-auto flex h-2 w-2">
+ <span
+ className={cn(
+ "animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",
+ level.color2,
+ )}
+ />
+ <span
+ className={cn(
+ "relative inline-flex rounded-full h-2 w-2",
+ level.color,
+ )}
+ />
+ </span>
+ </a>
+ );
+}
diff --git a/package-lock.json b/package-lock.json
index 04671270..421364c9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,6 +20,7 @@
"@mdx-js/react": "^3.0.1",
"@next-auth/prisma-adapter": "^1.0.7",
"@next/mdx": "^14.2.0",
+ "@openstatus/react": "^0.0.3",
"@prisma/client": "^5.12.1",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
@@ -2135,6 +2136,14 @@
"resolved": "https://registry.npmjs.org/@one-ini/wasm/-/wasm-0.1.1.tgz",
"integrity": "sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw=="
},
+ "node_modules/@openstatus/react": {
+ "version": "0.0.3",
+ "resolved": "https://registry.npmjs.org/@openstatus/react/-/react-0.0.3.tgz",
+ "integrity": "sha512-uDiegz7e3H67pG8lTT+op+6w5keTT7XpcENrREaqlWl5j53TYyO8nheOG1PeNw2/Qgd5KaGeRJJFn1crhTUSYw==",
+ "peerDependencies": {
+ "react": "^18.0.0"
+ }
+ },
"node_modules/@panva/hkdf": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.1.1.tgz",
diff --git a/package.json b/package.json
index d88585cc..f9399866 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
"@mdx-js/react": "^3.0.1",
"@next-auth/prisma-adapter": "^1.0.7",
"@next/mdx": "^14.2.0",
+ "@openstatus/react": "^0.0.3",
"@prisma/client": "^5.12.1",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",