Skip to content

Commit

Permalink
fix: wrong padding for single row mobile nav
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinchin committed Jan 19, 2019
1 parent 3ff79fc commit 1b16063
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion v1/lib/core/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,31 @@

const React = require('react');
const fs = require('fs');
const classNames = require('classnames');

const HeaderNav = require('./nav/HeaderNav.js');
const Head = require('./Head.js');

const Footer = require(`${process.cwd()}/core/Footer.js`);
const translation = require('../server/translation.js');
const env = require('../server/env.js');
const liveReloadServer = require('../server/liveReloadServer.js');
const {idx} = require('./utils.js');

const CWD = process.cwd();

// Component used to provide same head, header, footer, other scripts to all pages
class Site extends React.Component {
mobileNavHasOneRow(headerLinks) {
const hasLanguageDropdown =
env.translation.enabled && env.translation.enabledLanguages().length > 1;
const ordinaryHeaderLinks = headerLinks.filter(
link => !link.languages && !link.search,
);
const hasOrdinaryHeaderLinks = ordinaryHeaderLinks.length > 1;
return !hasLanguageDropdown && !hasOrdinaryHeaderLinks;
}

render() {
const tagline =
idx(translation, [this.props.language, 'localized-strings', 'tagline']) ||
Expand All @@ -43,6 +55,12 @@ class Site extends React.Component {
docsVersion = latestVersion;
}

const navPusherClasses = classNames('navPusher', {
singleRowMobileNav: this.mobileNavHasOneRow(
this.props.config.headerLinks,
),
});

return (
<html lang={this.props.language}>
<Head
Expand All @@ -62,7 +80,7 @@ class Site extends React.Component {
version={this.props.version}
current={this.props.metadata}
/>
<div className="navPusher">
<div className={navPusherClasses}>
{this.props.children}
<Footer config={this.props.config} language={this.props.language} />
</div>
Expand Down
8 changes: 8 additions & 0 deletions v1/lib/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,10 @@ input::placeholder {
z-index: 99;
}

.singleRowMobileNav.navPusher {
padding-top: 50px;
}

.navPusher:after {
background: rgba(0, 0, 0, 0.4);
content: '';
Expand Down Expand Up @@ -1990,6 +1994,10 @@ input::placeholder {
z-index: 10;
}

.tocActive .singleRowMobileNav .onPageNav {
top: 98px;
}

.tocActive .navToggle,
.tocActive .navBreadcrumb h2 {
visibility: hidden;
Expand Down

0 comments on commit 1b16063

Please sign in to comment.