Skip to content

Commit 7013da5

Browse files
second iteration
1 parent c6dd3f0 commit 7013da5

17 files changed

+291
-245
lines changed

docs/pages/_app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function AppWrapper(props) {
293293
pathname = pathname.replace(/\/$/, '');
294294
}
295295
// console.log(pages, { ...router, pathname })
296-
const activePage = findActivePage(pages, pathname) || { pathname };
296+
const activePage = findActivePage(pages, pathname);
297297

298298
let fonts = ['https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap'];
299299
if (pathname.match(/onepirate/)) {

docs/pages/company/about.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
2+
import TopLayoutCompany from 'docs/src/modules/components/TopLayoutCompany';
33

44
const req = require.context('docs/src/pages/company/about', false, /\.(md|js|tsx)$/);
55
const reqSource = require.context(
@@ -10,14 +10,5 @@ const reqSource = require.context(
1010
const reqPrefix = 'pages/company/about';
1111

1212
export default function Page() {
13-
return (
14-
<MarkdownDocs
15-
disableAd
16-
disableToc
17-
disableEdit
18-
req={req}
19-
reqSource={reqSource}
20-
reqPrefix={reqPrefix}
21-
/>
22-
);
13+
return <TopLayoutCompany req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
2314
}

docs/pages/company/contact.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
2+
import TopLayoutCompany from 'docs/src/modules/components/TopLayoutCompany';
33

44
const req = require.context('docs/src/pages/company/contact', false, /\.(md|js|tsx)$/);
55
const reqSource = require.context(
@@ -10,14 +10,5 @@ const reqSource = require.context(
1010
const reqPrefix = 'pages/company/contact';
1111

1212
export default function Page() {
13-
return (
14-
<MarkdownDocs
15-
disableAd
16-
disableToc
17-
disableEdit
18-
req={req}
19-
reqSource={reqSource}
20-
reqPrefix={reqPrefix}
21-
/>
22-
);
13+
return <TopLayoutCompany req={req} reqSource={reqSource} reqPrefix={reqPrefix} />;
2314
}

docs/pages/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ function loadDependencies() {
3131
const useStyles = makeStyles(theme => ({
3232
root: {
3333
flex: '1 0 100%',
34-
},
35-
drawer: {
36-
width: 0,
34+
'& #main-content': {
35+
outline: 0,
36+
},
3737
},
3838
hero: {
3939
paddingTop: 64,
@@ -111,7 +111,7 @@ export default function HomePage() {
111111
const classes = useStyles();
112112

113113
return (
114-
<AppFrame classes={{ drawer: classes.drawer }}>
114+
<AppFrame>
115115
<div className={classes.root}>
116116
<Head />
117117
<main id="main-content" tabIndex="-1">

docs/src/modules/components/AppContent.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const useStyles = makeStyles(theme => ({
1111
position: 'relative',
1212
maxWidth: '100%',
1313
margin: '0 auto',
14+
outline: 0,
1415
[theme.breakpoints.up('sm')]: {
1516
paddingRight: theme.spacing(1),
1617
maxWidth: 'calc(100% - 175px)',
@@ -40,18 +41,22 @@ const useStyles = makeStyles(theme => ({
4041
}));
4142

4243
export default function AppContent(props) {
43-
const { children, disableAd, disableToc } = props;
44+
const { children, className, disableAd, disableToc } = props;
4445
const classes = useStyles();
4546

4647
return (
4748
<Container
4849
component="main"
4950
id="main-content"
5051
tabIndex={-1}
51-
className={clsx(classes.root, {
52-
[classes.ad]: !disableAd,
53-
[classes.disableToc]: disableToc,
54-
})}
52+
className={clsx(
53+
classes.root,
54+
{
55+
[classes.ad]: !disableAd,
56+
[classes.disableToc]: disableToc,
57+
},
58+
className,
59+
)}
5560
>
5661
{children}
5762
</Container>
@@ -60,6 +65,7 @@ export default function AppContent(props) {
6065

6166
AppContent.propTypes = {
6267
children: PropTypes.node.isRequired,
68+
className: PropTypes.string,
6369
disableAd: PropTypes.bool.isRequired,
6470
disableToc: PropTypes.bool.isRequired,
6571
};

docs/src/modules/components/AppFrame.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import Link from 'docs/src/modules/components/Link';
3030
import AppDrawer from 'docs/src/modules/components/AppDrawer';
3131
import Notifications from 'docs/src/modules/components/Notifications';
3232
import MarkdownLinks from 'docs/src/modules/components/MarkdownLinks';
33-
import usePageTitle from 'docs/src/modules/components/usePageTitle';
3433
import { LANGUAGES_LABEL } from 'docs/src/modules/constants';
3534
import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
3635
import { useChangeTheme } from 'docs/src/modules/components/ThemeContext';
36+
import PageContext from 'docs/src/modules/components/PageContext';
3737

3838
const LOCALES = { zh: 'zh-CN', pt: 'pt-BR', es: 'es-ES' };
3939
const CROWDIN_ROOT_URL = 'https://translate.material-ui.com/project/material-ui-docs/';
@@ -137,11 +137,6 @@ const styles = theme => ({
137137
display: 'none',
138138
},
139139
},
140-
'@global': {
141-
'#main-content': {
142-
outline: 0,
143-
},
144-
},
145140
});
146141

147142
function AppFrame(props) {
@@ -183,13 +178,13 @@ function AppFrame(props) {
183178

184179
const router = useRouter();
185180
const { canonical } = pathnameToLanguage(Router2._rewriteUrlForNextExport(router.asPath));
186-
const title = usePageTitle({ t });
181+
const { activePage } = React.useContext(PageContext);
187182

188183
let disablePermanent = false;
189184
let navIconClassName = '';
190185
let appBarClassName = classes.appBar;
191186

192-
if (title === null) {
187+
if (activePage.title === false) {
193188
// home route, don't shift app bar or dock drawer
194189
disablePermanent = true;
195190
appBarClassName += ` ${classes.appBarHome}`;
@@ -337,7 +332,7 @@ function AppFrame(props) {
337332
</Toolbar>
338333
</AppBar>
339334
<AppDrawer
340-
className={classes.drawer}
335+
className={disablePermanent ? '' : classes.drawer}
341336
disablePermanent={disablePermanent}
342337
onClose={handleDrawerClose}
343338
onOpen={handleDrawerOpen}

docs/src/modules/components/EditPage.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import { useSelector } from 'react-redux';
44
import { Router, useRouter } from 'next/router';
55
import Button from '@material-ui/core/Button';
66
import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
7-
8-
const SOURCE_CODE_ROOT_URL = 'https://github.com/mui-org/material-ui/edit/master';
7+
import { SOURCE_CODE_ROOT_URL } from 'docs/src/modules/constants';
98

109
export default function EditPage(props) {
1110
const { markdownLocation } = props;
1211
const t = useSelector(state => state.options.t);
1312
const userLanguage = useSelector(state => state.options.userLanguage);
1413
const router = useRouter();
15-
const { canonical } = pathnameToLanguage(Router._rewriteUrlForNextExport(router.asPath));
1614

1715
return (
1816
<Button
@@ -21,6 +19,8 @@ export default function EditPage(props) {
2119
if (userLanguage === 'en') {
2220
return;
2321
}
22+
23+
const { canonical } = pathnameToLanguage(Router._rewriteUrlForNextExport(router.asPath));
2424
window.location = `/aa${canonical}`;
2525
}}
2626
href={userLanguage === 'en' ? `${SOURCE_CODE_ROOT_URL}${markdownLocation}` : null}

docs/src/modules/components/Head.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React from 'react';
22
import NextHead from 'next/head';
3-
import { Router as Router2, useRouter } from 'next/router';
3+
import { Router, useRouter } from 'next/router';
44
import PropTypes from 'prop-types';
55
import { useSelector } from 'react-redux';
66

77
export default function Head(props) {
8-
const router = useRouter();
98
const t = useSelector(state => state.options.t);
10-
const userLanguage = useSelector(state => state.options.userLanguage);
119
const { description = t('strapline'), title = t('headTitle'), children } = props;
10+
const userLanguage = useSelector(state => state.options.userLanguage);
11+
const router = useRouter();
1212

1313
return (
1414
<NextHead>
@@ -25,7 +25,7 @@ export default function Head(props) {
2525
<meta property="og:title" content={title} />
2626
<meta
2727
property="og:url"
28-
content={`https://material-ui.com${Router2._rewriteUrlForNextExport(router.asPath)}`}
28+
content={`https://material-ui.com${Router._rewriteUrlForNextExport(router.asPath)}`}
2929
/>
3030
<meta property="og:description" content={description} />
3131
<meta property="og:image" content="https://material-ui.com/static/brand.png" />

docs/src/modules/components/HomeFooter.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const styles = theme => ({
2323
marginBottom: theme.spacing(4),
2424
'& img': {
2525
width: 28,
26-
height: 28,
26+
height: 22,
2727
marginRight: theme.spacing(1.5),
2828
},
2929
},
@@ -60,7 +60,9 @@ function HomeFooter(props) {
6060
<Grid item xs={12} sm={3}>
6161
<div className={classes.logo}>
6262
<img src="/static/images/material-ui-logo.svg" alt="" />
63-
<Typography>Material-UI</Typography>
63+
<Link variant="body1" color="inherit" href="/">
64+
Material-UI
65+
</Link>
6466
</div>
6567
</Grid>
6668
<Grid item xs={6} sm={3} className={classes.list}>

0 commit comments

Comments
 (0)