fix(client): do not unmount Guide Layout on navigate

This commit is contained in:
Valeriy
2019-01-23 02:02:31 +03:00
committed by Stuart Taylor
parent 28ee458ceb
commit a44935a520
5 changed files with 28 additions and 16 deletions

View File

@ -6,6 +6,7 @@ import { createStore } from './src/redux/createStore';
import AppMountNotifier from './src/components/AppMountNotifier'; import AppMountNotifier from './src/components/AppMountNotifier';
import GuideNavContextProvider from './src/contexts/GuideNavigationContext'; import GuideNavContextProvider from './src/contexts/GuideNavigationContext';
import DefaultLayout from './src/components/layouts/Default'; import DefaultLayout from './src/components/layouts/Default';
import GuideLayout from './src/components/layouts/GuideLayout';
const store = createStore(); const store = createStore();
@ -34,6 +35,13 @@ export const wrapPageElement = ({ element, props }) => {
</DefaultLayout> </DefaultLayout>
); );
} }
if ((/^\/guide(\/.*)*/).test(pathname)) {
return (
<DefaultLayout>
<GuideLayout>{element}</GuideLayout>
</DefaultLayout>
);
}
return <DefaultLayout>{element}</DefaultLayout>; return <DefaultLayout>{element}</DefaultLayout>;
}; };

View File

@ -8,6 +8,7 @@ import { createStore } from './src/redux/createStore';
import GuideNavContextProvider from './src/contexts/GuideNavigationContext'; import GuideNavContextProvider from './src/contexts/GuideNavigationContext';
import DefaultLayout from './src/components/layouts/Default'; import DefaultLayout from './src/components/layouts/Default';
import GuideLayout from './src/components/layouts/GuideLayout';
const store = createStore(); const store = createStore();
@ -34,6 +35,13 @@ export const wrapPageElement = ({ element, props }) => {
</DefaultLayout> </DefaultLayout>
); );
} }
if ((/^\/guide(\/.*)*/).test(pathname)) {
return (
<DefaultLayout>
<GuideLayout>{element}</GuideLayout>
</DefaultLayout>
);
}
return <DefaultLayout>{element}</DefaultLayout>; return <DefaultLayout>{element}</DefaultLayout>;
}; };

View File

@ -66,9 +66,11 @@
/* Layout */ /* Layout */
.content { .content,
.sideNav {
/* 100vh - (navbar height) - (spacer height) */ /* 100vh - (navbar height) - (spacer height) */
min-height: calc(100vh - 38px - 60px); height: calc(100vh - 38px - 60px);
overflow-y: auto;
} }
.content img { .content img {
@ -179,7 +181,7 @@
@media (max-width: 992px) { @media (max-width: 992px) {
.content { .content {
min-height: auto; height: auto;
} }
} }

View File

@ -1,11 +1,9 @@
import React from 'react'; import React, { Fragment } from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import Layout from '../components/layouts/GuideLayout';
function Index() { function Index() {
return ( return (
<Layout> <Fragment>
<Helmet> <Helmet>
<title>Guide | freeCodeCamp.org</title> <title>Guide | freeCodeCamp.org</title>
<meta <meta
@ -57,7 +55,7 @@ function Index() {
</p> </p>
<hr /> <hr />
<p>Happy coding!</p> <p>Happy coding!</p>
</Layout> </Fragment>
); );
} }

View File

@ -1,10 +1,9 @@
import React, { Component } from 'react'; import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { graphql } from 'gatsby'; import { graphql } from 'gatsby';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import Breadcrumbs from './components/Breadcrumbs'; import Breadcrumbs from './components/Breadcrumbs';
import Layout from '../../components/layouts/GuideLayout';
const propTypes = { const propTypes = {
data: PropTypes.object, data: PropTypes.object,
@ -40,13 +39,10 @@ class GuideArticle extends Component {
pageContext: { meta } pageContext: { meta }
} = this.props; } = this.props;
return ( return (
<Layout> <Fragment>
<Helmet> <Helmet>
<title>{`${title} | freeCodeCamp Guide`}</title> <title>{`${title} | freeCodeCamp Guide`}</title>
<link <link href={`https://www.freecodecamp.org${slug}`} rel='canonical' />
href={`https://www.freecodecamp.org${slug}`}
rel='canonical'
/>
<meta <meta
content={`https://www.freecodecamp.org${slug}`} content={`https://www.freecodecamp.org${slug}`}
property='og:url' property='og:url'
@ -72,7 +68,7 @@ class GuideArticle extends Component {
}} }}
tabIndex='-1' tabIndex='-1'
/> />
</Layout> </Fragment>
); );
} }
} }