diff --git a/examples/with-stitches-styled/css/index.js b/examples/with-stitches-styled/css/index.js index 2b6c855ed55290c89b0178faeef5807dfcfd6707..82ca04e9d4b7bdcde7838bde5c29cfe4d16a161b 100644 --- a/examples/with-stitches-styled/css/index.js +++ b/examples/with-stitches-styled/css/index.js @@ -1,17 +1,12 @@ -import { createConfig } from '@stitches/css' +import { createCss } from '@stitches/css' import { createStyled } from '@stitches/styled' -const config = createConfig({ +export const css = createCss({ tokens: { colors: { RED: 'tomato', }, }, }) -/* - With Typescript: - const { Provider, styled, useCss } = createStyled() -*/ -const { Provider, styled, useCss } = createStyled() -export { config, Provider, styled, useCss } +export const styled = createStyled(css) diff --git a/examples/with-stitches-styled/package.json b/examples/with-stitches-styled/package.json index 9f7688677478bf00bfb6922e8735dfb85defdeec..f02cd6ad3cb8b259ab015b74f0a409b27f8c98c3 100644 --- a/examples/with-stitches-styled/package.json +++ b/examples/with-stitches-styled/package.json @@ -8,8 +8,8 @@ "start": "next start" }, "dependencies": { - "@stitches/css": "2.0.6", - "@stitches/styled": "2.0.6", + "@stitches/css": "3.0.0", + "@stitches/styled": "3.0.0", "next": "9.3.5", "react": "16.13.1", "react-dom": "16.13.1" diff --git a/examples/with-stitches-styled/pages/_app.js b/examples/with-stitches-styled/pages/_app.js deleted file mode 100644 index 3a02350e7434f706c04e6eaebc2a6557c7d72855..0000000000000000000000000000000000000000 --- a/examples/with-stitches-styled/pages/_app.js +++ /dev/null @@ -1,18 +0,0 @@ -import App from 'next/app' -import { createCss } from '@stitches/css' -import { Provider, config } from '../css' - -/* - With Typescript: - export default class MyApp extends App<{ serverCss: TCss }> { -*/ -export default class MyApp extends App { - render() { - const { Component, pageProps, serverCss } = this.props - return ( - - - - ) - } -} diff --git a/examples/with-stitches-styled/pages/_document.js b/examples/with-stitches-styled/pages/_document.js index 37446a385eae74d36143af2bee1291a7de3678e6..df3b228357357ddfc1cd80a01e2e48eba891dbc7 100644 --- a/examples/with-stitches-styled/pages/_document.js +++ b/examples/with-stitches-styled/pages/_document.js @@ -1,25 +1,28 @@ import Document from 'next/document' -import { createCss } from '@stitches/css' -import { config } from '../css' +import { css } from '../css' export default class MyDocument extends Document { static async getInitialProps(ctx) { - const css = createCss(config) const originalRenderPage = ctx.renderPage try { - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => (props) => , - }) + let extractedStyles + ctx.renderPage = () => { + const { styles, result } = css.getStyles(originalRenderPage) + extractedStyles = styles + return result + } const initialProps = await Document.getInitialProps(ctx) + return { ...initialProps, styles: ( <> {initialProps.styles} - + {extractedStyles.map((content) => ( + + ))} ), } diff --git a/examples/with-stitches-styled/pages/index.js b/examples/with-stitches-styled/pages/index.js index 139f87aa79be47a7f4102334b94c4cba4192838e..46a2e51a0daf8eb0231d2defa3d31db9b7111513 100644 --- a/examples/with-stitches-styled/pages/index.js +++ b/examples/with-stitches-styled/pages/index.js @@ -1,6 +1,8 @@ import { styled } from '../css' -const Header = styled.h1((css) => css.color('RED')) +const Header = styled.h1({ + color: 'RED', +}) export default function Home() { return
Hello world
diff --git a/examples/with-stitches/css/index.js b/examples/with-stitches/css/index.js index 810d0e4bfa19d6ddf9d3bed637fe3b0035b1b32b..bf4ac7ac1acaeab012450ec2e08e580d875b9280 100644 --- a/examples/with-stitches/css/index.js +++ b/examples/with-stitches/css/index.js @@ -1,30 +1,9 @@ -import { createConfig } from '@stitches/css' -import * as React from 'react' +import { createCss } from '@stitches/css' -const config = createConfig({ +export const css = createCss({ tokens: { colors: { RED: 'tomato', }, }, }) - -/* - With Typescript: - const context = React.createContext>(null) -*/ -const context = React.createContext(null) - -/* - With Typescript: - const Provider = ({ css, children }: { css: TCss, children?: React.ReactNode }) => { - return {children} - } -*/ -const Provider = ({ css, children }) => { - return {children} -} - -const useCss = () => React.useContext(context) - -export { config, Provider, useCss } diff --git a/examples/with-stitches/package.json b/examples/with-stitches/package.json index 0487dc2e090c9fc331aecf4eb38f13f30d869bb6..761c06c9d5fb526157ff3a1d6973c82a87916e44 100644 --- a/examples/with-stitches/package.json +++ b/examples/with-stitches/package.json @@ -8,7 +8,7 @@ "start": "next start" }, "dependencies": { - "@stitches/css": "2.0.6", + "@stitches/css": "3.0.0", "next": "9.3.5", "react": "16.13.1", "react-dom": "16.13.1" diff --git a/examples/with-stitches/pages/_app.js b/examples/with-stitches/pages/_app.js deleted file mode 100644 index 3b6955437658bd5f11b48af801126a477a5a25c4..0000000000000000000000000000000000000000 --- a/examples/with-stitches/pages/_app.js +++ /dev/null @@ -1,18 +0,0 @@ -import { createCss } from '@stitches/css' -import App from 'next/app' -import { config, Provider } from '../css' - -/* - With Typescript: - export default class MyApp extends App<{ serverCss: TCss }> { -*/ -export default class MyApp extends App { - render() { - const { Component, pageProps, serverCss } = this.props - return ( - - - - ) - } -} diff --git a/examples/with-stitches/pages/_document.js b/examples/with-stitches/pages/_document.js index 5de659632367eb01f4a893af10b71cee9a6eff8a..df3b228357357ddfc1cd80a01e2e48eba891dbc7 100644 --- a/examples/with-stitches/pages/_document.js +++ b/examples/with-stitches/pages/_document.js @@ -1,26 +1,27 @@ -import { createCss } from '@stitches/css' import Document from 'next/document' -import { config } from '../css' +import { css } from '../css' export default class MyDocument extends Document { static async getInitialProps(ctx) { - const css = createCss(config) const originalRenderPage = ctx.renderPage try { - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => (props) => , - }) + let extractedStyles + ctx.renderPage = () => { + const { styles, result } = css.getStyles(originalRenderPage) + extractedStyles = styles + return result + } const initialProps = await Document.getInitialProps(ctx) + return { ...initialProps, styles: ( <> {initialProps.styles} - {css.getStyles().map((css, index) => ( - + {extractedStyles.map((content) => ( + ))} ), diff --git a/examples/with-stitches/pages/index.js b/examples/with-stitches/pages/index.js index aac79783121e0fa3432e1ac827f31366b3ada036..039130840e4d47a1e29ddd9de64c10c35ebf4a22 100644 --- a/examples/with-stitches/pages/index.js +++ b/examples/with-stitches/pages/index.js @@ -1,6 +1,13 @@ -import { useCss } from '../css' +import { css } from '../css' export default function Home() { - const css = useCss() - return

Hello world

+ return ( +

+ Hello world +

+ ) }