diff --git a/demo/docs/advanced.mdx b/demo/docs/advanced.mdx index 1dafe0f44..0b063eca9 100644 --- a/demo/docs/advanced.mdx +++ b/demo/docs/advanced.mdx @@ -55,4 +55,4 @@ import BrowserWindow from '@site/src/components/BrowserWindow'; -``` \ No newline at end of file +``` diff --git a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts index 1927d6c86..e09c57570 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts +++ b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts @@ -279,6 +279,14 @@ declare module "@theme/ApiExplorer/ApiCodeBlock" { export default function ApiCodeBlock(): JSX.Element; } +declare module "@theme/ApiExplorer/DemoExpandButton" { + import { Props as DemoExpandButtonProps } from "@theme/ApiExplorer/DemoExpandButton"; + + export default function DemoExpandButton( + props: DemoExpandButtonProps + ): JSX.Element; +} + declare module "@theme/ApiExplorer/Server/slice" { export default server as Reducer; } diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/DemoExpandButton/_DemoExpandButton.scss b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/DemoExpandButton/_DemoExpandButton.scss new file mode 100644 index 000000000..9a5e2758e --- /dev/null +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/DemoExpandButton/_DemoExpandButton.scss @@ -0,0 +1,19 @@ +.openapi-explorer__demo-expand-modal-content { + padding: none; + border: thin solid var(--ifm-toc-border-color); + border-radius: var(--ifm-global-radius); + max-width: 95%; + width: 70vw; + height: 80vh; + overflow: auto; +} + +.openapi-explorer__demo-expand-modal-overlay { + display: flex; + align-items: center; + justify-content: center; + position: fixed; + inset: 0px; + background-color: rgba(0, 0, 0, 0.9); + z-index: 201; +} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/DemoExpandButton/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/DemoExpandButton/index.tsx new file mode 100644 index 000000000..faa43aa43 --- /dev/null +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/DemoExpandButton/index.tsx @@ -0,0 +1,94 @@ +/* ========================================================================== + * Copyright (c) Palo Alto Networks + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * ========================================================================== */ + +import React, { useEffect, useState } from "react"; + +import { translate } from "@docusaurus/Translate"; +import ExitButton from "@theme/ApiExplorer/ApiCodeBlock/ExitButton"; +import Request from "@theme/ApiExplorer/Request"; +import Response from "@theme/ApiExplorer/Response"; +import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types"; +import clsx from "clsx"; +import Modal from "react-modal"; + +export interface Props { + readonly item: NonNullable; + readonly className?: string; +} + +export default function DemoExpandButton({ + item, + className, +}: Props): React.JSX.Element { + const [isModalOpen, setIsModalOpen] = useState(false); + + useEffect(() => { + Modal.setAppElement("body"); + }, []); + + return ( + <> + + setIsModalOpen(false)} + contentLabel="API Demo" + > +
+ + +
+ setIsModalOpen(false)} + /> +
+
+
+ + ); +} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx index 30f7bcc69..43abfa601 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/index.tsx @@ -30,6 +30,7 @@ import * as sdk from "postman-collection"; import { FormProvider, useForm } from "react-hook-form"; import makeRequest from "./makeRequest"; +import DemoExpandButton from "@theme/ApiExplorer/DemoExpandButton"; function Request({ item }: { item: ApiItem }) { const postman = new sdk.Request(item.postman); @@ -194,6 +195,10 @@ function Request({ item }: { item: ApiItem }) { Expand all )} +
{showServerOptions && item.method !== "event" && ( diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/styles.scss b/packages/docusaurus-theme-openapi-docs/src/theme/styles.scss index 5e0933346..0ccd3edec 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/styles.scss +++ b/packages/docusaurus-theme-openapi-docs/src/theme/styles.scss @@ -17,6 +17,7 @@ @use "./ApiExplorer/ParamOptions/ParamOptions"; @use "./ApiExplorer/Request/Request"; @use "./ApiExplorer/Response/Response"; +@use "./ApiExplorer/DemoExpandButton/DemoExpandButton"; @use "./ApiExplorer/Server/Server"; /* Api Demo Panel / ApiCodeBlock */