Skip to content

Commit 955bc8c

Browse files
committed
feat: use typescript & provide dts
1 parent b2fa600 commit 955bc8c

36 files changed

+3124
-226
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "@leedomjs/eslint-config-basic"
2+
"extends": "@leedomjs/eslint-config-ts",
3+
"rules": {
4+
"@stylistic/js/multiline-ternary": 0
5+
}
36
}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919

2020
- run: npx changelogithub
2121
env:
22-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ yarn-error.log*
77

88
node_modules/
99
.DS_Store
10+
dist
11+
fixtures

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,31 @@
1919
"bugs": {
2020
"url": "https://github.com/leedomjs/tailwindcss-preset/issues"
2121
},
22-
"main": "index.js",
2322
"scripts": {
2423
"lint": "eslint .",
2524
"build:css": "tailwindcss -i fixtures/styles/tailwind.css -o fixtures/styles/output.css -w",
25+
"build:color": "pnpm --dir ./packages/tailwindcss-color-preset build",
26+
"build:mp": "pnpm --dir ./packages/tailwindcss-miniprogram-preset build",
27+
"build:preset": "pnpm --dir ./packages/tailwindcss-preset build",
28+
"build": "pnpm build:color && pnpm build:mp && pnpm build:preset",
2629
"release": "bumpp -r && pnpm -r publish --access public",
2730
"prepare": "simple-git-hooks"
2831
},
2932
"simple-git-hooks": {
3033
"pre-commit": "pnpm lint-staged"
3134
},
3235
"lint-staged": {
33-
"packages/**/*.js": "eslint --fix"
36+
"packages/**/*.ts": "eslint --fix"
3437
},
3538
"devDependencies": {
36-
"@leedomjs/eslint-config-basic": "^0.11.2",
39+
"@leedomjs/eslint-config-ts": "^0.11.2",
3740
"@leedomjs/tailwindcss-preset": "workspace:*",
3841
"bumpp": "^9.4.1",
3942
"eslint": "8.57.0",
4043
"lint-staged": "^15.2.2",
4144
"simple-git-hooks": "^2.11.1",
42-
"tailwindcss": "^3.4.3"
45+
"tailwindcss": "^3.4.3",
46+
"typescript": "^5.3.3",
47+
"unbuild": "^2.0.0"
4348
}
4449
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig([
4+
{
5+
entries: ['src/index'],
6+
outDir: 'dist',
7+
declaration: true,
8+
rollup: {
9+
emitCJS: true,
10+
esbuild: {
11+
minify: true,
12+
},
13+
},
14+
},
15+
])

packages/tailwindcss-color-preset/package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@leedomjs/tailwindcss-color-preset",
3+
"type": "module",
34
"version": "0.2.0",
45
"description": "Collecting theme color of some UI Frameworks for Tailwind CSS",
56
"keywords": [
@@ -22,11 +23,30 @@
2223
"bugs": {
2324
"url": "https://github.com/leedomjs/tailwindcss-preset/issues"
2425
},
25-
"main": "index.js",
26+
"files": [
27+
"dist"
28+
],
29+
"main": "dist/index.mjs",
30+
"scripts": {
31+
"build": "unbuild"
32+
},
33+
"exports": {
34+
".": {
35+
"types": "./dist/index.d.ts",
36+
"import": "./dist/index.mjs",
37+
"require": "./dist/index.cjs"
38+
}
39+
},
40+
"module": "./dist/index.mjs",
41+
"types": "./dist/index.d.ts",
2642
"peerDependencies": {
2743
"tailwindcss": ">=2.2.19"
2844
},
2945
"dependencies": {
3046
"tailwindcss": "^3.4.3"
47+
},
48+
"devDependencies": {
49+
"typescript": "^5.3.3",
50+
"unbuild": "^2.0.0"
3151
}
3252
}

packages/tailwindcss-color-preset/colors/el-colors.js renamed to packages/tailwindcss-color-preset/src/colors/el-colors.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// refer to https://github.com/element-plus/element-plus/blob/dev/packages/theme-chalk/src/common/var.scss
2+
import type { ColorConfig } from './types'
23

3-
export default {
4+
const ElColors: ColorConfig = {
45
'el-primary': {
56
DEFAULT: '#409eff',
67
3: '#79bbff',
@@ -56,3 +57,5 @@ export default {
5657
dark: '#73767a',
5758
},
5859
}
60+
61+
export default ElColors

packages/tailwindcss-color-preset/colors/index.js renamed to packages/tailwindcss-color-preset/src/colors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { default as ElColors } from './el-colors'
22
export { default as NaiveColors } from './naive-colors'
33
export { default as VanColors } from './van-colors'
44
export { default as VanBackground } from './van-background'
5+
export type * from './types'
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
export default {
1+
import type { ColorConfig } from './types'
2+
3+
const NaiveColors: ColorConfig = {
24
'n-primary': '#18a058',
35
'n-success': '#18a058',
46
'n-info': '#2080f0',
57
'n-warning': '#f0a020',
68
'n-error': '#d03050',
79
'n-gray': '#333639',
810
}
11+
12+
export default NaiveColors
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* tailwindcss color param
3+
* @example
4+
* {
5+
* DEFAULT: '#409eff',
6+
* 3: '#79bbff',
7+
* 5: '#a0cfff',
8+
* 7: '#c6e2ff',
9+
* 8: '#d9ecff',
10+
* 9: '#ecf5ff',
11+
* dark: '#337ecc',
12+
* }
13+
*
14+
*/
15+
export type Color = string | { [key: string]: string }
16+
17+
/**
18+
* tailwindcss color param
19+
* @example
20+
* 'el-primary': {
21+
* DEFAULT: '#409eff',
22+
* 3: '#79bbff',
23+
* 5: '#a0cfff',
24+
* 7: '#c6e2ff',
25+
* 8: '#d9ecff',
26+
* 9: '#ecf5ff',
27+
* dark: '#337ecc',
28+
* },
29+
*
30+
*/
31+
export interface ColorConfig {
32+
[key: string]: Color
33+
}

0 commit comments

Comments
 (0)