Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/components/Sidenav/DocsHomeButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { SideNavItem } from '@leafygreen-ui/side-nav';
import Icon from '@leafygreen-ui/icon';
import { css as LeafyCSS, cx } from '@leafygreen-ui/emotion';
import { palette } from '@leafygreen-ui/palette';
import Link from '../Link';
import { baseUrl } from '../../utils/base-url';
import { sideNavItemBasePadding } from './styles/sideNavItem';
import { titleStyle } from './styles/sideNavItem';

const homeLinkStyle = LeafyCSS`
span {
color: ${palette.gray.dark1};
font-weight: 400;
display: flex;
gap: 6px;
align-items: text-bottom;
Comment thread
seungpark marked this conversation as resolved.
Outdated
svg {
height: 17px;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

horrible little way to ensure that the svg and text of home button slightly align, since the svg is a bit bigger than its content so visually it doesn't line up even though the text and icon are bottom-aligned.

color: ${palette.gray.dark2}
}
}
`;

const DocsHomeButton = () => {
return (
<SideNavItem className={cx(titleStyle, sideNavItemBasePadding, homeLinkStyle)} as={Link} to={baseUrl()}>
<Icon glyph="Home"></Icon>
Docs Home
</SideNavItem>
);
};

export default DocsHomeButton;
35 changes: 3 additions & 32 deletions src/components/Sidenav/Sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import VersionDropdown from '../VersionDropdown';
import useStickyTopValues from '../../hooks/useStickyTopValues';
import { theme } from '../../theme/docsTheme';
import { formatText } from '../../utils/format-text';
import { baseUrl } from '../../utils/base-url';
import { TocContext } from '../../context/toc-context';
import { VersionContext } from '../../context/version-context';
import useSnootyMetadata from '../../utils/use-snooty-metadata';
Expand All @@ -23,11 +22,11 @@ import GuidesTOCTree from './GuidesTOCTree';
import IA from './IA';
import IATransition from './IATransition';
import ProductsList from './ProductsList';
import SidenavBackButton from './SidenavBackButton';
import { SidenavContext } from './sidenav-context';
import SidenavMobileTransition from './SidenavMobileTransition';
import Toctree from './Toctree';
import { sideNavItemBasePadding, sideNavItemFontSize } from './styles/sideNavItem';
import { sideNavItemBasePadding, sideNavItemFontSize, titleStyle } from './styles/sideNavItem';
import DocsHomeButton from './DocsHomeButton';

const SIDENAV_WIDTH = 268;

Expand Down Expand Up @@ -77,21 +76,6 @@ const sideNavStyling = ({ hideMobile, isCollapsed }) => LeafyCSS`

`;

const titleStyle = LeafyCSS`
color: ${palette.gray.dark3};
font-size: ${theme.fontSize.small};
font-weight: bold;
line-height: 20px;
text-transform: none;
:hover {
background-color: inherit;

&:after, span:after {
display: none;
}
}
`;

// Prevent content scrolling when the side nav is open on mobile and tablet screen sizes
const disableScroll = (shouldDisableScroll) => css`
body {
Expand Down Expand Up @@ -260,21 +244,8 @@ const Sidenav = ({ chapters, guides, page, pageTitle, repoBranches, siteTitle, s
<IATransition back={back} hasIA={!!ia} slug={slug} isMobile={isMobile}>
<NavTopContainer>
<ArtificialPadding />
<SideNavItem className={cx(titleStyle, sideNavItemBasePadding)} as={Link} to={baseUrl()}>
MongoDB Documentation
</SideNavItem>
<DocsHomeButton />
<Border />
<SidenavBackButton
handleClick={() => {
setBack(true);
hideMobileSidenav();
}}
project={project}
currentSlug={slug}
target={isGuidesTemplate ? '/' : ''}
titleOverride={isGuidesTemplate ? siteTitle : ''}
eol={eol}
/>
{ia && (
<IA
header={!isLanding && <span className={cx([titleStyle])}>{formatText(pageTitle)}</span>}
Expand Down
17 changes: 17 additions & 0 deletions src/components/Sidenav/styles/sideNavItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { css } from '@leafygreen-ui/emotion';
import { palette } from '@leafygreen-ui/palette';
import { theme } from '../../../theme/docsTheme';

export const sideNavItemBasePadding = css`
Expand Down Expand Up @@ -31,3 +32,19 @@ export const sideNavItemTOCStyling = ({ level = 1 }) => css`
export const sideNavItemFontSize = css`
font-size: ${theme.fontSize.small};
`;

export const titleStyle = css`
color: ${palette.gray.dark3};
font-size: ${theme.fontSize.small};
font-weight: bold;
line-height: 20px;
text-transform: none;
:hover {
background-color: inherit;

&:after,
span:after {
display: none;
}
}
`;