Skip to content

Commit 04ffad4

Browse files
committed
feat: use tailwindcss Config type to check
1 parent 680594e commit 04ffad4

File tree

8 files changed

+20
-55
lines changed

8 files changed

+20
-55
lines changed

packages/tailwindcss-color-preset/src/colors/el-colors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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'
3-
4-
const ElColors: ColorConfig = {
2+
const ElColors = {
53
'el-primary': {
64
DEFAULT: '#409eff',
75
3: '#79bbff',

packages/tailwindcss-color-preset/src/colors/naive-colors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { ColorConfig } from './types'
2-
3-
const NaiveColors: ColorConfig = {
1+
const NaiveColors = {
42
'n-primary': '#18a058',
53
'n-success': '#18a058',
64
'n-info': '#2080f0',

packages/tailwindcss-color-preset/src/colors/types.ts

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,10 @@
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-
}
34-
351
/**
362
* select color
373
* @example
384
* {
39-
* element: true
5+
* element: true,
6+
* naive: true,
7+
* vant: true,
408
* }
419
*/
4210
export interface ColorOption {

packages/tailwindcss-color-preset/src/colors/van-background.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { ColorConfig } from './types'
2-
3-
const VanBackground: ColorConfig = {
1+
const VanBackground = {
42
'van-gradient-red': 'linear-gradient(to right, #ff6034, #ee0a24)',
53
'van-gradient-orange': 'linear-gradient(to right, #ffd01e, #ff8917)',
64
}

packages/tailwindcss-color-preset/src/colors/van-colors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// refer to https://github.com/youzan/vant/blob/main/packages/vant/src/style/css-variables.less
2-
import type { ColorConfig } from './types'
3-
4-
const VanColors: ColorConfig = {
2+
const VanColors = {
53
'van-primary': '#1989fa',
64
'van-success': '#07c160',
75
'van-danger': '#ee0a24',

packages/tailwindcss-color-preset/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isPackageExists } from 'local-pkg'
2+
import type { Config } from 'tailwindcss'
23
import {
34
ElColors,
45
NaiveColors,
@@ -15,7 +16,8 @@ export default (opt: ColorOption = {
1516
element: ELEMENT,
1617
naive: NAIVE,
1718
vant: VANT,
18-
}) => ({
19+
}): Config => ({
20+
content: [],
1921
theme: {
2022
extend: {
2123
colors: {

packages/tailwindcss-miniprogram-preset/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Config } from 'tailwindcss'
12
import {
23
extend,
34
fontSize,
@@ -11,7 +12,8 @@ export interface MiniProgramConfig {
1112

1213
export default (opt: MiniProgramConfig = {
1314
enable: true,
14-
}) => opt.enable ? {
15+
}): Config => opt.enable ? {
16+
content: [],
1517
theme: {
1618
/**
1719
* refer to https://tailwindcss.com/docs/customizing-spacing
@@ -33,6 +35,8 @@ export default (opt: MiniProgramConfig = {
3335
corePlugins: {
3436
preflight: false, // mp doesn't need base styles.
3537
},
36-
} : {}
38+
} : {
39+
content: [],
40+
}
3741

3842
export type * from './transform/types'

packages/tailwindcss-preset/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { isPackageExists } from 'local-pkg'
22
import color from '@leedomjs/tailwindcss-color-preset'
33
import mp from '@leedomjs/tailwindcss-miniprogram-preset'
44

5-
import type { Color, ColorOption } from '@leedomjs/tailwindcss-color-preset'
6-
7-
import type * as miniprogram from '@leedomjs/tailwindcss-miniprogram-preset'
5+
import type { ColorOption } from '@leedomjs/tailwindcss-color-preset'
6+
import type { Config } from 'tailwindcss'
87

98
/**
109
* combine color and mp types
11-
*
1210
* @example
1311
* {
1412
* mp?: boolean
@@ -30,7 +28,8 @@ export default (opt: PresetOption = {
3028
element: ELEMENT,
3129
naive: NAIVE,
3230
vant: VANT,
33-
}) => ({
31+
}): Config => ({
32+
content: [],
3433
presets: [
3534
color({
3635
element: opt.element ?? ELEMENT,

0 commit comments

Comments
 (0)