From c84bf2ea32ae346b75dfd3588de977db5032c5ca Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Mon, 24 Jul 2017 06:39:36 +0200 Subject: [PATCH] Update material-ui example (#2630) --- .../with-material-ui-next/components/App.js | 23 ++++----- examples/with-material-ui-next/package.json | 3 +- .../with-material-ui-next/pages/_document.js | 14 +++--- .../with-material-ui-next/styles/context.js | 49 +++++++++++++++++++ .../styles/createDefaultContext.js | 38 -------------- 5 files changed, 71 insertions(+), 56 deletions(-) create mode 100644 examples/with-material-ui-next/styles/context.js delete mode 100644 examples/with-material-ui-next/styles/createDefaultContext.js diff --git a/examples/with-material-ui-next/components/App.js b/examples/with-material-ui-next/components/App.js index a7026458..ddb582a2 100644 --- a/examples/with-material-ui-next/components/App.js +++ b/examples/with-material-ui-next/components/App.js @@ -1,21 +1,19 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' +import { JssProvider } from 'react-jss' import { withStyles, createStyleSheet, MuiThemeProvider } from 'material-ui/styles' -import { getDefaultContext } from '../styles/createDefaultContext' +import { getContext } from '../styles/context' +// Apply some reset const styleSheet = createStyleSheet('App', theme => ({ '@global': { html: { background: theme.palette.background.default, - fontFamily: theme.typography.fontFamily, WebkitFontSmoothing: 'antialiased', // Antialiasing. MozOsxFontSmoothing: 'grayscale' // Antialiasing. }, body: { margin: 0 - }, - a: { - color: 'inherit' } } })) @@ -34,13 +32,16 @@ class App extends Component { } render () { - const { styleManager, theme } = getDefaultContext() + const context = getContext() + return ( - - - {this.props.children} - - + + + + {this.props.children} + + + ) } } diff --git a/examples/with-material-ui-next/package.json b/examples/with-material-ui-next/package.json index a533f313..bfac72be 100644 --- a/examples/with-material-ui-next/package.json +++ b/examples/with-material-ui-next/package.json @@ -5,7 +5,8 @@ "material-ui": "next", "next": "latest", "react": "^15.5.4", - "react-dom": "^15.5.4" + "react-dom": "^15.5.4", + "react-jss": "^7.0.2" }, "scripts": { "dev": "next", diff --git a/examples/with-material-ui-next/pages/_document.js b/examples/with-material-ui-next/pages/_document.js index 1941b5ec..61e4570d 100644 --- a/examples/with-material-ui-next/pages/_document.js +++ b/examples/with-material-ui-next/pages/_document.js @@ -1,20 +1,22 @@ import React from 'react' import Document, { Head, Main, NextScript } from 'next/document' -import { getDefaultContext, setDefaultContext } from '../styles/createDefaultContext' +import { getContext, setContext } from '../styles/context' export default class MyDocument extends Document { static async getInitialProps (ctx) { - setDefaultContext() + // Reset the context for handling a new request. + setContext() const page = ctx.renderPage() - const styleContext = getDefaultContext() + // Get the context with the collected side effects. + const context = getContext() return { ...page, - styles: