Skip to content

Commit

Permalink
last ditch open api effort
Browse files Browse the repository at this point in the history
  • Loading branch information
mayaraman19 committed Apr 22, 2024
1 parent 61ff525 commit a142896
Showing 1 changed file with 5 additions and 33 deletions.
38 changes: 5 additions & 33 deletions src/components/OpenAPI/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useState, useEffect } from 'react';
import { render } from 'react-dom';
import PropTypes from 'prop-types';
import { RedocStandalone } from 'redoc';
import { Global, css } from '@emotion/react';
import styled from '@emotion/styled';
import { palette } from '@leafygreen-ui/palette';
import { createRoot } from 'react-dom/client';
import ComponentFactory from '../ComponentFactory';
import { SidenavBackButton } from '../Sidenav';
import Spinner from '../Spinner';
import { useSiteMetadata } from '../../hooks/use-site-metadata';
import useStickyTopValues from '../../hooks/useStickyTopValues';
import { isBrowser } from '../../utils/is-browser';
import { theme } from '../../theme/docsTheme';
import { getPlaintext } from '../../utils/get-plaintext';
import { fetchOASFile } from '../../utils/realm';
import DocsHomeButton from '../Sidenav/DocsHomeButton';
import { isLinkInWhitelist, WhitelistErrorCallout } from './whitelist';
import {
codeBlockCss,
Expand Down Expand Up @@ -91,13 +91,6 @@ const getGlobalCss = ({ topLarge, topMedium }) => css`
}
`;

const Border = styled('hr')`
border: unset;
border-bottom: 1px solid ${palette.gray.light2};
margin: ${theme.size.default} 0;
width: 100%;
`;

const LoadingContainer = styled('div')`
align-items: center;
display: flex;
Expand All @@ -110,15 +103,6 @@ const LoadingMessage = styled('div')`
margin-bottom: ${theme.size.small};
`;

const MenuTitle = styled('div')`
color: ${palette.gray.dark3};
font-size: ${theme.fontSize.small};
font-weight: bold;
line-height: 20px;
margin: ${theme.size.medium} ${theme.size.default};
text-transform: capitalize;
`;

const JustifiedWhitelistWarning = styled(WhitelistErrorCallout)`
margin: 20px auto;
max-width: 840px;
Expand All @@ -131,18 +115,6 @@ const LoadingWidget = ({ className }) => (
</LoadingContainer>
);

const MenuTitleContainer = ({ siteTitle, pageTitle }) => {
const docsTitle = siteTitle ? `${siteTitle} Docs` : 'Docs';
return (
<>
{/* Disable LG left arrow glyph due to bug where additional copies of the LG icon would be rendered
at the bottom of the page. */}
<SidenavBackButton border={<Border />} enableGlyph={false} target="/" titleOverride={docsTitle} />
<MenuTitle>{pageTitle}</MenuTitle>
</>
);
};

const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, page, ...rest }) => {
const usesRST = options?.['uses-rst'];
const usesRealm = options?.['uses-realm'];
Expand Down Expand Up @@ -210,10 +182,10 @@ const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, pag
if (searchEl) {
const menuTitleContainerEl = document.createElement('div');
menuTitleContainerEl.className = menuTitleContainerClass;
const root = createRoot(menuTitleContainerEl);
const element = <DocsHomeButton />;
root.render(element);
sidebarEl.insertBefore(menuTitleContainerEl, searchEl);
const pageTitle = page?.options?.title || '';
const siteTitle = metadata?.title;
render(<MenuTitleContainer siteTitle={siteTitle} pageTitle={pageTitle} />, menuTitleContainerEl);
}
}
}}
Expand Down

0 comments on commit a142896

Please sign in to comment.