Unverified Commit 4d8d99e4 authored by Han Yeong-woo's avatar Han Yeong-woo Committed by GitHub

chore(example): convert `with-stitches` to TS (#38892)

* chore(example): convert `with-stitches` to TS

* refactor: change arrow to declaration

* refactor: change import default to `* as`

* feat: add next.config.js

* refactor: improve typing
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent e8bbf148
......@@ -23,12 +23,13 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
module.exports = nextConfig
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"dev": "next dev",
"start": "next start"
},
"dependencies": {
"@stitches/react": "^1.2.6",
"@stitches/react": "1.2.8",
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "^18.0.6",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"typescript": "^4.7.4"
}
}
import React from 'react'
import NextDocument, { Html, Head, Main, NextScript } from 'next/document'
import { getCssText } from '../stitches.config'
export default class Document extends NextDocument {
render() {
return (
<Html lang="en">
<Head>
<style
id="stitches"
dangerouslySetInnerHTML={{ __html: getCssText() }}
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
import { Head, Html, Main, NextScript } from 'next/document'
import { getCssText } from '../stitches.config'
export default function MyDocument() {
return (
<Html lang="en">
<Head>
<style
id="stitches"
dangerouslySetInnerHTML={{ __html: getCssText() }}
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
import Head from 'next/head'
import { styled } from '../stitches.config'
import StitchesLogo from '../components/StitchesLogo'
import { styled } from '../stitches.config'
const Box = styled('div', {})
......
import type * as Stitches from '@stitches/react'
import { createStitches } from '@stitches/react'
export const {
......@@ -57,19 +58,19 @@ export const {
},
},
utils: {
marginX: (value) => ({
marginX: (value: Stitches.PropertyValue<'margin'>) => ({
marginLeft: value,
marginRight: value,
}),
marginY: (value) => ({
marginY: (value: Stitches.PropertyValue<'margin'>) => ({
marginTop: value,
marginBottom: value,
}),
paddingX: (value) => ({
paddingX: (value: Stitches.PropertyValue<'padding'>) => ({
paddingLeft: value,
paddingRight: value,
}),
paddingY: (value) => ({
paddingY: (value: Stitches.PropertyValue<'padding'>) => ({
paddingTop: value,
paddingBottom: value,
}),
......
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"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"]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment