Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert with-goober example to TS #39761

Merged
merged 3 commits into from Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions examples/with-goober/package.json
Expand Up @@ -6,10 +6,15 @@
"start": "next start"
},
"dependencies": {
"goober": "^2.0.2",
"goober-autoprefixer": "^1.2.0",
"goober": "^2.1.10",
"goober-autoprefixer": "^1.2.3",
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.7.7",
"@types/react": "^18.0.17",
"typescript": "^4.7.4"
}
}
@@ -1,12 +1,13 @@
import React from 'react'
import { prefix } from 'goober-autoprefixer'
import { createElement } from 'react'
import { setup } from 'goober'
import { prefix } from 'goober/prefixer'
import type { AppProps } from 'next/app'

// goober's needs to know how to render the `styled` nodes.
// So to let it know, we run the `setup` function with the
// `createElement` function and prefixer function.
setup(React.createElement, prefix)
setup(createElement, prefix)

export default function App({ Component, pageProps }) {
export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
@@ -1,10 +1,19 @@
import Document, { Html, Head, Main, NextScript } from 'next/document'
import { extractCss } from 'goober'
import NextDocument, {
DocumentContext,
Head,
Html,
Main,
NextScript,
} from 'next/document'

export default class MyDocument extends Document {
static async getInitialProps({ renderPage }) {
type Props = {
css: string
}

class Document extends NextDocument<Props> {
static async getInitialProps({ renderPage }: DocumentContext) {
const page = await renderPage()
// Extrach the css for each page render
const css = extractCss()
return { ...page, css }
}
Expand All @@ -27,3 +36,5 @@ export default class MyDocument extends Document {
)
}
}

export default Document
20 changes: 20 additions & 0 deletions examples/with-goober/tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}