Skip to content

Commit

Permalink
chore(example): convert with-stitches to TS (#38892)
Browse files Browse the repository at this point in the history
* 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: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
nix6839 and ijjk committed Jul 22, 2022
1 parent e8bbf14 commit 4d8d99e
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 35 deletions.
9 changes: 5 additions & 4 deletions examples/with-stitches/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions examples/with-stitches/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <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.
6 changes: 6 additions & 0 deletions examples/with-stitches/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}

module.exports = nextConfig
14 changes: 10 additions & 4 deletions examples/with-stitches/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"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"
}
}
22 changes: 0 additions & 22 deletions examples/with-stitches/pages/_document.jsx

This file was deleted.

19 changes: 19 additions & 0 deletions examples/with-stitches/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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>
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Head from 'next/head'
import { styled } from '../stitches.config'
import StitchesLogo from '../components/StitchesLogo'
import { styled } from '../stitches.config'

const Box = styled('div', {})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as Stitches from '@stitches/react'
import { createStitches } from '@stitches/react'

export const {
Expand Down Expand Up @@ -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,
}),
Expand Down
20 changes: 20 additions & 0 deletions examples/with-stitches/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"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"]
}

0 comments on commit 4d8d99e

Please sign in to comment.