mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
emotion v8 + adjustments for breaking changes (#3054)
* emotion v8 + adjustments for breaking changes * Corrected versioning * Take hydrate from 'react-emotion' I was actually wondering that, but haven't seen hydrate in the medium post (even though you pointed out that react-emotion exports all of emotion and I've seen it in source) and didn't want to risk it for the off chance that it *should* be imported directly from emotion for some reason :D
This commit is contained in:
parent
7fe20ed285
commit
573692c137
|
@ -7,13 +7,13 @@
|
|||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-plugin-emotion": "^7.1.0",
|
||||
"emotion": "^7.2.0",
|
||||
"emotion-server": "^7.2.0",
|
||||
"babel-plugin-emotion": "^8.0.4",
|
||||
"emotion": "^8.0.5",
|
||||
"emotion-server": "^8.0.5",
|
||||
"next": "^3.0.6",
|
||||
"react": "^15.6.1",
|
||||
"react-dom": "^15.6.1",
|
||||
"react-emotion": "^7.2.0"
|
||||
"react-emotion": "^8.0.5"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
import Document, { Head, Main, NextScript } from 'next/document'
|
||||
import { extractCritical } from 'emotion-server'
|
||||
import { flush } from 'emotion'
|
||||
|
||||
const dev = process.env.NODE_ENV !== 'production'
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
static getInitialProps ({ renderPage }) {
|
||||
if (dev) { flush() }
|
||||
const page = renderPage()
|
||||
const styles = extractCritical(page.html)
|
||||
return { ...page, ...styles }
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React from 'react'
|
||||
import { hydrate, keyframes, css, injectGlobal } from 'emotion'
|
||||
import styled from 'react-emotion'
|
||||
import styled, { hydrate, keyframes, css, injectGlobal } from 'react-emotion'
|
||||
|
||||
// Adds server generated styles to emotion cache.
|
||||
// '__NEXT_DATA__.ids' is set in '_document.js'
|
||||
|
@ -48,15 +47,20 @@ export default () => {
|
|||
}
|
||||
`
|
||||
|
||||
const Basic = styled.div`composes: ${basicStyles};`
|
||||
const Basic = styled.div`
|
||||
${basicStyles};
|
||||
`
|
||||
|
||||
const Combined = styled.div`
|
||||
composes: ${basicStyles} ${hoverStyles};
|
||||
${basicStyles};
|
||||
${hoverStyles};
|
||||
& code {
|
||||
background-color: linen;
|
||||
}
|
||||
`
|
||||
const Animated = styled.div`
|
||||
composes: ${basicStyles} ${hoverStyles};
|
||||
${basicStyles};
|
||||
${hoverStyles};
|
||||
& code {
|
||||
background-color: linen;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue