Move global styles inside the app
This commit is contained in:
38
functions/package-lock.json
generated
38
functions/package-lock.json
generated
@ -980,6 +980,26 @@
|
|||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"readable-stream": "~1.0.32"
|
"readable-stream": "~1.0.32"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"readable-stream": {
|
||||||
|
"version": "1.0.34",
|
||||||
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
|
||||||
|
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"core-util-is": "~1.0.0",
|
||||||
|
"inherits": "~2.0.1",
|
||||||
|
"isarray": "0.0.1",
|
||||||
|
"string_decoder": "~0.10.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "0.10.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||||
|
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bytebuffer": {
|
"bytebuffer": {
|
||||||
@ -3800,18 +3820,6 @@
|
|||||||
"scheduler": "^0.12.0"
|
"scheduler": "^0.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"readable-stream": {
|
|
||||||
"version": "1.0.34",
|
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
|
|
||||||
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"core-util-is": "~1.0.0",
|
|
||||||
"inherits": "~2.0.1",
|
|
||||||
"isarray": "0.0.1",
|
|
||||||
"string_decoder": "~0.10.x"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"regex-not": {
|
"regex-not": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz",
|
||||||
@ -4230,12 +4238,6 @@
|
|||||||
"strip-ansi": "^3.0.0"
|
"strip-ansi": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"string_decoder": {
|
|
||||||
"version": "0.10.31",
|
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
|
||||||
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"stringifier": {
|
"stringifier": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/stringifier/-/stringifier-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/stringifier/-/stringifier-1.4.0.tgz",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOMServer from 'react-dom/server';
|
import { renderToString } from 'react-dom/server';
|
||||||
|
|
||||||
import MainTemplate from '../client/MainTemplate';
|
import MainTemplate from '../client/MainTemplate';
|
||||||
import MainApp from '../client/main/App';
|
import MainApp from '../client/main/App';
|
||||||
@ -8,9 +8,7 @@ import getEntryPoints from '../utils/getEntryPoints';
|
|||||||
import renderTemplate from '../utils/renderTemplate';
|
import renderTemplate from '../utils/renderTemplate';
|
||||||
|
|
||||||
export default function serveMainPage(req, res) {
|
export default function serveMainPage(req, res) {
|
||||||
const content = createHTML(
|
const content = createHTML(renderToString(React.createElement(MainApp)));
|
||||||
ReactDOMServer.renderToString(React.createElement(MainApp))
|
|
||||||
);
|
|
||||||
|
|
||||||
const entryPoints = getEntryPoints('main', {
|
const entryPoints = getEntryPoints('main', {
|
||||||
es: 'module',
|
es: 'module',
|
||||||
|
|||||||
@ -1,26 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Global, css } from '@emotion/core';
|
|
||||||
|
|
||||||
import App from './autoIndex/App';
|
import App from './autoIndex/App';
|
||||||
|
|
||||||
const globalStyles = css`
|
|
||||||
body {
|
|
||||||
font-size: 14px;
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
||||||
Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 1.7;
|
|
||||||
padding: 0px 10px 5px;
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const props = window.__DATA__ || {};
|
const props = window.__DATA__ || {};
|
||||||
|
|
||||||
ReactDOM.hydrate(
|
ReactDOM.hydrate(<App {...props} />, document.getElementById('root'));
|
||||||
<div>
|
|
||||||
<Global styles={globalStyles} />
|
|
||||||
<App {...props} />
|
|
||||||
</div>,
|
|
||||||
document.getElementById('root')
|
|
||||||
);
|
|
||||||
|
|||||||
@ -1,8 +1,20 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { Global, css } from '@emotion/core';
|
||||||
|
|
||||||
import DirectoryListing from './DirectoryListing';
|
import DirectoryListing from './DirectoryListing';
|
||||||
|
|
||||||
|
const globalStyles = css`
|
||||||
|
body {
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
||||||
|
Helvetica, Arial, sans-serif;
|
||||||
|
line-height: 1.7;
|
||||||
|
padding: 0px 10px 5px;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default class App extends React.Component {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
availableVersions: []
|
availableVersions: []
|
||||||
@ -18,6 +30,8 @@ export default class App extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div css={{ maxWidth: 900, margin: '0 auto' }}>
|
<div css={{ maxWidth: 900, margin: '0 auto' }}>
|
||||||
|
<Global styles={globalStyles} />
|
||||||
|
|
||||||
<header
|
<header
|
||||||
css={{
|
css={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|||||||
@ -1,43 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Global, css } from '@emotion/core';
|
|
||||||
|
|
||||||
import App from './main/App';
|
import App from './main/App';
|
||||||
|
|
||||||
const globalStyles = css`
|
ReactDOM.render(<App />, document.getElementById('root'));
|
||||||
body {
|
|
||||||
font-size: 14px;
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
||||||
Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 1.7;
|
|
||||||
padding: 5px 20px;
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 800px) {
|
|
||||||
body {
|
|
||||||
padding: 40px 20px 120px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link {
|
|
||||||
color: blue;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: rebeccapurple;
|
|
||||||
}
|
|
||||||
|
|
||||||
dd,
|
|
||||||
ul {
|
|
||||||
margin-left: 0;
|
|
||||||
padding-left: 25px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
ReactDOM.render(
|
|
||||||
<div>
|
|
||||||
<Global styles={globalStyles} />
|
|
||||||
<App />
|
|
||||||
</div>,
|
|
||||||
document.getElementById('root')
|
|
||||||
);
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { Global, css } from '@emotion/core';
|
||||||
import formatBytes from 'pretty-bytes';
|
import formatBytes from 'pretty-bytes';
|
||||||
import formatDate from 'date-fns/format';
|
import formatDate from 'date-fns/format';
|
||||||
import parseDate from 'date-fns/parse';
|
import parseDate from 'date-fns/parse';
|
||||||
@ -10,6 +11,36 @@ import formatPercent from '../utils/formatPercent';
|
|||||||
import cloudflareLogo from './CloudflareLogo.png';
|
import cloudflareLogo from './CloudflareLogo.png';
|
||||||
import herokuLogo from './HerokuLogo.png';
|
import herokuLogo from './HerokuLogo.png';
|
||||||
|
|
||||||
|
const globalStyles = css`
|
||||||
|
body {
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
||||||
|
Helvetica, Arial, sans-serif;
|
||||||
|
line-height: 1.7;
|
||||||
|
padding: 5px 20px;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
body {
|
||||||
|
padding: 40px 20px 120px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a:link {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: rebeccapurple;
|
||||||
|
}
|
||||||
|
|
||||||
|
dd,
|
||||||
|
ul {
|
||||||
|
margin-left: 0;
|
||||||
|
padding-left: 25px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
heading: {
|
heading: {
|
||||||
margin: 0,
|
margin: 0,
|
||||||
@ -84,6 +115,8 @@ export default class App extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div css={{ maxWidth: 700, margin: '0 auto' }}>
|
<div css={{ maxWidth: 700, margin: '0 auto' }}>
|
||||||
|
<Global styles={globalStyles} />
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<h1 css={styles.heading}>unpkg</h1>
|
<h1 css={styles.heading}>unpkg</h1>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user