Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Commit 0714589

Browse files
committed
chore(setup): setup TSDX and Next.js
We will use TSDX for the actual development of the React components. However we also want to provide a sort of "playground" while developing these components. For this "playground" we will use Next.js which you can start with `yarn playground` or `npm run playground`.
1 parent 7a67819 commit 0714589

12 files changed

+12750
-5
lines changed

.gitignore

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# logs
112
*.log
13+
14+
# next.js
15+
/.next/
16+
/out/
17+
18+
# production
19+
/build
20+
/dist
21+
22+
# misc
223
.DS_Store
3-
node_modules
24+
*.pem
425
.cache
5-
dist
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
32+
# local env files
33+
.env.local
34+
.env.development.local
35+
.env.test.local
36+
.env.production.local
37+
38+
# vercel
39+
.vercel

commitlint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = { extends: ['@commitlint/config-conventional'] };
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

jest.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
setupFilesAfterEnv: ['<rootDir>/jest/custom-matchers.ts'],
3+
globals: {
4+
'ts-jest': {
5+
isolatedModules: true,
6+
tsConfig: './tsconfig.tsdx.json',
7+
},
8+
},
9+
}

jest/custom-matchers.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Assuming requestAnimationFrame is roughly 60 frames per second
2+
const frame = 1000 / 60
3+
4+
const formatter = new Intl.NumberFormat('en')
5+
6+
expect.extend({
7+
toBeWithinRenderFrame(actual, expected) {
8+
const min = expected - frame
9+
const max = expected + frame
10+
11+
const pass = actual >= min && actual <= max
12+
13+
if (pass) {
14+
return {
15+
message: () =>
16+
`expected ${actual} not to be within range of a frame ${formatter.format(
17+
min
18+
)} - ${formatter.format(max)}`,
19+
pass: true,
20+
}
21+
} else {
22+
return {
23+
message: () =>
24+
`expected ${actual} to be within range of a frame ${formatter.format(
25+
min
26+
)} - ${formatter.format(max)}`,
27+
pass: false,
28+
}
29+
}
30+
},
31+
})

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

next.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
devIndicators: {
3+
autoPrerender: false,
4+
},
5+
}

package.json

+39-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "@tailwindui/react",
33
"version": "0.0.0-development",
4+
"main": "dist/index.js",
5+
"typings": "dist/index.d.ts",
6+
"module": "dist/tailwindui.esm.js",
47
"license": "MIT",
58
"files": [
69
"dist"
@@ -9,11 +12,18 @@
912
"node": ">=10"
1013
},
1114
"scripts": {
15+
"start": "tsdx watch",
16+
"build": "tsdx build --name tailwindui --tsconfig ./tsconfig.tsdx.json",
17+
"test": "tsdx test --passWithNoTests",
18+
"playground": "next dev",
19+
"lint": "tsdx lint",
20+
"prepare": "npm run build",
1221
"commit": "git-cz",
1322
"semantic-release": "semantic-release"
1423
},
1524
"husky": {
1625
"hooks": {
26+
"pre-commit": "npm run lint",
1727
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
1828
}
1929
},
@@ -28,12 +38,39 @@
2838
"path": "cz-conventional-changelog"
2939
}
3040
},
41+
"release": {
42+
"branches": [
43+
"+([0-9])?(.{+([0-9]),x}).x",
44+
"master",
45+
{
46+
"name": "develop",
47+
"channel": "next"
48+
}
49+
]
50+
},
51+
"peerDependencies": {
52+
"react": ">=16"
53+
},
3154
"devDependencies": {
3255
"@commitlint/cli": "^9.1.2",
3356
"@commitlint/config-conventional": "^9.1.2",
34-
"commitizen": "^4.1.2",
57+
"@tailwindcss/ui": "^0.5.0",
58+
"@testing-library/react": "^10.4.8",
59+
"@types/node": "^14.6.0",
60+
"@types/react-dom": "^16.9.8",
61+
"@types/react": "^16.9.46",
62+
"babel-jest": "^26.3.0",
63+
"commitizen": "^4.1.5",
3564
"cz-conventional-changelog": "^3.2.0",
3665
"husky": "^4.2.5",
37-
"semantic-release": "^17.1.1"
66+
"next": "9.5.2",
67+
"react-dom": "^16.13.1",
68+
"react": "^16.13.1",
69+
"semantic-release": "^17.1.1",
70+
"snapshot-diff": "^0.8.1",
71+
"tailwindcss": "^1.7.3",
72+
"tsdx": "^0.13.3",
73+
"tslib": "^2.0.1",
74+
"typescript": "^3.9.7"
3875
}
3976
}

postcss.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

tailwind.config.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const defaultTheme = require('tailwindcss/defaultTheme')
2+
3+
module.exports = {
4+
purge: ['./components/**/*.tsx', './pages/**/*.tsx'],
5+
theme: {
6+
container: {
7+
center: true,
8+
},
9+
extend: {
10+
fontFamily: {
11+
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
12+
},
13+
},
14+
},
15+
variants: {},
16+
plugins: [require('@tailwindcss/ui')],
17+
}

tsconfig.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"include": ["src", "types"],
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"lib": ["dom", "esnext"],
6+
"importHelpers": true,
7+
"declaration": true,
8+
"sourceMap": true,
9+
"rootDir": "./src",
10+
"strict": true,
11+
"noUnusedLocals": true,
12+
"noUnusedParameters": true,
13+
"noImplicitReturns": true,
14+
"noFallthroughCasesInSwitch": true,
15+
"moduleResolution": "node",
16+
"baseUrl": "./",
17+
"paths": {
18+
"@tailwindui/react": ["src"],
19+
"*": ["src/*", "node_modules/*"]
20+
},
21+
"jsx": "preserve",
22+
"esModuleInterop": true,
23+
"target": "es5",
24+
"allowJs": true,
25+
"skipLibCheck": true,
26+
"forceConsistentCasingInFileNames": true,
27+
"noEmit": true,
28+
"resolveJsonModule": true,
29+
"isolatedModules": true
30+
},
31+
"exclude": ["node_modules"]
32+
}

tsconfig.tsdx.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"compilerOptions": {
5+
"jsx": "react"
6+
}
7+
}

0 commit comments

Comments
 (0)