-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from ParabolInc/look-away
Switch from react-look to aphrodite. fix #313 fix #307 fix #305 fix #302 fix #295 fix #290 fix #282 fix #276 fix #252 fix #227 fix #221 fix #190 fix #124
- Loading branch information
Showing
293 changed files
with
6,484 additions
and
4,743 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,54 @@ | ||
/* eslint react/no-danger:0 */ | ||
import React, {PropTypes} from 'react'; | ||
import {LookRoot} from 'react-look'; | ||
import {Provider} from 'react-redux'; | ||
import {RouterContext} from 'react-router'; | ||
import {renderToString} from 'react-dom/server'; | ||
import makeSegmentSnippet from '@segment/snippet'; | ||
|
||
const segmentSnippet = makeSegmentSnippet.min({ | ||
const segKey = process.env.SEGMENT_WRITE_KEY; | ||
const segmentSnippet = segKey && makeSegmentSnippet.min({ | ||
host: 'cdn.segment.com', | ||
apiKey: process.env.SEGMENT_WRITE_KEY | ||
apiKey: segKey | ||
}); | ||
|
||
// Injects the server rendered state and app into a basic html template | ||
export default function Html({ | ||
store, | ||
title, | ||
lookConfig, | ||
lookCSSToken, | ||
entries, | ||
renderProps | ||
}) { | ||
const PROD = process.env.NODE_ENV === 'production'; | ||
export default function Html({store, entries, StyleSheetServer, renderProps}) { | ||
const {manifest, app, vendor} = entries; | ||
const initialState = `window.__INITIAL_STATE__ = ${JSON.stringify(store.getState())}`; | ||
// TURN ON WHEN WE SEND STATE TO CLIENT | ||
// const initialState = `window.__INITIAL_STATE__ = ${JSON.stringify(store.getState())}`; | ||
// <script dangerouslySetInnerHTML={{__html: initialState}}/> | ||
|
||
const root = PROD && renderToString( | ||
<LookRoot config={lookConfig}> | ||
const {html, css} = StyleSheetServer.renderStatic(() => { | ||
return renderToString( | ||
<Provider store={store}> | ||
<RouterContext {...renderProps} /> | ||
</Provider> | ||
</LookRoot> | ||
); | ||
const fontAwesomeUrl = PROD ? | ||
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css' : | ||
'/static/css/font-awesome.css'; | ||
); | ||
}); | ||
const dehydratedStyles = `window.__APHRODITE__ = ${JSON.stringify(css.renderedClassNames)}`; | ||
const fontAwesomeUrl = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css'; | ||
return ( | ||
<html> | ||
<head> | ||
<meta charSet="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"/> | ||
<meta property="description" content="Team transparency, made easy."/> | ||
<style dangerouslySetInnerHTML={{__html: lookCSSToken}} id={lookConfig.styleElementId}/> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href={fontAwesomeUrl} | ||
/> | ||
<title>{title}</title> | ||
<style data-aphrodite dangerouslySetInnerHTML={{__html: css.content}}/> | ||
<link rel="stylesheet" type="text/css" href={fontAwesomeUrl}/> | ||
{/* segment.io analytics */} | ||
{process.env.SEGMENT_WRITE_KEY && | ||
<script | ||
type="text/javascript" | ||
dangerouslySetInnerHTML={{__html: segmentSnippet}} | ||
/> | ||
} | ||
<script type="text/javascript" dangerouslySetInnerHTML={{__html: segmentSnippet}}/> | ||
</head> | ||
<body> | ||
<script dangerouslySetInnerHTML={{__html: initialState}}/> | ||
{PROD ? | ||
<div id="root" dangerouslySetInnerHTML={{__html: root}}></div> : | ||
<div id="root"></div>} | ||
{PROD && <script dangerouslySetInnerHTML={{__html: manifest.text}}/>} | ||
{PROD && <script src={vendor.js}/>} | ||
<script src={PROD ? app.js : '/static/app.js'}/> | ||
<script dangerouslySetInnerHTML={{__html: dehydratedStyles}}/> | ||
<div id="root" dangerouslySetInnerHTML={{__html: html}}></div> | ||
<script dangerouslySetInnerHTML={{__html: manifest.text}}/> | ||
<script src={vendor.js}/> | ||
<script src={app.js}/> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
Html.propTypes = { | ||
StyleSheetServer: PropTypes.object, | ||
store: PropTypes.object.isRequired, | ||
title: PropTypes.string.isRequired, | ||
lookConfig: PropTypes.object.isRequired, | ||
lookCSSToken: PropTypes.string.isRequired, | ||
entries: PropTypes.object, | ||
renderProps: PropTypes.object | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.