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

chore: refactor with-typestyle example #40740

Merged
merged 3 commits into from Sep 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
11 changes: 8 additions & 3 deletions examples/with-typestyle/package.json
Expand Up @@ -7,8 +7,13 @@
},
"dependencies": {
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typestyle": "^2.0.1"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typestyle": "^2.4.0"
},
"devDependencies": {
"@types/node": "18.7.18",
"@types/react": "16.9.17",
"typescript": "4.8.2"
}
}
24 changes: 0 additions & 24 deletions examples/with-typestyle/pages/_document.js

This file was deleted.

37 changes: 37 additions & 0 deletions examples/with-typestyle/pages/_document.tsx
@@ -0,0 +1,37 @@
import Document, {
Html,
Head,
Main,
NextScript,
DocumentInitialProps,
DocumentContext,
} from 'next/document'
import { getStyles } from 'typestyle'

export default function MyDocument() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}

MyDocument.getInitialProps = async (
ctx: DocumentContext
): Promise<DocumentInitialProps> => {
const initialProps = await Document.getInitialProps(ctx)
const styleTags = getStyles()
return {
...initialProps,
styles: (
<>
{initialProps.styles}
<style id="typestyle-target">{styleTags}</style>
</>
),
}
}
@@ -1,8 +1,7 @@
import { style } from 'typestyle'

const className = style({ color: 'red' })
const RedText = ({ text }) => <div className={className}>{text}</div>

export default function Home() {
return <RedText text="Hello Next.js!" />
return <div className={className}>Hello Next.js!</div>
}
20 changes: 20 additions & 0 deletions examples/with-typestyle/tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}