Skip to content

Commit 0957c96

Browse files
[docs] Some last improvement before the release (mui#7847)
1 parent 946ff76 commit 0957c96

21 files changed

Lines changed: 147 additions & 27 deletions

docs/scripts/buildIcons.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// @flow
2+
3+
import path from 'path';
4+
import gm from 'gm';
5+
import display from '../src/modules/scripts/display';
6+
7+
const SIZES = [48, 70, 96, 150, 152, 192, 256, 310, 384, 512];
8+
const INPUT_ICON = path.join(__dirname, '../../static/logo.png');
9+
const OUTPUT_DIR = path.join(__dirname, '../../static/icons');
10+
11+
display.info('Generating Icons');
12+
13+
const promises = SIZES.map(
14+
size =>
15+
new Promise((resolve, reject) => {
16+
gm(INPUT_ICON).resize(size, size).write(path.join(OUTPUT_DIR, `${size}x${size}.png`), err => {
17+
if (err) {
18+
reject(err);
19+
return;
20+
}
21+
22+
resolve();
23+
display.success(`Size ${size} created`);
24+
});
25+
}),
26+
);
27+
28+
Promise.all(promises).catch(err => {
29+
setTimeout(() => {
30+
display.error(err);
31+
throw err;
32+
}, 0);
33+
});

docs/src/modules/components/AppWrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import blue from 'material-ui/colors/blue';
1414
import pink from 'material-ui/colors/pink';
1515
import { lightTheme, darkTheme, setPrismTheme } from 'docs/src/modules/utils/prism';
1616

17-
// Injected the styles after docssearch
17+
// Injected the insertion-point-jss after docssearch
1818
if (process.browser && !global.__INSERTION_POINT__) {
1919
global.__INSERTION_POINT__ = true;
2020
const styleNode = document.createComment('insertion-point-jss');
21-
const docsearchStylesSheet = document.querySelector('#docsearch-styles-sheet');
21+
const docsearchStylesSheet = document.querySelector('#insertion-point-jss');
2222

2323
if (document.head && docsearchStylesSheet) {
2424
document.head.insertBefore(styleNode, docsearchStylesSheet.nextSibling);

docs/src/modules/components/withRoot.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ import wrapDisplayName from 'recompose/wrapDisplayName';
88
import AppWrapper from 'docs/src/modules/components/AppWrapper';
99
import initRedux from 'docs/src/modules/redux/initRedux';
1010
import findPages from /* preval */ 'docs/src/modules/utils/findPages';
11+
import { loadCSS } from 'fg-loadcss/src/loadCSS';
12+
13+
if (process.browser) {
14+
loadCSS(
15+
'https://fonts.googleapis.com/icon?family=Material+Icons',
16+
document.querySelector('#insertion-point-jss'),
17+
);
18+
loadCSS(
19+
'https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css',
20+
document.querySelector('#insertion-point-jss'),
21+
);
22+
}
1123

1224
const pages = [
1325
{
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-disable no-console, flowtype/require-valid-file-annotation */
2+
3+
import chalk from 'chalk';
4+
5+
const display = {
6+
info: (...args) => {
7+
if (process.env.NODE_ENV === 'test') {
8+
return;
9+
}
10+
11+
console.info(chalk.cyan(`i ${args.join(' ')}`));
12+
},
13+
error: (...args) => {
14+
if (process.env.NODE_ENV === 'test') {
15+
return;
16+
}
17+
18+
console.error(chalk.bold.red(`✘ ${args.join(' ')}`));
19+
},
20+
success: (...args) => {
21+
if (process.env.NODE_ENV === 'test') {
22+
return;
23+
}
24+
25+
console.log(chalk.green(`✔ ${args.join(' ')}`));
26+
},
27+
};
28+
29+
export default display;

next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ module.exports = {
3030

3131
return Object.assign({}, config, {
3232
plugins,
33+
externals: Object.assign({}, {
34+
fs: 'fs',
35+
}),
3336
module: Object.assign({}, config.module, {
3437
rules: config.module.rules.concat([
3538
{

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"scripts": {
2525
"docs:deploy": "yarn docs:build && firebase deploy",
2626
"docs:api": "rimraf pages/api/* && babel-node ./docs/scripts/buildApi.js",
27+
"docs:icons": "rimraf static/icons/* && babel-node ./docs/scripts/buildIcons.js",
2728
"docs:build": "cross-env BABEL_ENV=docs-production next build",
2829
"docs:dev": "cross-env BABEL_ENV=docs-development next dev",
2930
"docs:start": "next start",
@@ -89,7 +90,7 @@
8990
"babel-cli": "^6.26.0",
9091
"babel-core": "^6.26.0",
9192
"babel-eslint": "^7.2.3",
92-
"babel-loader": "^7.1.1",
93+
"babel-loader": "^7.1.2",
9394
"babel-plugin-flow-react-proptypes": "^5.0.0",
9495
"babel-plugin-istanbul": "^4.1.4",
9596
"babel-plugin-preval": "^1.4.3",
@@ -107,6 +108,7 @@
107108
"babel-preset-stage-1": "^6.24.1",
108109
"babel-register": "^6.26.0",
109110
"chai": "^4.1.1",
111+
"clean-css": "^4.1.7",
110112
"cross-env": "^5.0.5",
111113
"doctrine": "^2.0.0",
112114
"enzyme": "^2.9.1",
@@ -123,12 +125,14 @@
123125
"eslint-plugin-react": "^7.2.1",
124126
"eslint-plugin-spellcheck": "^0.0.8",
125127
"eventsource-polyfill": "^0.9.6",
128+
"fg-loadcss": "^1.3.1",
126129
"file-loader": "^0.11.2",
127130
"flow-bin": "^0.52.0",
128131
"flow-copy-source": "^1.2.0",
129132
"flow-typed": "^2.1.5",
130133
"fs-extra": "^4.0.1",
131134
"glob": "^7.1.2",
135+
"gm": "^1.23.0",
132136
"jsdom": "^11.1.0",
133137
"json-loader": "^0.5.7",
134138
"karma": "^1.7.0",

pages/_document.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import React from 'react';
44
import Document, { Head, Main, NextScript } from 'next/document';
55
import { getContext, setContext } from 'docs/src/modules/styles/context';
6+
import CleanCSS from 'clean-css';
7+
8+
const cleanCSS = new CleanCSS();
69

710
class MyDocument extends Document {
811
render() {
@@ -11,6 +14,10 @@ class MyDocument extends Document {
1114
<html lang="en" dir="ltr">
1215
<Head>
1316
<title>Material-UI</title>
17+
<meta
18+
name="description"
19+
content="React Components that Implement Google's Material Design."
20+
/>
1421
<meta charSet="utf-8" />
1522
{/* Use minimum-scale=1 to enable GPU rasterization */}
1623
<meta
@@ -31,18 +38,17 @@ class MyDocument extends Document {
3138
rel="stylesheet"
3239
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
3340
/>
34-
<link
35-
rel="stylesheet"
36-
href="https://fonts.googleapis.com/icon?family=Material+Icons"
37-
async
38-
/>
39-
<link
40-
id="docsearch-styles-sheet"
41-
rel="stylesheet"
42-
href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"
43-
async
44-
defer
41+
<style id="insertion-point-jss" />
42+
{/* Twitter */}
43+
<meta name="twitter:card" content="summary_large_image" />
44+
<meta name="twitter:site" content="@MaterialUI" />
45+
<meta name="twitter:title" content="Material-UI" />
46+
<meta
47+
name="twitter:description"
48+
content="React Components that Implement Google's Material Design."
4549
/>
50+
<meta name="twitter:image" content="/static/icons/512x512.png" />
51+
<link rel="shortcut icon" href="/static/favicon.ico" />
4652
</Head>
4753
<body>
4854
<Main />
@@ -77,13 +83,19 @@ MyDocument.getInitialProps = ctx => {
7783
const page = ctx.renderPage();
7884
// Get the context with the collected side effects.
7985
const context = getContext();
86+
87+
let css = context.sheetsRegistry.toString();
88+
if (process.env.NODE_ENV === 'production') {
89+
css = cleanCSS.minify(css).styles;
90+
}
91+
8092
return {
8193
...page,
8294
styles: (
8395
<style
8496
id="jss-server-side"
8597
// eslint-disable-next-line react/no-danger
86-
dangerouslySetInnerHTML={{ __html: context.sheetsRegistry.toString() }}
98+
dangerouslySetInnerHTML={{ __html: css }}
8799
/>
88100
),
89101
};

pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function PageHome(props) {
7171
{'Material-UI'}
7272
</Typography>
7373
<Typography type="headline" component="h2" color="inherit" className={classes.headline}>
74-
{"A React component library implementing Google's Material Design"}
74+
{"React Components that Implement Google's Material Design."}
7575
</Typography>
7676
<Button
7777
component={Link}

static/icons/150x150.png

3.57 KB
Loading

static/icons/152x152.png

3.67 KB
Loading

0 commit comments

Comments
 (0)