Skip to content

Commit a142896

Browse files
committed
last ditch open api effort
1 parent 61ff525 commit a142896

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

src/components/OpenAPI/index.js

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import React, { useState, useEffect } from 'react';
2-
import { render } from 'react-dom';
32
import PropTypes from 'prop-types';
43
import { RedocStandalone } from 'redoc';
54
import { Global, css } from '@emotion/react';
65
import styled from '@emotion/styled';
76
import { palette } from '@leafygreen-ui/palette';
7+
import { createRoot } from 'react-dom/client';
88
import ComponentFactory from '../ComponentFactory';
9-
import { SidenavBackButton } from '../Sidenav';
109
import Spinner from '../Spinner';
1110
import { useSiteMetadata } from '../../hooks/use-site-metadata';
1211
import useStickyTopValues from '../../hooks/useStickyTopValues';
1312
import { isBrowser } from '../../utils/is-browser';
1413
import { theme } from '../../theme/docsTheme';
1514
import { getPlaintext } from '../../utils/get-plaintext';
1615
import { fetchOASFile } from '../../utils/realm';
16+
import DocsHomeButton from '../Sidenav/DocsHomeButton';
1717
import { isLinkInWhitelist, WhitelistErrorCallout } from './whitelist';
1818
import {
1919
codeBlockCss,
@@ -91,13 +91,6 @@ const getGlobalCss = ({ topLarge, topMedium }) => css`
9191
}
9292
`;
9393

94-
const Border = styled('hr')`
95-
border: unset;
96-
border-bottom: 1px solid ${palette.gray.light2};
97-
margin: ${theme.size.default} 0;
98-
width: 100%;
99-
`;
100-
10194
const LoadingContainer = styled('div')`
10295
align-items: center;
10396
display: flex;
@@ -110,15 +103,6 @@ const LoadingMessage = styled('div')`
110103
margin-bottom: ${theme.size.small};
111104
`;
112105

113-
const MenuTitle = styled('div')`
114-
color: ${palette.gray.dark3};
115-
font-size: ${theme.fontSize.small};
116-
font-weight: bold;
117-
line-height: 20px;
118-
margin: ${theme.size.medium} ${theme.size.default};
119-
text-transform: capitalize;
120-
`;
121-
122106
const JustifiedWhitelistWarning = styled(WhitelistErrorCallout)`
123107
margin: 20px auto;
124108
max-width: 840px;
@@ -131,18 +115,6 @@ const LoadingWidget = ({ className }) => (
131115
</LoadingContainer>
132116
);
133117

134-
const MenuTitleContainer = ({ siteTitle, pageTitle }) => {
135-
const docsTitle = siteTitle ? `${siteTitle} Docs` : 'Docs';
136-
return (
137-
<>
138-
{/* Disable LG left arrow glyph due to bug where additional copies of the LG icon would be rendered
139-
at the bottom of the page. */}
140-
<SidenavBackButton border={<Border />} enableGlyph={false} target="/" titleOverride={docsTitle} />
141-
<MenuTitle>{pageTitle}</MenuTitle>
142-
</>
143-
);
144-
};
145-
146118
const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, page, ...rest }) => {
147119
const usesRST = options?.['uses-rst'];
148120
const usesRealm = options?.['uses-realm'];
@@ -210,10 +182,10 @@ const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, pag
210182
if (searchEl) {
211183
const menuTitleContainerEl = document.createElement('div');
212184
menuTitleContainerEl.className = menuTitleContainerClass;
185+
const root = createRoot(menuTitleContainerEl);
186+
const element = <DocsHomeButton />;
187+
root.render(element);
213188
sidebarEl.insertBefore(menuTitleContainerEl, searchEl);
214-
const pageTitle = page?.options?.title || '';
215-
const siteTitle = metadata?.title;
216-
render(<MenuTitleContainer siteTitle={siteTitle} pageTitle={pageTitle} />, menuTitleContainerEl);
217189
}
218190
}
219191
}}

0 commit comments

Comments
 (0)