Skip to content

Commit

Permalink
Fix preview header (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs authored Aug 7, 2024
1 parent d031a1c commit e1619ae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
36 changes: 25 additions & 11 deletions src/components/Header/preview-header.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import React from 'react';
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { palette } from '@leafygreen-ui/palette';
import { SidenavMobileMenuDropdown } from '../Sidenav';
import SiteBanner from '../Banner/SiteBanner';
import { theme } from '../../theme/docsTheme';
import { HeaderContext } from './header-context';

const StyledHeaderContainer = styled.header`
const StyledHeaderContainer = styled.header(
(props) => `
grid-area: header;
position: sticky;
top: 0;
z-index: 10;
`;
margin-top: ${props.hasBanner ? theme.header.bannerHeight : '0px'};
z-index: ${theme.zIndexes.header};
${props.template === 'landing' || props.template === 'errorpage' ? '' : 'position: sticky;'}
`
);

const StyledUnifiedNavPlaceholder = styled.nav`
width: 100%;
height: ${theme.header.navbarHeight};
display: flex;
align-items: center;
border-bottom: 1px solid #b8c4c2;
background-color: white;
--background-color: white;
--border-color: #b8c4c2;
.dark-theme & {
--background-color: ${palette.black};
--border-color: ${palette.gray.dark2};
}
background-color: var(--background-color);
border-bottom: 1px solid var(--border-color);
@media ${theme.screenSize.upToLarge} {
height: ${theme.header.navbarMobileHeight};
Expand All @@ -34,16 +46,18 @@ const StyledStagingWarning = styled.p`
`;

const Header = ({ sidenav }) => {
const { bannerContent } = useContext(HeaderContext);

return (
<StyledHeaderContainer>
<>
<SiteBanner />
<>
<StyledHeaderContainer hasBanner={!!bannerContent}>
<StyledUnifiedNavPlaceholder>
<StyledStagingWarning>This is a staging build.</StyledStagingWarning>
</StyledUnifiedNavPlaceholder>
{sidenav && <SidenavMobileMenuDropdown />}
</>
</StyledHeaderContainer>
</StyledHeaderContainer>
</>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/styles/global-dark-mode.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ body {
}

.dark-theme body {
background-color: var(--lg-bg-dark-mode);
background-color: var(--black);
color: var(--lg-color-dark-mode);
}

Expand Down
1 change: 0 additions & 1 deletion src/styles/mongodb-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ th {
--check-circle: '\f058';

/* Supporting the new dark mode with LG styles */
--lg-bg-dark-mode: var(--gray-dark4);
--lg-color-dark-mode: var(--day-spa);
} /*!
* Font Awesome Free 5.3.1 by @fontawesome - https://fontawesome.com
Expand Down

0 comments on commit e1619ae

Please sign in to comment.