diff --git a/www/gatsby-node.js b/www/gatsby-node.js index 525ea7fb38..3400d41792 100644 --- a/www/gatsby-node.js +++ b/www/gatsby-node.js @@ -8,6 +8,7 @@ const createPages = require('./utils/createPages'); const onCreateNode = require('./utils/onCreateNode'); const onCreateWebpackConfig = require('./utils/onCreateWebpackConfig'); const createCssUtilityClassNodes = require('./utils/createCssUtilityClassNodes'); +const onCreatePage = require('./utils/onCreatePage'); exports.onCreateWebpackConfig = ({ actions }) => onCreateWebpackConfig(actions); @@ -18,3 +19,5 @@ exports.createPages = ({ graphql, actions, reporter }) => createPages(graphql, a exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => { createCssUtilityClassNodes({ actions, createNodeId, createContentDigest }); }; + +exports.onCreatePage = ({ page, actions }) => onCreatePage(page, actions); diff --git a/www/src/components/PageEditBtn/index.tsx b/www/src/components/PageEditBtn/index.tsx index a158090389..39821143fd 100644 --- a/www/src/components/PageEditBtn/index.tsx +++ b/www/src/components/PageEditBtn/index.tsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { Button, Hyperlink, Nav } from '~paragon-react'; export interface PageEditBtnProps extends Partial> { - githubEditPath: string, + githubEditPath?: string, isNavLink?: boolean; } diff --git a/www/src/components/PageLayout.tsx b/www/src/components/PageLayout.tsx index 932eaf4fe2..b2bd452395 100644 --- a/www/src/components/PageLayout.tsx +++ b/www/src/components/PageLayout.tsx @@ -93,9 +93,7 @@ function Layout({
- {isMdx && ( - - )} +
@@ -151,14 +149,14 @@ function Layout({ - {isMdx && ( - - - + {!hideFooterComponentMenu && ( + + + )}
+ {/* eslint-disable-next-line react/jsx-pascal-case */}

404: Not Found

@@ -14,4 +15,10 @@ function NotFoundPage() { ); } +NotFoundPage.propTypes = { + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, +}; + export default NotFoundPage; diff --git a/www/src/pages/foundations/colors.tsx b/www/src/pages/foundations/colors.tsx index dac5493007..d0c07e73c7 100644 --- a/www/src/pages/foundations/colors.tsx +++ b/www/src/pages/foundations/colors.tsx @@ -121,15 +121,18 @@ export interface IColorsPage { nodes: [], }, }, + pageContext: { + githubEditPath: string, + } } // eslint-disable-next-line react/prop-types -export default function ColorsPage({ data }: IColorsPage) { +export default function ColorsPage({ data, pageContext }: IColorsPage) { const { settings } = useContext(SettingsContext); parseColors(data.allCssUtilityClasses.nodes); // eslint-disable-line react/prop-types return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} diff --git a/www/src/pages/foundations/elevation.jsx b/www/src/pages/foundations/elevation.jsx index 52dac1b816..68d1421c56 100644 --- a/www/src/pages/foundations/elevation.jsx +++ b/www/src/pages/foundations/elevation.jsx @@ -268,7 +268,7 @@ function BoxShadowGenerator() { ); } -export default function ElevationPage() { +export default function ElevationPage({ pageContext }) { const { settings } = useContext(SettingsContext); const levelTitle = boxShadowLevels.map(level => ( @@ -284,7 +284,7 @@ export default function ElevationPage() { )); return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -399,3 +399,9 @@ export default function ElevationPage() { ); } + +ElevationPage.propTypes = { + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, +}; diff --git a/www/src/pages/foundations/responsive.jsx b/www/src/pages/foundations/responsive.jsx index 4e97c975cc..560c2e4161 100644 --- a/www/src/pages/foundations/responsive.jsx +++ b/www/src/pages/foundations/responsive.jsx @@ -49,7 +49,7 @@ function MaxWidthCell({ row }) { return {row.values.maxWidth ? `${row.values.maxWidth}px` : '-'}; } -function Responsive() { +function Responsive({ pageContext }) { const { settings } = useContext(SettingsContext); const breakpointsData = Object.keys(breakpoints).map(breakpoint => { const { minWidth, maxWidth } = breakpoints[breakpoint]; @@ -60,7 +60,7 @@ function Responsive() { }); return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -79,6 +79,7 @@ function Responsive() { { Header: 'Min width', accessor: 'minWidth', Cell: MinWidthCell }, { Header: 'Max Width', accessor: 'maxWidth', Cell: MaxWidthCell }, ]} + itemCount={0} > @@ -103,6 +104,12 @@ function Responsive() { ); } +Responsive.propTypes = { + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, +}; + const cellPropTypes = { row: PropTypes.shape({ values: PropTypes.shape({ diff --git a/www/src/pages/foundations/spacing.tsx b/www/src/pages/foundations/spacing.tsx index be2a639df1..2c98bbde58 100644 --- a/www/src/pages/foundations/spacing.tsx +++ b/www/src/pages/foundations/spacing.tsx @@ -83,7 +83,7 @@ SpaceBlock.defaultProps = { utilityClass: '', }; -export default function SpacingPage() { +export default function SpacingPage({ pageContext }) { const { settings } = useContext(SettingsContext); const [size, setSize] = useState(3); const [direction, setDirection] = useState('r'); @@ -96,7 +96,7 @@ export default function SpacingPage() { })); return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -109,6 +109,7 @@ export default function SpacingPage() { { Header: 'Spacer value', accessor: 'spacer' }, { Header: 'Pixel value', accessor: 'pixelValue' }, ]} + itemCount={0} > @@ -197,9 +198,9 @@ export default function SpacingPage() { {directions.map(({ key }) => ( - + {sizes.map(_size => ( - + .{getUtilityClassName('m', key, _size)} ))} @@ -211,9 +212,9 @@ export default function SpacingPage() { {directions.map(({ key }) => ( - + {sizes.map(_size => ( - + .{getUtilityClassName('p', key, _size)} ))} @@ -226,3 +227,9 @@ export default function SpacingPage() { ); } + +SpacingPage.propTypes = { + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, +}; diff --git a/www/src/pages/foundations/typography.tsx b/www/src/pages/foundations/typography.tsx index 816260798f..cf72e84bb3 100644 --- a/www/src/pages/foundations/typography.tsx +++ b/www/src/pages/foundations/typography.tsx @@ -1,5 +1,6 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ import React, { useContext } from 'react'; +import PropTypes from 'prop-types'; import { Container } from '~paragon-react'; import SEO from '../../components/SEO'; import MeasuredItem from '../../components/MeasuredItem'; @@ -42,11 +43,11 @@ const measuredTypeProps = { }, }; -export default function TypographyPage() { +export default function TypographyPage({ pageContext }) { const { settings } = useContext(SettingsContext); return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -64,7 +65,7 @@ export default function TypographyPage() { CSS Class {[1, 2, 3, 4, 5, 6].map(headingSize => ( - +

@@ -166,7 +167,7 @@ export default function TypographyPage() { CSS Class {[1, 2, 3, 4].map(displaySize => ( - +

@@ -398,3 +399,9 @@ export default function TypographyPage() { ); } + +TypographyPage.propTypes = { + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, +}; diff --git a/www/src/pages/insights.tsx b/www/src/pages/insights.tsx index 44128bd1b6..a2d8626c89 100644 --- a/www/src/pages/insights.tsx +++ b/www/src/pages/insights.tsx @@ -27,14 +27,21 @@ const { lastModified: analysisLastUpdated, } = dependentProjectsAnalysis; -interface TabsDataType { +export interface TabsDataType { components: string[], hooks: string[], utils: string[], icons: string[], } -export default function InsightsPage({ pageContext: { tab } }: { pageContext: { tab: string } }) { +export interface InsightsPageTypes { + pageContext: { + tab: string, + githubEditPath: string + } +} + +export default function InsightsPage({ pageContext: { tab, githubEditPath } }: InsightsPageTypes) { const { settings } = useContext(SettingsContext); const { paragonTypes = {}, isParagonIcon = () => false } = useContext(InsightsContext) as IInsightsContext; const { @@ -61,7 +68,7 @@ export default function InsightsPage({ pageContext: { tab } }: { pageContext: { } }; return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -113,5 +120,6 @@ export default function InsightsPage({ pageContext: { tab } }: { pageContext: { InsightsPage.propTypes = { pageContext: PropTypes.shape({ tab: PropTypes.oneOf(Object.values(INSIGHTS_TABS)), + githubEditPath: PropTypes.string, }).isRequired, }; diff --git a/www/src/pages/playground.tsx b/www/src/pages/playground.tsx index 7496b4a719..9707676a47 100644 --- a/www/src/pages/playground.tsx +++ b/www/src/pages/playground.tsx @@ -120,4 +120,7 @@ Playground.propTypes = { search: PropTypes.string, href: PropTypes.string, }).isRequired, + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, }; diff --git a/www/src/pages/status.tsx b/www/src/pages/status.tsx index 07710b57cf..9e70298f9d 100644 --- a/www/src/pages/status.tsx +++ b/www/src/pages/status.tsx @@ -1,4 +1,5 @@ import React, { useContext } from 'react'; +import PropTypes from 'prop-types'; import { StaticQuery, graphql } from 'gatsby'; import { Table, Container } from '~paragon-react'; import { ComponentStatus } from '../components/doc-elements'; @@ -11,11 +12,11 @@ export interface IComponents { title?: string, } -export default function StatusPage() { +export default function StatusPage({ pageContext }) { const { settings } = useContext(SettingsContext); return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -91,3 +92,9 @@ export default function StatusPage() { ); } + +StatusPage.propTypes = { + pageContext: PropTypes.shape({ + githubEditPath: PropTypes.string, + }).isRequired, +}; diff --git a/www/src/templates/default-mdx-page-template.tsx b/www/src/templates/default-mdx-page-template.tsx index 7742495ce4..29fa854ac2 100644 --- a/www/src/templates/default-mdx-page-template.tsx +++ b/www/src/templates/default-mdx-page-template.tsx @@ -29,6 +29,7 @@ export interface IPageTemplateType { frontmatter: { title: string, }, + githubEditPath: string, }, } @@ -36,7 +37,7 @@ export default function PageTemplate({ children, pageContext }: IPageTemplateTyp const { settings } = useContext(SettingsContext); return ( - + {/* eslint-disable-next-line react/jsx-pascal-case */} @@ -53,5 +54,6 @@ PageTemplate.propTypes = { frontmatter: PropTypes.shape({ title: PropTypes.string, }), + githubEditPath: PropTypes.string, }).isRequired, }; diff --git a/www/utils/createPages.js b/www/utils/createPages.js index 394fbea1e0..cbca6919f4 100644 --- a/www/utils/createPages.js +++ b/www/utils/createPages.js @@ -75,10 +75,11 @@ async function createPages(graphql, actions, reporter) { } INSIGHTS_PAGES.forEach(({ path: pagePath, tab }) => { + const githubEditPath = 'https://github.com/openedx/paragon/edit/master/www/src/pages/insights.tsx'; createPage({ path: pagePath, component: require.resolve('../src/pages/insights.tsx'), - context: { tab }, + context: { tab, githubEditPath }, }); }); diff --git a/www/utils/onCreatePage.js b/www/utils/onCreatePage.js new file mode 100644 index 0000000000..aa5cc1f93d --- /dev/null +++ b/www/utils/onCreatePage.js @@ -0,0 +1,14 @@ +async function onCreatePage(page, actions) { + const { createPage } = actions; + const githubEditPath = `https://github.com/openedx/paragon/edit/master/www/src${page.componentPath.split('src')[1]}`; + + createPage({ + ...page, + context: { + ...page.context, + githubEditPath, + }, + }); +} + +module.exports = onCreatePage;