Refactor layout (#486)

* Refactor to move `<DatasetContainer>` out of layout
* `<DatasetContainer>` is now in the methodology page. Starting the review there will help understand the motive for this change.
* Fixed 404 page which seems way out of date.
* Use row/col grid syntax
This commit is contained in:
TomNUSDS 2021-08-09 08:04:24 -07:00 committed by GitHub
commit 73a205dc48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 285 additions and 216 deletions

View file

@ -0,0 +1,30 @@
// Trussworks GridContainer won't allow it to span 100% of the page, so
// this works around it and tries to hide the complexity in component
import React, {ReactNode} from 'react';
import {GridContainer} from '@trussworks/react-uswds';
interface ILayoutProps {
children: ReactNode,
fullWidth?: boolean,
className?: string
}
const J40MainGridContainer = ({
children,
fullWidth = false,
className = 'j40-grid-container'}: ILayoutProps) => {
return fullWidth ? (
<div
className={'j40-grid-container ' + className}>
{children}
</div>
) : (
<GridContainer
containerSize={'desktop-lg'}
className={'j40-grid-container ' + className}>
{children}
</GridContainer>
);
};
export default J40MainGridContainer;

View file

@ -1,10 +1,7 @@
import React, {ReactNode} from 'react';
import {GridContainer, Grid} from '@trussworks/react-uswds';
import J40Header from './J40Header';
import J40Footer from './J40Footer';
import {URLFlagProvider} from '../contexts/FlagContext';
import DatasetContainer from '../components/DatasetContainer';
// this has to be wrong
interface ILayoutProps {
children: ReactNode,
@ -12,22 +9,13 @@ interface ILayoutProps {
}
const Layout = ({children, location}: ILayoutProps) => {
const isMethodologyPage = location.pathname.match(/methodology\/?/);
// @ts-ignore
return (
<URLFlagProvider location={location}>
<J40Header location={location}/>
<GridContainer containerSize={'desktop-lg'}
className={'j40-grid-container'}>
<Grid row>
<main id={'main-content'}
className={'usa-layout-docs j40-main-content desktop:grid-col-12'}>
{children}
</main>
</Grid>
</GridContainer>
{isMethodologyPage ? <DatasetContainer />: null}
<main id={'main-content'}>
{children}
</main>
<J40Footer/>
</URLFlagProvider>
);