/* ============================================================================ * 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 { usePrismTheme } from "@docusaurus/theme-common"; import { translate } from "@docusaurus/Translate"; import Container from "@theme/ApiExplorer/ApiCodeBlock/Container"; import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton"; import ExitButton from "@theme/ApiExplorer/ApiCodeBlock/ExitButton"; import Line from "@theme/ApiExplorer/ApiCodeBlock/Line"; import clsx from "clsx"; import { Highlight, Language } from "prism-react-renderer"; import Modal from "react-modal"; export interface Props { readonly code: string; readonly className: string; readonly language: Language; readonly showLineNumbers: boolean; readonly blockClassName: string; readonly title: string | undefined; readonly lineClassNames: { [lineIndex: number]: string[] }; } export default function ExpandButton({ code, className, language, showLineNumbers, blockClassName, title, lineClassNames, }: Props): React.JSX.Element { const [isModalOpen, setIsModalOpen] = useState(false); const prismTheme = usePrismTheme(); useEffect(() => { Modal.setAppElement("body"); }, []); return ( <> setIsModalOpen(false)} contentLabel="Code Snippet" > {title && (
{title}
)}
{({ className, tokens, getLineProps, getTokenProps }) => (
                  
                    {tokens.map((line, i) => (
                      
                    ))}
                  
                
)}
setIsModalOpen(false)} />
); }