1
1
import React , { useState , useEffect } from 'react' ;
2
- import { render } from 'react-dom' ;
3
2
import PropTypes from 'prop-types' ;
4
3
import { RedocStandalone } from 'redoc' ;
5
4
import { Global , css } from '@emotion/react' ;
6
5
import styled from '@emotion/styled' ;
7
6
import { palette } from '@leafygreen-ui/palette' ;
7
+ import { createRoot } from 'react-dom/client' ;
8
8
import ComponentFactory from '../ComponentFactory' ;
9
- import { SidenavBackButton } from '../Sidenav' ;
10
9
import Spinner from '../Spinner' ;
11
10
import { useSiteMetadata } from '../../hooks/use-site-metadata' ;
12
11
import useStickyTopValues from '../../hooks/useStickyTopValues' ;
13
12
import { isBrowser } from '../../utils/is-browser' ;
14
13
import { theme } from '../../theme/docsTheme' ;
15
14
import { getPlaintext } from '../../utils/get-plaintext' ;
16
15
import { fetchOASFile } from '../../utils/realm' ;
16
+ import DocsHomeButton from '../Sidenav/DocsHomeButton' ;
17
17
import { isLinkInWhitelist , WhitelistErrorCallout } from './whitelist' ;
18
18
import {
19
19
codeBlockCss ,
@@ -91,13 +91,6 @@ const getGlobalCss = ({ topLarge, topMedium }) => css`
91
91
}
92
92
` ;
93
93
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
-
101
94
const LoadingContainer = styled ( 'div' ) `
102
95
align-items: center;
103
96
display: flex;
@@ -110,15 +103,6 @@ const LoadingMessage = styled('div')`
110
103
margin-bottom: ${ theme . size . small } ;
111
104
` ;
112
105
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
-
122
106
const JustifiedWhitelistWarning = styled ( WhitelistErrorCallout ) `
123
107
margin: 20px auto;
124
108
max-width: 840px;
@@ -131,18 +115,6 @@ const LoadingWidget = ({ className }) => (
131
115
</ LoadingContainer >
132
116
) ;
133
117
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
-
146
118
const OpenAPI = ( { metadata, nodeData : { argument, children, options = { } } , page, ...rest } ) => {
147
119
const usesRST = options ?. [ 'uses-rst' ] ;
148
120
const usesRealm = options ?. [ 'uses-realm' ] ;
@@ -210,10 +182,10 @@ const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, pag
210
182
if ( searchEl ) {
211
183
const menuTitleContainerEl = document . createElement ( 'div' ) ;
212
184
menuTitleContainerEl . className = menuTitleContainerClass ;
185
+ const root = createRoot ( menuTitleContainerEl ) ;
186
+ const element = < DocsHomeButton /> ;
187
+ root . render ( element ) ;
213
188
sidebarEl . insertBefore ( menuTitleContainerEl , searchEl ) ;
214
- const pageTitle = page ?. options ?. title || '' ;
215
- const siteTitle = metadata ?. title ;
216
- render ( < MenuTitleContainer siteTitle = { siteTitle } pageTitle = { pageTitle } /> , menuTitleContainerEl ) ;
217
189
}
218
190
}
219
191
} }
0 commit comments