diff --git a/Readme.md b/Readme.md index b5d4b4e9..53f4fc0d 100644 --- a/Readme.md +++ b/Readme.md @@ -44,7 +44,7 @@ We use [glamor](https://github.com/threepointone/glamor) to provide a great buil ```jsx import React from 'react' -import css from 'next/css' +import { style } from 'next/css' export default () => (
@@ -52,7 +52,7 @@ export default () => (
) -const style = css({ +const style = style({ main: { background: 'red', ':hover': { diff --git a/bench/fixtures/basic/pages/css.js b/bench/fixtures/basic/pages/css.js index 6d125bdc..80cb5cf0 100644 --- a/bench/fixtures/basic/pages/css.js +++ b/bench/fixtures/basic/pages/css.js @@ -1,11 +1,11 @@ import React, { Component } from 'react' -import { StyleSheet, css } from 'next/css' +import { style } from 'next/css' export default class CrazyCSS extends Component { spans () { const out = [] for (let i = 0; i < 1000; i++) { - out.push(This is ${i}) + out.push(This is ${i}) } return out } @@ -17,7 +17,5 @@ export default class CrazyCSS extends Component { const spanStyles = {} for (let i = 0; i < 1000; i++) { - spanStyles[`padding-${i}`] = { padding: i } + spanStyles[`padding-${i}`] = style({ padding: i }) } - -const styles = StyleSheet.create(spanStyles) diff --git a/client/next.js b/client/next.js index 52075154..df3e0611 100644 --- a/client/next.js +++ b/client/next.js @@ -1,13 +1,13 @@ import { createElement } from 'react' import { render } from 'react-dom' import HeadManager from './head-manager' -import { StyleSheet } from '../lib/css' +import { rehydrate } from '../lib/css' import Router from '../lib/router' import DefaultApp from '../lib/app' import evalScript from '../lib/eval-script' const { - __NEXT_DATA__: { app, component, props, classNames, err } + __NEXT_DATA__: { app, component, props, ids, err } } = window const App = app ? evalScript(app).default : DefaultApp @@ -19,5 +19,5 @@ const headManager = new HeadManager() const container = document.getElementById('__next') const appProps = { Component, props, router, headManager } -StyleSheet.rehydrate(classNames) +rehydrate(ids) render(createElement(App, appProps), container) diff --git a/examples/basic-css/pages/index.js b/examples/basic-css/pages/index.js index 9dead5b1..c9dffd27 100644 --- a/examples/basic-css/pages/index.js +++ b/examples/basic-css/pages/index.js @@ -1,21 +1,19 @@ import React from 'react' -import { css, StyleSheet } from 'next/css' +import { style } from 'next/css' export default () => ( -
+

Hello World

) -const styles = StyleSheet.create({ - main: { - font: '15px Helvetica, Arial, sans-serif', - background: '#eee', - padding: '100px', - textAlign: 'center', - transition: '100ms ease-in background', - ':hover': { - background: '#ccc' - } +const styles = style({ + font: '15px Helvetica, Arial, sans-serif', + background: '#eee', + padding: '100px', + textAlign: 'center', + transition: '100ms ease-in background', + ':hover': { + background: '#ccc' } }) diff --git a/examples/nested-components/components/paragraph.js b/examples/nested-components/components/paragraph.js index 0332a3da..0010ce21 100644 --- a/examples/nested-components/components/paragraph.js +++ b/examples/nested-components/components/paragraph.js @@ -1,13 +1,11 @@ import React from 'react' -import { css, StyleSheet } from 'next/css' +import { style } from 'next/css' export default ({ children }) => ( -

{children}

+

{children}

) -const styles = StyleSheet.create({ - main: { - font: '13px Helvetica, Arial', - margin: '10px 0' - } +const styles = style({ + font: '13px Helvetica, Arial', + margin: '10px 0' }) diff --git a/examples/nested-components/components/post.js b/examples/nested-components/components/post.js index 8d90dd91..0570885a 100644 --- a/examples/nested-components/components/post.js +++ b/examples/nested-components/components/post.js @@ -1,23 +1,21 @@ import React from 'react' -import { css, StyleSheet } from 'next/css' +import { style } from 'next/css' export default ({ title, children }) => ( -
-

{ title }

+
+

{ title }

{ children }
) -const styles = StyleSheet.create({ - main: { - font: '15px Helvetica, Arial', - border: '1px solid #eee', - padding: '0 10px' - }, - - title: { - fontSize: '16px', - fontWeight: 'bold', - margin: '10px 0' - } +const mainStyle = style({ + font: '15px Helvetica, Arial', + border: '1px solid #eee', + padding: '0 10px' +}) + +const titleStyle = style({ + fontSize: '16px', + fontWeight: 'bold', + margin: '10px 0' }) diff --git a/examples/nested-components/pages/index.js b/examples/nested-components/pages/index.js index e78df55f..14098fbc 100644 --- a/examples/nested-components/pages/index.js +++ b/examples/nested-components/pages/index.js @@ -1,10 +1,10 @@ import React from 'react' import P from '../components/paragraph' import Post from '../components/post' -import { css, StyleSheet } from 'next/css' +import { style } from 'next/css' export default () => ( -
+

Hello there

This is an example of a componentized blog post

@@ -26,23 +26,23 @@ export default () => (
) -const Hr = () =>
+const Hr = () =>
-const styles = StyleSheet.create({ - main: { +const styles = { + main: style({ margin: 'auto', maxWidth: '420px', padding: '10px' - }, + }), - hr: { + hr: style({ width: '100px', borderWidth: 0, margin: '20px auto', textAlign: 'center', - ':before': { + '::before': { content: '"***"', color: '#ccc' } - } -}) + }) +} diff --git a/lib/css.js b/lib/css.js index 96716816..ead82183 100644 --- a/lib/css.js +++ b/lib/css.js @@ -1 +1 @@ -module.exports = require('aphrodite') +module.exports = require('glamor') diff --git a/lib/document.js b/lib/document.js index 07fdf4e4..9b2ea4fc 100644 --- a/lib/document.js +++ b/lib/document.js @@ -5,7 +5,7 @@ export default ({ head, css, html, data, dev, staticMarkup }) => { return {(head || []).map((h, i) => React.cloneElement(h, { key: i }))} - ')) - t.true(html.includes('
This is red
')) + t.true(html.includes('.css-im3wl1')) + t.true(html.includes('
This is red
')) }) test(async t => {