Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-tabs": "^1.1.12",
"@radix-ui/react-tooltip": "1.2.7",
"@scalar/api-reference-react": "^0.7.42",
"@tanstack/react-query": "5.81.5",
"@tryghost/content-api": "^1.11.28",
"class-variance-authority": "^0.7.1",
Expand Down
8 changes: 6 additions & 2 deletions apps/portal/src/app/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const links = [
href: "/insight",
name: "Insight",
},
{
href: "/reference",
name: "API Reference",
},
];

const toolLinks = [
Expand Down Expand Up @@ -281,7 +285,7 @@ export function Header() {
}}
>
<NavLink href={link.href} name={link.name} />
{pathname.startsWith(link.href) && (
{pathname?.startsWith(link.href) && (
<div className="bg-violet-700 h-[2px] inset-x-0 rounded-full absolute -bottom-1" />
)}
</li>
Expand Down Expand Up @@ -526,7 +530,7 @@ function NavLink(props: {
<Link
className={clsx(
"font-medium text-base transition-colors hover:text-foreground xl:text-sm",
pathname.startsWith(props.href)
pathname?.startsWith(props.href)
? "text-foreground"
: "text-muted-foreground",
props.icon ? "flex flex-row gap-3" : "",
Expand Down
37 changes: 37 additions & 0 deletions apps/portal/src/app/reference/ScalarClient.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use client";

import { ApiReferenceReact } from "@scalar/api-reference-react";
import "@scalar/api-reference-react/style.css";
import "./scalar.css";
import { useTheme } from "next-themes";
import { useEffect } from "react";

Comment thread
MananTank marked this conversation as resolved.
export function ScalarApiReference() {
const { theme } = useTheme();

// scaler is using light-mode and dark-mode classes for theming
useEffect(() => {
if (theme === "dark") {
document.body.classList.remove("light-mode");
document.body.classList.add("dark-mode");
} else {
document.body.classList.remove("dark-mode");
document.body.classList.add("light-mode");
}
}, [theme]);
Comment thread
MananTank marked this conversation as resolved.

return (
<ApiReferenceReact
configuration={{
url: "https://api.thirdweb.com/openapi.json",
theme: "deepSpace",
layout: "modern",
showSidebar: true,
hideModels: false,
hideDarkModeToggle: true, // Hide since portal controls theme
hideDownloadButton: false,
hideTestRequestButton: false,
}}
/>
);
}
19 changes: 19 additions & 0 deletions apps/portal/src/app/reference/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createMetadata } from "@/components/Document";
import { ScalarApiReference } from "./ScalarClient";

export const metadata = createMetadata({
image: {
title: "API Reference",
icon: "thirdweb",
},
title: "thirdweb API Reference",
description: "Complete REST API reference for all thirdweb services",
});

export default function ApiReferencePage() {
return (
<div className="container max-sm:px-0">
<ScalarApiReference />
</div>
);
}
Comment thread
MananTank marked this conversation as resolved.
15 changes: 15 additions & 0 deletions apps/portal/src/app/reference/scalar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.scalar-app {
--scalar-background-1: hsl(var(--background));
--scalar-background-2: hsl(var(--card));
}

/* fixes sticky sidebar and header on mobile */
.scalar-app .references-navigation-list,
.scalar-app .references-header {
position: sticky;
top: var(--sticky-top-height);
}

.scalar-app .references-navigation-list {
height: calc(100vh - var(--sticky-top-height));
}
Loading
Loading