diff --git a/app/docs/styles.css b/app/docs/styles.css index 46e5b155bdb..9c7342280d2 100644 --- a/app/docs/styles.css +++ b/app/docs/styles.css @@ -445,3 +445,7 @@ aside[aria-label*="On this page" i] > div:first-child, } } +/* Add extra horizontal padding to the first button in response tablist */ +div [role="tablist"] button:first-child { + padding-left: 0.5rem !important; +} diff --git a/components/api/api-open-body.client.tsx b/components/api/api-open-body.client.tsx new file mode 100644 index 00000000000..c300e54a60e --- /dev/null +++ b/components/api/api-open-body.client.tsx @@ -0,0 +1,26 @@ +"use client"; +import { useEffect } from "react"; + +// automatically open the Body section on OpenAPI pages +export function OpenBodySection() { + useEffect(() => { + const openBodySection = () => { + const buttons = Array.from(document.querySelectorAll("button")); + + buttons.forEach((button) => { + if ( + button.textContent?.trim().startsWith("Body") && + button.getAttribute("data-state") === "closed" + ) { + button.click(); + } + }); + }; + + openBodySection(); + const timer = setTimeout(openBodySection, 100); + return () => clearTimeout(timer); + }, []); + + return null; +} diff --git a/components/api/api-pages.tsx b/components/api/api-pages.tsx index 152a35c3927..3d3bc3c147e 100644 --- a/components/api/api-pages.tsx +++ b/components/api/api-pages.tsx @@ -5,6 +5,7 @@ import metricsApiClient from './metrics-api-page.client'; import pchainApiClient from './pchain-api-page.client'; import cchainApiClient from './cchain-api-page.client'; import xchainApiClient from './xchain-api-page.client'; +import { OpenBodySection } from "./api-open-body.client"; const DataAPIPageBase = createAPIPage(dataApi, { client: dataApiClient, @@ -13,6 +14,7 @@ const DataAPIPageBase = createAPIPage(dataApi, { export function DataAPIPage(props: any) { return (