From 6e3c7abced49371bd46973a34134a3c2e6eecde6 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 5 Jan 2020 16:01:59 +0100 Subject: [PATCH] [docs] Add company page (#18964) --- crowdin.yml | 2 +- docs/pages/company/about.js | 14 ++ docs/pages/company/contact.js | 14 ++ docs/pages/discover-more/governance.js | 14 -- docs/pages/index.js | 8 +- docs/src/modules/components/AppContent.js | 16 +- docs/src/modules/components/AppFrame.js | 13 +- docs/src/modules/components/EditPage.js | 3 +- docs/src/modules/components/Head.js | 8 +- docs/src/modules/components/HomeFooter.js | 30 +++- docs/src/modules/components/MarkdownDocs.js | 144 ++-------------- .../modules/components/TopLayoutCompany.js | 67 ++++++++ .../src/modules/components/useMarkdownDocs.js | 157 ++++++++++++++++++ .../components/useMarkdownDocsContents.js | 43 ----- docs/src/modules/components/usePageTitle.js | 15 -- docs/src/modules/constants.js | 3 + docs/src/pages.js | 3 +- docs/src/pages/company/about/about.md | 23 +++ docs/src/pages/company/contact/contact.md | 13 ++ .../discover-more/governance/governance.md | 99 ----------- docs/src/pages/discover-more/vision/vision.md | 2 +- docs/translations/translations.json | 2 +- 22 files changed, 360 insertions(+), 333 deletions(-) create mode 100644 docs/pages/company/about.js create mode 100644 docs/pages/company/contact.js delete mode 100644 docs/pages/discover-more/governance.js create mode 100644 docs/src/modules/components/TopLayoutCompany.js create mode 100644 docs/src/modules/components/useMarkdownDocs.js delete mode 100644 docs/src/modules/components/useMarkdownDocsContents.js delete mode 100644 docs/src/modules/components/usePageTitle.js create mode 100644 docs/src/pages/company/about/about.md create mode 100644 docs/src/pages/company/contact/contact.md delete mode 100644 docs/src/pages/discover-more/governance/governance.md diff --git a/crowdin.yml b/crowdin.yml index 9e567f766c54c9..537c07dc3e4fbc 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -5,8 +5,8 @@ files: - /docs/src/pages/getting-started/templates/*/**/* - /docs/src/pages/premium-themes/*/**/* - /docs/src/pages/discover-more/backers/* - - /docs/src/pages/discover-more/governance/* - /docs/src/pages/discover-more/roadmap/* + - /docs/src/pages/company/* translation: /%original_path%/%file_name%-%two_letters_code%.%file_extension% - source: /docs/translations/*.json ignore: diff --git a/docs/pages/company/about.js b/docs/pages/company/about.js new file mode 100644 index 00000000000000..6bd0db5ba86275 --- /dev/null +++ b/docs/pages/company/about.js @@ -0,0 +1,14 @@ +import React from 'react'; +import TopLayoutCompany from 'docs/src/modules/components/TopLayoutCompany'; + +const req = require.context('docs/src/pages/company/about', false, /\.(md|js|tsx)$/); +const reqSource = require.context( + '!raw-loader!../../src/pages/company/about', + false, + /\.(js|tsx)$/, +); +const reqPrefix = 'pages/company/about'; + +export default function Page() { + return ; +} diff --git a/docs/pages/company/contact.js b/docs/pages/company/contact.js new file mode 100644 index 00000000000000..a29f44bb35a3fc --- /dev/null +++ b/docs/pages/company/contact.js @@ -0,0 +1,14 @@ +import React from 'react'; +import TopLayoutCompany from 'docs/src/modules/components/TopLayoutCompany'; + +const req = require.context('docs/src/pages/company/contact', false, /\.(md|js|tsx)$/); +const reqSource = require.context( + '!raw-loader!../../src/pages/company/contact', + false, + /\.(js|tsx)$/, +); +const reqPrefix = 'pages/company/contact'; + +export default function Page() { + return ; +} diff --git a/docs/pages/discover-more/governance.js b/docs/pages/discover-more/governance.js deleted file mode 100644 index d2cc35c4d3dbd9..00000000000000 --- a/docs/pages/discover-more/governance.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; - -const req = require.context('docs/src/pages/discover-more/governance', false, /\.(md|js|tsx)$/); -const reqSource = require.context( - '!raw-loader!../../src/pages/discover-more/governance', - false, - /\.(js|tsx)$/, -); -const reqPrefix = 'pages/discover-more/governance'; - -export default function Page() { - return ; -} diff --git a/docs/pages/index.js b/docs/pages/index.js index 5678100bf260e0..8d82a44f9b5a8f 100644 --- a/docs/pages/index.js +++ b/docs/pages/index.js @@ -31,9 +31,9 @@ function loadDependencies() { const useStyles = makeStyles(theme => ({ root: { flex: '1 0 100%', - }, - drawer: { - width: 0, + '& #main-content': { + outline: 0, + }, }, hero: { paddingTop: 64, @@ -111,7 +111,7 @@ export default function HomePage() { const classes = useStyles(); return ( - +
diff --git a/docs/src/modules/components/AppContent.js b/docs/src/modules/components/AppContent.js index 54b881de2b6d9c..20170d813cc94f 100644 --- a/docs/src/modules/components/AppContent.js +++ b/docs/src/modules/components/AppContent.js @@ -11,6 +11,7 @@ const useStyles = makeStyles(theme => ({ position: 'relative', maxWidth: '100%', margin: '0 auto', + outline: 0, [theme.breakpoints.up('sm')]: { paddingRight: theme.spacing(1), maxWidth: 'calc(100% - 175px)', @@ -40,7 +41,7 @@ const useStyles = makeStyles(theme => ({ })); export default function AppContent(props) { - const { children, disableAd, disableToc } = props; + const { children, className, disableAd, disableToc } = props; const classes = useStyles(); return ( @@ -48,10 +49,14 @@ export default function AppContent(props) { component="main" id="main-content" tabIndex={-1} - className={clsx(classes.root, { - [classes.ad]: !disableAd, - [classes.disableToc]: disableToc, - })} + className={clsx( + classes.root, + { + [classes.ad]: !disableAd, + [classes.disableToc]: disableToc, + }, + className, + )} > {children} @@ -60,6 +65,7 @@ export default function AppContent(props) { AppContent.propTypes = { children: PropTypes.node.isRequired, + className: PropTypes.string, disableAd: PropTypes.bool.isRequired, disableToc: PropTypes.bool.isRequired, }; diff --git a/docs/src/modules/components/AppFrame.js b/docs/src/modules/components/AppFrame.js index 5ea9b31f3113be..8101f884bd5a0c 100644 --- a/docs/src/modules/components/AppFrame.js +++ b/docs/src/modules/components/AppFrame.js @@ -30,10 +30,10 @@ import Link from 'docs/src/modules/components/Link'; import AppDrawer from 'docs/src/modules/components/AppDrawer'; import Notifications from 'docs/src/modules/components/Notifications'; import MarkdownLinks from 'docs/src/modules/components/MarkdownLinks'; -import usePageTitle from 'docs/src/modules/components/usePageTitle'; import { LANGUAGES_LABEL } from 'docs/src/modules/constants'; import { pathnameToLanguage } from 'docs/src/modules/utils/helpers'; import { useChangeTheme } from 'docs/src/modules/components/ThemeContext'; +import PageContext from 'docs/src/modules/components/PageContext'; const LOCALES = { zh: 'zh-CN', pt: 'pt-BR', es: 'es-ES' }; const CROWDIN_ROOT_URL = 'https://translate.material-ui.com/project/material-ui-docs/'; @@ -137,11 +137,6 @@ const styles = theme => ({ display: 'none', }, }, - '@global': { - '#main-content': { - outline: 0, - }, - }, }); function AppFrame(props) { @@ -183,13 +178,13 @@ function AppFrame(props) { const router = useRouter(); const { canonical } = pathnameToLanguage(Router2._rewriteUrlForNextExport(router.asPath)); - const title = usePageTitle({ t }); + const { activePage } = React.useContext(PageContext); let disablePermanent = false; let navIconClassName = ''; let appBarClassName = classes.appBar; - if (title === null) { + if (activePage.title === false) { // home route, don't shift app bar or dock drawer disablePermanent = true; appBarClassName += ` ${classes.appBarHome}`; @@ -337,7 +332,7 @@ function AppFrame(props) { state.options.t); - const userLanguage = useSelector(state => state.options.userLanguage); const { description = t('strapline'), title = t('headTitle'), children } = props; + const userLanguage = useSelector(state => state.options.userLanguage); + const router = useRouter(); return ( @@ -30,7 +30,7 @@ export default function Head(props) { diff --git a/docs/src/modules/components/HomeFooter.js b/docs/src/modules/components/HomeFooter.js index 58dfa3347fc196..fe0fb38c103346 100644 --- a/docs/src/modules/components/HomeFooter.js +++ b/docs/src/modules/components/HomeFooter.js @@ -1,3 +1,4 @@ +/* eslint-disable material-ui/no-hardcoded-labels */ import React from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; @@ -22,7 +23,7 @@ const styles = theme => ({ marginBottom: theme.spacing(4), '& img': { width: 28, - height: 28, + height: 22, marginRight: theme.spacing(1.5), }, }, @@ -56,13 +57,15 @@ function HomeFooter(props) {