Skip to content

Commit 526107e

Browse files
authored
DOP-4533: FE removal of the SidenavBackButton (#1067)
1 parent 70ab2e5 commit 526107e

File tree

6 files changed

+57
-159
lines changed

6 files changed

+57
-159
lines changed

src/components/OpenAPI/index.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Global, css } from '@emotion/react';
66
import styled from '@emotion/styled';
77
import { palette } from '@leafygreen-ui/palette';
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';
@@ -91,13 +90,6 @@ const getGlobalCss = ({ topLarge, topMedium }) => css`
9190
}
9291
`;
9392

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-
10193
const LoadingContainer = styled('div')`
10294
align-items: center;
10395
display: flex;
@@ -132,12 +124,9 @@ const LoadingWidget = ({ className }) => (
132124
);
133125

134126
const MenuTitleContainer = ({ siteTitle, pageTitle }) => {
135-
const docsTitle = siteTitle ? `${siteTitle} Docs` : 'Docs';
136127
return (
137128
<>
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} />
129+
{/* TODO: Add DocsHomeButton here - see comment below */}
141130
<MenuTitle>{pageTitle}</MenuTitle>
142131
</>
143132
);
@@ -213,6 +202,8 @@ const OpenAPI = ({ metadata, nodeData: { argument, children, options = {} }, pag
213202
sidebarEl.insertBefore(menuTitleContainerEl, searchEl);
214203
const pageTitle = page?.options?.title || '';
215204
const siteTitle = metadata?.title;
205+
/* TODO: The below function is deprecated with React 18, need to replace it (potentially with
206+
createRoot() and .render() (see React documentation) */
216207
render(<MenuTitleContainer siteTitle={siteTitle} pageTitle={pageTitle} />, menuTitleContainerEl);
217208
}
218209
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { SideNavItem } from '@leafygreen-ui/side-nav';
3+
import Icon from '@leafygreen-ui/icon';
4+
import { css as LeafyCSS, cx } from '@leafygreen-ui/emotion';
5+
import { palette } from '@leafygreen-ui/palette';
6+
import Link from '../Link';
7+
import { baseUrl } from '../../utils/base-url';
8+
import { sideNavItemBasePadding } from './styles/sideNavItem';
9+
import { titleStyle } from './styles/sideNavItem';
10+
11+
const homeLinkStyle = LeafyCSS`
12+
span {
13+
color: ${palette.gray.dark1};
14+
font-weight: 400;
15+
display: flex;
16+
gap: 6px;
17+
svg {
18+
height: 17px;
19+
color: ${palette.gray.dark2};
20+
}
21+
}
22+
`;
23+
24+
const DocsHomeButton = () => {
25+
return (
26+
<SideNavItem className={cx(titleStyle, sideNavItemBasePadding, homeLinkStyle)} as={Link} to={baseUrl()}>
27+
<Icon glyph="Home"></Icon>
28+
Docs Home
29+
</SideNavItem>
30+
);
31+
};
32+
33+
export default DocsHomeButton;

src/components/Sidenav/Sidenav.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import VersionDropdown from '../VersionDropdown';
1313
import useStickyTopValues from '../../hooks/useStickyTopValues';
1414
import { theme } from '../../theme/docsTheme';
1515
import { formatText } from '../../utils/format-text';
16-
import { baseUrl } from '../../utils/base-url';
1716
import { TocContext } from '../../context/toc-context';
1817
import { VersionContext } from '../../context/version-context';
1918
import useSnootyMetadata from '../../utils/use-snooty-metadata';
@@ -23,11 +22,11 @@ import GuidesTOCTree from './GuidesTOCTree';
2322
import IA from './IA';
2423
import IATransition from './IATransition';
2524
import ProductsList from './ProductsList';
26-
import SidenavBackButton from './SidenavBackButton';
2725
import { SidenavContext } from './sidenav-context';
2826
import SidenavMobileTransition from './SidenavMobileTransition';
2927
import Toctree from './Toctree';
30-
import { sideNavItemBasePadding, sideNavItemFontSize } from './styles/sideNavItem';
28+
import { sideNavItemBasePadding, sideNavItemFontSize, titleStyle } from './styles/sideNavItem';
29+
import DocsHomeButton from './DocsHomeButton';
3130

3231
const SIDENAV_WIDTH = 268;
3332

@@ -77,21 +76,6 @@ const sideNavStyling = ({ hideMobile, isCollapsed }) => LeafyCSS`
7776
7877
`;
7978

80-
const titleStyle = LeafyCSS`
81-
color: ${palette.gray.dark3};
82-
font-size: ${theme.fontSize.small};
83-
font-weight: bold;
84-
line-height: 20px;
85-
text-transform: none;
86-
:hover {
87-
background-color: inherit;
88-
89-
&:after, span:after {
90-
display: none;
91-
}
92-
}
93-
`;
94-
9579
// Prevent content scrolling when the side nav is open on mobile and tablet screen sizes
9680
const disableScroll = (shouldDisableScroll) => css`
9781
body {
@@ -260,21 +244,8 @@ const Sidenav = ({ chapters, guides, page, pageTitle, repoBranches, siteTitle, s
260244
<IATransition back={back} hasIA={!!ia} slug={slug} isMobile={isMobile}>
261245
<NavTopContainer>
262246
<ArtificialPadding />
263-
<SideNavItem className={cx(titleStyle, sideNavItemBasePadding)} as={Link} to={baseUrl()}>
264-
MongoDB Documentation
265-
</SideNavItem>
247+
<DocsHomeButton />
266248
<Border />
267-
<SidenavBackButton
268-
handleClick={() => {
269-
setBack(true);
270-
hideMobileSidenav();
271-
}}
272-
project={project}
273-
currentSlug={slug}
274-
target={isGuidesTemplate ? '/' : ''}
275-
titleOverride={isGuidesTemplate ? siteTitle : ''}
276-
eol={eol}
277-
/>
278249
{ia && (
279250
<IA
280251
header={!isLanding && <span className={cx([titleStyle])}>{formatText(pageTitle)}</span>}

src/components/Sidenav/SidenavBackButton.js

Lines changed: 0 additions & 106 deletions
This file was deleted.

src/components/Sidenav/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import Sidenav from './Sidenav';
2-
import SidenavBackButton from './SidenavBackButton';
32
import SidenavMobileMenuButton from './SidenavMobileMenuButton';
43
import SidenavMobileMenuDropdown from './SidenavMobileMenuDropdown';
54
import { SidenavContext, SidenavContextProvider } from './sidenav-context';
65

7-
export {
8-
Sidenav,
9-
SidenavBackButton,
10-
SidenavContext,
11-
SidenavContextProvider,
12-
SidenavMobileMenuButton,
13-
SidenavMobileMenuDropdown,
14-
};
6+
export { Sidenav, SidenavContext, SidenavContextProvider, SidenavMobileMenuButton, SidenavMobileMenuDropdown };

src/components/Sidenav/styles/sideNavItem.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { css } from '@leafygreen-ui/emotion';
2+
import { palette } from '@leafygreen-ui/palette';
23
import { theme } from '../../../theme/docsTheme';
34

45
export const sideNavItemBasePadding = css`
@@ -31,3 +32,19 @@ export const sideNavItemTOCStyling = ({ level = 1 }) => css`
3132
export const sideNavItemFontSize = css`
3233
font-size: ${theme.fontSize.small};
3334
`;
35+
36+
export const titleStyle = css`
37+
color: ${palette.gray.dark3};
38+
font-size: ${theme.fontSize.small};
39+
font-weight: bold;
40+
line-height: 20px;
41+
text-transform: none;
42+
:hover {
43+
background-color: inherit;
44+
45+
&:after,
46+
span:after {
47+
display: none;
48+
}
49+
}
50+
`;

0 commit comments

Comments
 (0)