Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right rail content #502

Merged
merged 41 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1d183b9
feat: create a related content component
jerelmiller Jul 29, 2020
749427a
feat: Add the related content sidebar to the main page
jerelmiller Jul 29, 2020
cee2d25
fix: migrate the rest of the layout styles to emotion
jerelmiller Jul 29, 2020
69931c4
chore: add prop type for className
jerelmiller Jul 29, 2020
25bb8a3
chore: remove import of removed scss module
jerelmiller Jul 29, 2020
71309ea
fix: use align-self: start instead of wrapping div
jerelmiller Jul 29, 2020
209cbee
chore: remove unused import
jerelmiller Jul 29, 2020
5ce869d
chore: use grid-column-gap instead of padding to add gap between layo…
jerelmiller Jul 29, 2020
a78d3d8
feat: add a usePageContext hook
jerelmiller Jul 29, 2020
4329cb5
chore: use usePageContext hook in layout
jerelmiller Jul 29, 2020
7e3e092
feat: add dynamic layout value
jerelmiller Jul 29, 2020
d3d34ab
chore: more forward-facing improvements for when to show the related …
jerelmiller Jul 29, 2020
1f7b2d5
feat: move the related content area to the guide template
jerelmiller Jul 29, 2020
89c3d78
chore: remove unused variables
jerelmiller Jul 29, 2020
ef316b3
fix: add prop type for page prop
jerelmiller Jul 29, 2020
b92b2e5
chore: use emotion for styling the guide template
jerelmiller Jul 30, 2020
f0d65d1
feat: hide the related content on a mobile layout
jerelmiller Jul 30, 2020
a6f668a
fix: fix mobile nav styles when mobile nav is open
jerelmiller Jul 30, 2020
1a8eb4d
fix: use Video component from theme in mdx
jerelmiller Jul 30, 2020
48da4d9
feat: move the content area into a grid
jerelmiller Jul 30, 2020
2880c29
chore: remove grid-area property that does nothing
jerelmiller Jul 30, 2020
2e6f488
feat: create a PageLayout component
jerelmiller Jul 30, 2020
0643661
feat: use PageLayout in GuideTemplate
jerelmiller Jul 30, 2020
9e0c007
feat: use PageLayout for OverviewTemplate
jerelmiller Jul 30, 2020
027a893
feat: use PageLayout for ComponentReferenceTemplate
jerelmiller Jul 30, 2020
11d156e
feat: use PageLayout for ApiReferenceTemplate
jerelmiller Jul 30, 2020
b9a5fc8
feat: use PageLayout for index page
jerelmiller Jul 30, 2020
37b7d0b
feat: use PageLayout for developer champion page
jerelmiller Jul 30, 2020
3f706f1
feat: use PageLayout for podcasts page
jerelmiller Jul 30, 2020
38e304f
fix: spacing on footer
jerelmiller Jul 30, 2020
7beb48e
Merge remote-tracking branch 'origin/main' into jerel/right-rail
jerelmiller Jul 30, 2020
06fe20d
fix: use to instead of href for podcasts link
jerelmiller Jul 30, 2020
9d049e6
fix: widen the main layout by 100px
jerelmiller Jul 30, 2020
fc8ec18
feat: add page layout context
jerelmiller Jul 30, 2020
c0277d9
feat: use dynamic breakpoint for side by side component based on layout
jerelmiller Jul 30, 2020
110180e
chore: use emotion to style SideBySide
jerelmiller Jul 30, 2020
571e1bf
fix: keep grid gap when on single column
jerelmiller Jul 30, 2020
44659b7
feat: remove PageTitle component
jerelmiller Jul 30, 2020
c76eca1
feat: move related content to bottom of content when on smaller screens
jerelmiller Jul 30, 2020
04c4a32
chore: minor responsive style adjustments to main page title
jerelmiller Jul 30, 2020
fdcfd2b
feat: add border around right rail component
jerelmiller Jul 30, 2020
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
3 changes: 1 addition & 2 deletions src/components/MDXContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import cx from 'classnames';
import { MDXRenderer } from 'gatsby-plugin-mdx';
import { MDXProvider } from '@mdx-js/react';

import Video from './Video';
import Step from './Step';
import Steps from './Steps';
import Caution from './Caution';
import Important from './Important';
import Tip from './Tip';
import Intro from './Intro';
import { MDXCodeBlock } from '@newrelic/gatsby-theme-newrelic';
import { MDXCodeBlock, Video } from '@newrelic/gatsby-theme-newrelic';

import styles from './MDXContainer.module.scss';

Expand Down
1 change: 0 additions & 1 deletion src/components/MobileHeader.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.container {
position: relative;
border-bottom: 1px solid var(--divider-color);
padding: 0 2rem;

width: 100vw;
Expand Down
7 changes: 7 additions & 0 deletions src/components/PageLayout/Content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styled from '@emotion/styled';

const Content = styled.div`
grid-area: content;
`;

export default Content;
39 changes: 39 additions & 0 deletions src/components/PageLayout/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/core';

const Header = ({ title, children }) => (
<header
css={css`
grid-area: page-header;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid var(--divider-color);

@media screen and (max-width: 1080px) {
flex-direction: column;
align-items: flex-start;
}
`}
>
<h1
css={css`
font-family: var(--secondary-font-family);
font-size: 2.5rem;
font-weight: normal;
margin-bottom: 0;
`}
>
{title}
</h1>
{children}
</header>
);

Header.propTypes = {
children: PropTypes.node,
title: PropTypes.string.isRequired,
};

export default Header;
8 changes: 8 additions & 0 deletions src/components/PageLayout/MarkdownContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import styled from '@emotion/styled';
import MDXContainer from '../MDXContainer';

const MarkdownContent = styled(MDXContainer)`
grid-area: content;
`;

export default MarkdownContent;
77 changes: 77 additions & 0 deletions src/components/PageLayout/PageLayout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/core';
import { graphql, useStaticQuery } from 'gatsby';
import Content from './Content';
import Header from './Header';
import MarkdownContent from './MarkdownContent';
import RelatedContent from './RelatedContent';

const TYPES = {
SINGLE_COLUMN: 'SINGLE_COLUMN',
RELATED_CONTENT: 'RELATED_CONTENT',
};

const LAYOUTS = {
[TYPES.RELATED_CONTENT]: css`
grid-template-areas:
'page-header page-header'
'content related-content';
grid-template-columns: minmax(0, 1fr) auto;
grid-gap: 2rem;

@media (max-width: 1240px) {
grid-template-areas:
'page-header'
'content';
grid-template-columns: minmax(0, 1fr);
}
`,
[TYPES.SINGLE_COLUMN]: css`
grid-template-areas:
'page-header'
'content';
grid-template-columns: minmax(0, 1fr);
`,
};

const PageLayout = ({ children, type }) => {
const {
site: { layout },
} = useStaticQuery(graphql`
query {
site {
layout {
contentPadding
}
}
}
`);

return (
<div
css={css`
display: grid;
grid-gap: ${layout.contentPadding};

${LAYOUTS[type]};
`}
>
{children}
</div>
);
};

PageLayout.propTypes = {
children: PropTypes.node,
type: PropTypes.oneOf(Object.values(TYPES)).isRequired,
};

PageLayout.TYPE = TYPES;

PageLayout.Content = Content;
PageLayout.Header = Header;
PageLayout.MarkdownContent = MarkdownContent;
PageLayout.RelatedContent = RelatedContent;

export default PageLayout;
108 changes: 108 additions & 0 deletions src/components/PageLayout/RelatedContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/core';
import { graphql, useStaticQuery } from 'gatsby';
import { Button, ExternalLink, Icon } from '@newrelic/gatsby-theme-newrelic';
import usePageContext from '../../hooks/usePageContext';

const RelatedContent = ({ page }) => {
const { site } = useStaticQuery(graphql`
query {
site {
siteMetadata {
repository
}
}
}
`);
const { fileRelativePath } = usePageContext();

const {
fields: { gitAuthorTime },
} = page;

const {
siteMetadata: { repository },
} = site;

return (
<aside
css={css`
grid-area: related-content;
position: sticky;
top: calc(var(--global-header-height) + 2rem);
align-self: start;

@media (max-width: 1240px) {
display: none;
}
`}
>
<h4>Contribute</h4>
<Button
as={ExternalLink}
href={`${repository}/issues/new/choose`}
css={css`
margin-right: 0.5rem;
`}
variant={Button.VARIANT.PRIMARY}
size={Button.SIZE.SMALL}
>
<Icon
name={Icon.TYPE.GITHUB}
css={css`
margin-right: 0.5rem;
`}
/>
File an issue
</Button>
<Button
as={ExternalLink}
href={`${repository}/tree/main/${fileRelativePath}`}
variant={Button.VARIANT.NORMAL}
size={Button.SIZE.SMALL}
>
<Icon
name={Icon.TYPE.EDIT}
css={css`
margin-right: 0.5rem;
`}
/>
Edit this page
</Button>

<div
css={css`
font-size: 0.875rem;
font-style: italic;
margin-top: 1rem;
color: var(--color-neutrals-500);

.dark-mode & {
color: var(--color-dark-500);
}
`}
>
{`Page last modified on ${gitAuthorTime}`}
</div>
</aside>
);
};

RelatedContent.propTypes = {
page: PropTypes.shape({
fields: PropTypes.shape({
gitAuthorTime: PropTypes.string,
}),
}),
};

export const query = graphql`
fragment RelatedContent_page on Mdx {
fields {
gitAuthorTime(formatString: "MMMM DD, YYYY")
}
}
`;

export default RelatedContent;
1 change: 1 addition & 0 deletions src/components/PageLayout/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './PageLayout';
6 changes: 6 additions & 0 deletions src/hooks/usePageContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useContext } from 'react';
import { PageContext } from '../components/PageContext';

const usePageContext = () => useContext(PageContext);

export default usePageContext;
Loading