xt-element-ui 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.common.js +628 -377
- package/lib/index.css +1 -1
- package/lib/index.umd.js +628 -377
- package/lib/index.umd.min.js +1 -1
- package/package.json +2 -2
- package/src/components/button/index.vue +48 -15
- package/src/components/button/style/index.scss +130 -0
- package/src/components/card/index.vue +20 -41
- package/src/components/card/style/index.scss +49 -0
- package/src/components/card-item/index.vue +85 -40
- package/src/components/card-item/style/index.scss +72 -0
- package/src/components/config-provider/index.js +2 -0
- package/src/components/config-provider/index.vue +176 -0
- package/src/components/config-provider/style/index.scss +12 -0
- package/src/components/flex-box/index.vue +21 -91
- package/src/components/flex-box/style/index.scss +91 -0
- package/src/components/index.scss +19 -0
- package/src/components/input/index.vue +28 -11
- package/src/components/input/style/index.scss +27 -0
- package/src/index.js +65 -122
- package/src/styles/export.scss +1 -1
- package/src/styles/theme/bg.scss +6 -0
- package/src/styles/theme/border.scss +4 -0
- package/src/styles/theme/color.scss +11 -0
- package/src/styles/theme/component.scss +70 -0
- package/src/styles/theme/dark.scss +29 -0
- package/src/styles/theme/font.scss +10 -0
- package/src/styles/theme/index.scss +11 -0
- package/src/styles/theme/radius.scss +4 -0
- package/src/styles/theme/shadow.scss +3 -0
- package/src/styles/theme/spacing.scss +5 -0
- package/src/styles/theme/text.scss +5 -0
- package/src/styles/theme/transition.scss +3 -0
- package/src/styles/theme-element.scss +0 -10
- package/src/styles/variables.scss +1 -119
- package/src/styles/vars.scss +168 -0
- package/src/utils/index.js +195 -124
- package/src/styles/theme.scss +0 -128
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
@import './theme/index.scss';
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
// 主色调系列
|
|
5
|
+
--xt-color-primary: #{$xt-color-primary};
|
|
6
|
+
--xt-color-success: #{$xt-color-success};
|
|
7
|
+
--xt-color-warning: #{$xt-color-warning};
|
|
8
|
+
--xt-color-danger: #{$xt-color-danger};
|
|
9
|
+
--xt-color-info: #{$xt-color-info};
|
|
10
|
+
|
|
11
|
+
// 主色调浅色系列
|
|
12
|
+
--xt-color-primary-light-3: #{$xt-color-primary-light-3};
|
|
13
|
+
--xt-color-primary-light-5: #{$xt-color-primary-light-5};
|
|
14
|
+
--xt-color-primary-light-7: #{$xt-color-primary-light-7};
|
|
15
|
+
--xt-color-primary-light-8: #{$xt-color-primary-light-8};
|
|
16
|
+
--xt-color-primary-light-9: #{$xt-color-primary-light-9};
|
|
17
|
+
|
|
18
|
+
// 文字颜色
|
|
19
|
+
--xt-color-text-primary: #{$xt-color-text-primary};
|
|
20
|
+
--xt-color-text-regular: #{$xt-color-text-regular};
|
|
21
|
+
--xt-color-text-secondary: #{$xt-color-text-secondary};
|
|
22
|
+
--xt-color-text-placeholder: #{$xt-color-text-placeholder};
|
|
23
|
+
--xt-color-text-disabled: #{$xt-color-text-disabled};
|
|
24
|
+
|
|
25
|
+
// 背景颜色
|
|
26
|
+
--xt-color-bg-primary: #{$xt-color-bg-primary};
|
|
27
|
+
--xt-color-bg-secondary: #{$xt-color-bg-secondary};
|
|
28
|
+
--xt-color-bg-hover: #{$xt-color-bg-hover};
|
|
29
|
+
--xt-color-bg-container: #{$xt-color-bg-container};
|
|
30
|
+
--xt-color-bg-overlay: #{$xt-color-bg-overlay};
|
|
31
|
+
|
|
32
|
+
// 边框颜色
|
|
33
|
+
--xt-color-border: #{$xt-color-border};
|
|
34
|
+
--xt-color-border-light: #{$xt-color-border-light};
|
|
35
|
+
--xt-color-border-lighter: #{$xt-color-border-lighter};
|
|
36
|
+
--xt-color-border-extra-light: #{$xt-color-border-extra-light};
|
|
37
|
+
|
|
38
|
+
// 字体大小
|
|
39
|
+
--xt-font-size-extra-large: #{$xt-font-size-extra-large};
|
|
40
|
+
--xt-font-size-large: #{$xt-font-size-large};
|
|
41
|
+
--xt-font-size-medium: #{$xt-font-size-medium};
|
|
42
|
+
--xt-font-size-base: #{$xt-font-size-base};
|
|
43
|
+
--xt-font-size-small: #{$xt-font-size-small};
|
|
44
|
+
--xt-font-size-extra-small: #{$xt-font-size-extra-small};
|
|
45
|
+
|
|
46
|
+
// 间距
|
|
47
|
+
--xt-spacing-xs: #{$xt-spacing-xs};
|
|
48
|
+
--xt-spacing-sm: #{$xt-spacing-sm};
|
|
49
|
+
--xt-spacing-md: #{$xt-spacing-md};
|
|
50
|
+
--xt-spacing-lg: #{$xt-spacing-lg};
|
|
51
|
+
--xt-spacing-xl: #{$xt-spacing-xl};
|
|
52
|
+
|
|
53
|
+
// 圆角
|
|
54
|
+
--xt-border-radius-base: #{$xt-border-radius-base};
|
|
55
|
+
--xt-border-radius-small: #{$xt-border-radius-small};
|
|
56
|
+
--xt-border-radius-round: #{$xt-border-radius-round};
|
|
57
|
+
--xt-border-radius-circle: #{$xt-border-radius-circle};
|
|
58
|
+
|
|
59
|
+
// 阴影
|
|
60
|
+
--xt-shadow-sm: #{$xt-shadow-sm};
|
|
61
|
+
--xt-shadow-md: #{$xt-shadow-md};
|
|
62
|
+
--xt-shadow-lg: #{$xt-shadow-lg};
|
|
63
|
+
|
|
64
|
+
// 过渡动画
|
|
65
|
+
--xt-transition-duration: #{$xt-transition-duration};
|
|
66
|
+
--xt-transition-duration-fast: #{$xt-transition-duration-fast};
|
|
67
|
+
|
|
68
|
+
// 按钮专用变量
|
|
69
|
+
--xt-button-height: #{$xt-button-height};
|
|
70
|
+
--xt-button-padding-x: #{$xt-button-padding-x};
|
|
71
|
+
--xt-button-padding-y: #{$xt-button-padding-y};
|
|
72
|
+
--xt-button-font-weight: #{$xt-button-font-weight};
|
|
73
|
+
--xt-button-border-width: #{$xt-button-border-width};
|
|
74
|
+
--xt-button-transition: #{$xt-button-transition};
|
|
75
|
+
|
|
76
|
+
// 卡片专用变量
|
|
77
|
+
--xt-card-bg-color: #{$xt-card-bg-color};
|
|
78
|
+
--xt-card-border-color: #{$xt-card-border-color};
|
|
79
|
+
--xt-card-border-radius: #{$xt-card-border-radius};
|
|
80
|
+
--xt-card-padding: #{$xt-card-padding};
|
|
81
|
+
--xt-card-header-padding: #{$xt-card-header-padding};
|
|
82
|
+
--xt-card-shadow: #{$xt-card-shadow};
|
|
83
|
+
|
|
84
|
+
// 卡片项专用变量
|
|
85
|
+
--xt-card-item-min-height: #{$xt-card-item-min-height};
|
|
86
|
+
--xt-card-item-gap: #{$xt-card-item-gap};
|
|
87
|
+
--xt-card-item-border-width: #{$xt-card-item-border-width};
|
|
88
|
+
|
|
89
|
+
// 输入框专用变量
|
|
90
|
+
--xt-input-height: #{$xt-input-height};
|
|
91
|
+
--xt-input-padding-x: #{$xt-input-padding-x};
|
|
92
|
+
--xt-input-bg-color: #{$xt-input-bg-color};
|
|
93
|
+
--xt-input-border-color: #{$xt-input-border-color};
|
|
94
|
+
--xt-input-text-color: #{$xt-input-text-color};
|
|
95
|
+
--xt-input-placeholder-color: #{$xt-input-placeholder-color};
|
|
96
|
+
|
|
97
|
+
// FlexBox 专用变量
|
|
98
|
+
--xt-flex-box-gap: #{$xt-flex-box-gap};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 暗色主题
|
|
102
|
+
html.dark, html[data-theme="dark"] {
|
|
103
|
+
--xt-color-primary: var(--xt-color-primary);
|
|
104
|
+
--xt-color-success: #{$xt-dark-color-success};
|
|
105
|
+
--xt-color-warning: #{$xt-dark-color-warning};
|
|
106
|
+
--xt-color-danger: #{$xt-dark-color-danger};
|
|
107
|
+
--xt-color-info: #{$xt-dark-color-info};
|
|
108
|
+
|
|
109
|
+
--xt-color-text-primary: #{$xt-dark-color-text-primary};
|
|
110
|
+
--xt-color-text-regular: #{$xt-dark-color-text-regular};
|
|
111
|
+
--xt-color-text-secondary: #{$xt-dark-color-text-secondary};
|
|
112
|
+
--xt-color-text-placeholder: #{$xt-dark-color-text-placeholder};
|
|
113
|
+
--xt-color-text-disabled: #{$xt-dark-color-text-disabled};
|
|
114
|
+
|
|
115
|
+
--xt-color-bg-primary: #{$xt-dark-color-bg-primary};
|
|
116
|
+
--xt-color-bg-secondary: #{$xt-dark-color-bg-secondary};
|
|
117
|
+
--xt-color-bg-hover: #{$xt-dark-color-bg-hover};
|
|
118
|
+
--xt-color-bg-container: #{$xt-dark-color-bg-container};
|
|
119
|
+
--xt-color-bg-overlay: #{$xt-dark-color-bg-overlay};
|
|
120
|
+
|
|
121
|
+
--xt-color-border: #{$xt-dark-color-border};
|
|
122
|
+
--xt-color-border-light: #{$xt-dark-color-border-light};
|
|
123
|
+
--xt-color-border-lighter: #{$xt-dark-color-border-lighter};
|
|
124
|
+
--xt-color-border-extra-light: #{$xt-dark-color-border-extra-light};
|
|
125
|
+
|
|
126
|
+
// 暗色主题下的组件变量
|
|
127
|
+
--xt-card-bg-color: #{$xt-dark-color-bg-primary};
|
|
128
|
+
--xt-card-border-color: #{$xt-dark-color-border};
|
|
129
|
+
--xt-input-bg-color: #{$xt-dark-color-bg-secondary};
|
|
130
|
+
--xt-input-border-color: #{$xt-dark-color-border};
|
|
131
|
+
--xt-input-text-color: #{$xt-dark-color-text-primary};
|
|
132
|
+
--xt-input-placeholder-color: #{$xt-dark-color-text-placeholder};
|
|
133
|
+
|
|
134
|
+
// 暗色主题按钮颜色变量
|
|
135
|
+
--xt-dark-button-primary-bg: #{$xt-dark-button-primary-bg};
|
|
136
|
+
--xt-dark-button-success-bg: #{$xt-dark-button-success-bg};
|
|
137
|
+
--xt-dark-button-warning-bg: #{$xt-dark-button-warning-bg};
|
|
138
|
+
--xt-dark-button-danger-bg: #{$xt-dark-button-danger-bg};
|
|
139
|
+
--xt-dark-button-info-bg: #{$xt-dark-button-info-bg};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 字体大小主题(基于增量)
|
|
143
|
+
[data-size="small"] {
|
|
144
|
+
--xt-font-size-extra-large: #{$xt-font-size-extra-large + $xt-font-size-increment-small};
|
|
145
|
+
--xt-font-size-large: #{$xt-font-size-large + $xt-font-size-increment-small};
|
|
146
|
+
--xt-font-size-medium: #{$xt-font-size-medium + $xt-font-size-increment-small};
|
|
147
|
+
--xt-font-size-base: #{$xt-font-size-base + $xt-font-size-increment-small};
|
|
148
|
+
--xt-font-size-small: #{$xt-font-size-small + $xt-font-size-increment-small};
|
|
149
|
+
--xt-font-size-extra-small: #{$xt-font-size-extra-small + $xt-font-size-increment-small};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[data-size="medium"] {
|
|
153
|
+
--xt-font-size-extra-large: #{$xt-font-size-extra-large + $xt-font-size-increment-medium};
|
|
154
|
+
--xt-font-size-large: #{$xt-font-size-large + $xt-font-size-increment-medium};
|
|
155
|
+
--xt-font-size-medium: #{$xt-font-size-medium + $xt-font-size-increment-medium};
|
|
156
|
+
--xt-font-size-base: #{$xt-font-size-base + $xt-font-size-increment-medium};
|
|
157
|
+
--xt-font-size-small: #{$xt-font-size-small + $xt-font-size-increment-medium};
|
|
158
|
+
--xt-font-size-extra-small: #{$xt-font-size-extra-small + $xt-font-size-increment-medium};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
[data-size="large"] {
|
|
162
|
+
--xt-font-size-extra-large: #{$xt-font-size-extra-large + $xt-font-size-increment-large};
|
|
163
|
+
--xt-font-size-large: #{$xt-font-size-large + $xt-font-size-increment-large};
|
|
164
|
+
--xt-font-size-medium: #{$xt-font-size-medium + $xt-font-size-increment-large};
|
|
165
|
+
--xt-font-size-base: #{$xt-font-size-base + $xt-font-size-increment-large};
|
|
166
|
+
--xt-font-size-small: #{$xt-font-size-small + $xt-font-size-increment-large};
|
|
167
|
+
--xt-font-size-extra-small: #{$xt-font-size-extra-small + $xt-font-size-increment-large};
|
|
168
|
+
}
|
package/src/utils/index.js
CHANGED
|
@@ -1,124 +1,195 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
// 默认配置
|
|
2
|
+
const defaultConfig = {
|
|
3
|
+
theme: 'light',
|
|
4
|
+
size: 'medium',
|
|
5
|
+
primaryColor: '#409EFF'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// 当前配置
|
|
9
|
+
let currentConfig = { ...defaultConfig }
|
|
10
|
+
|
|
11
|
+
// 调试:输出初始化信息
|
|
12
|
+
console.log('[XtElementUI] utils initialized with currentConfig:', currentConfig)
|
|
13
|
+
|
|
14
|
+
// 配置变更事件处理
|
|
15
|
+
const configChangeListeners = []
|
|
16
|
+
|
|
17
|
+
const emitConfigChange = function(key, value) {
|
|
18
|
+
configChangeListeners.forEach(listener => {
|
|
19
|
+
listener(key, value)
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 获取所有配置
|
|
24
|
+
export const getConfig = function() {
|
|
25
|
+
return { ...currentConfig }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 设置全局配置
|
|
29
|
+
export const setConfig = function(config) {
|
|
30
|
+
if (typeof config !== 'object' || config === null) {
|
|
31
|
+
console.warn('[XtElementUI] setConfig 必须传入对象参数')
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (config.theme !== undefined) {
|
|
36
|
+
setTheme(config.theme)
|
|
37
|
+
}
|
|
38
|
+
if (config.size !== undefined) {
|
|
39
|
+
setSize(config.size)
|
|
40
|
+
}
|
|
41
|
+
if (config.primaryColor !== undefined) {
|
|
42
|
+
setPrimaryColor(config.primaryColor)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// 设置主题
|
|
48
|
+
export const setTheme = function(theme) {
|
|
49
|
+
const validThemes = ['light', 'dark']
|
|
50
|
+
if (!validThemes.includes(theme)) {
|
|
51
|
+
console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
currentConfig.theme = theme
|
|
56
|
+
const root = document.documentElement
|
|
57
|
+
|
|
58
|
+
// 使用类名方式切换主题(兼容 Element Plus 风格)
|
|
59
|
+
if (theme === 'dark') {
|
|
60
|
+
root.classList.add('dark')
|
|
61
|
+
root.setAttribute('data-theme', 'dark')
|
|
62
|
+
} else {
|
|
63
|
+
root.classList.remove('dark')
|
|
64
|
+
root.removeAttribute('data-theme')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
emitConfigChange('theme', theme)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 设置字体大小
|
|
71
|
+
export const setSize = function(size) {
|
|
72
|
+
const validSizes = ['small', 'medium', 'large']
|
|
73
|
+
if (!validSizes.includes(size)) {
|
|
74
|
+
console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
currentConfig.size = size
|
|
79
|
+
document.documentElement.setAttribute('data-size', size)
|
|
80
|
+
emitConfigChange('size', size)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 将十六进制颜色转换为 RGB 对象
|
|
84
|
+
function hexToRgb(hex) {
|
|
85
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
|
|
86
|
+
return result ? {
|
|
87
|
+
r: parseInt(result[1], 16),
|
|
88
|
+
g: parseInt(result[2], 16),
|
|
89
|
+
b: parseInt(result[3], 16)
|
|
90
|
+
} : null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 将 RGB 对象转换为十六进制颜色
|
|
94
|
+
function rgbToHex(r, g, b) {
|
|
95
|
+
return '#' + [r, g, b].map(x => {
|
|
96
|
+
const hex = x.toString(16)
|
|
97
|
+
return hex.length === 1 ? '0' + hex : hex
|
|
98
|
+
}).join('')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 计算浅色系列(混合白色)
|
|
102
|
+
function lightenColor(hex, percent) {
|
|
103
|
+
const rgb = hexToRgb(hex)
|
|
104
|
+
if (!rgb) return hex
|
|
105
|
+
|
|
106
|
+
const amount = Math.round(2.55 * percent)
|
|
107
|
+
const r = Math.min(255, rgb.r + amount)
|
|
108
|
+
const g = Math.min(255, rgb.g + amount)
|
|
109
|
+
const b = Math.min(255, rgb.b + amount)
|
|
110
|
+
|
|
111
|
+
return rgbToHex(r, g, b)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 设置主色调
|
|
115
|
+
export const setPrimaryColor = function(color) {
|
|
116
|
+
// 颜色格式验证(支持 3/6/8 位十六进制)
|
|
117
|
+
const colorRegex = /^#[0-9A-Fa-f]{3}$|^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{8}$/
|
|
118
|
+
if (!colorRegex.test(color)) {
|
|
119
|
+
console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 转换为 6 位十六进制(去掉透明度)
|
|
124
|
+
let validColor = color
|
|
125
|
+
if (color.length === 4) {
|
|
126
|
+
// #RGB 转换为 #RRGGBB
|
|
127
|
+
validColor = '#' + color[1] + color[1] + color[2] + color[2] + color[3] + color[3]
|
|
128
|
+
} else if (color.length === 9) {
|
|
129
|
+
// #RRGGBBAA 转换为 #RRGGBB(去掉 Alpha)
|
|
130
|
+
validColor = color.substring(0, 7)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
currentConfig.primaryColor = validColor
|
|
134
|
+
|
|
135
|
+
// 设置主色调
|
|
136
|
+
document.documentElement.style.setProperty('--xt-color-primary', validColor)
|
|
137
|
+
|
|
138
|
+
// 动态计算并设置浅色系列
|
|
139
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-3', lightenColor(validColor, 30))
|
|
140
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-5', lightenColor(validColor, 50))
|
|
141
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-7', lightenColor(validColor, 70))
|
|
142
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-8', lightenColor(validColor, 80))
|
|
143
|
+
document.documentElement.style.setProperty('--xt-color-primary-light-9', lightenColor(validColor, 90))
|
|
144
|
+
|
|
145
|
+
emitConfigChange('primaryColor', validColor)
|
|
146
|
+
console.log('[XtElementUI] 主色调已设置为:', validColor)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 获取当前主题
|
|
150
|
+
export const getTheme = function() {
|
|
151
|
+
return currentConfig.theme
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 获取当前字体大小
|
|
155
|
+
export const getSize = function() {
|
|
156
|
+
return currentConfig.size
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 获取当前主色调
|
|
160
|
+
export const getPrimaryColor = function() {
|
|
161
|
+
return currentConfig.primaryColor
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 重置为默认配置
|
|
165
|
+
export const resetConfig = function() {
|
|
166
|
+
setConfig(defaultConfig)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 监听配置变更
|
|
170
|
+
export const onConfigChange = function(listener) {
|
|
171
|
+
if (typeof listener === 'function') {
|
|
172
|
+
configChangeListeners.push(listener)
|
|
173
|
+
return function() {
|
|
174
|
+
const index = configChangeListeners.indexOf(listener)
|
|
175
|
+
if (index > -1) {
|
|
176
|
+
configChangeListeners.splice(index, 1)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
console.warn('[XtElementUI] onConfigChange 必须传入函数')
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default {
|
|
185
|
+
setTheme,
|
|
186
|
+
setSize,
|
|
187
|
+
setPrimaryColor,
|
|
188
|
+
getConfig,
|
|
189
|
+
setConfig,
|
|
190
|
+
getTheme,
|
|
191
|
+
getSize,
|
|
192
|
+
getPrimaryColor,
|
|
193
|
+
resetConfig,
|
|
194
|
+
onConfigChange
|
|
195
|
+
}
|
package/src/styles/theme.scss
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
@use './variables.scss' as *;
|
|
2
|
-
|
|
3
|
-
:root {
|
|
4
|
-
// 主色调系列
|
|
5
|
-
--xt-color-primary: #{$xt-color-primary};
|
|
6
|
-
--xt-color-success: #{$xt-color-success};
|
|
7
|
-
--xt-color-warning: #{$xt-color-warning};
|
|
8
|
-
--xt-color-danger: #{$xt-color-danger};
|
|
9
|
-
--xt-color-info: #{$xt-color-info};
|
|
10
|
-
|
|
11
|
-
// 主色调浅色系列
|
|
12
|
-
--xt-color-primary-light-3: #{$xt-color-primary-light-3};
|
|
13
|
-
--xt-color-primary-light-5: #{$xt-color-primary-light-5};
|
|
14
|
-
--xt-color-primary-light-7: #{$xt-color-primary-light-7};
|
|
15
|
-
--xt-color-primary-light-8: #{$xt-color-primary-light-8};
|
|
16
|
-
--xt-color-primary-light-9: #{$xt-color-primary-light-9};
|
|
17
|
-
|
|
18
|
-
// 文字颜色
|
|
19
|
-
--xt-color-text-primary: #{$xt-color-text-primary};
|
|
20
|
-
--xt-color-text-regular: #{$xt-color-text-regular};
|
|
21
|
-
--xt-color-text-secondary: #{$xt-color-text-secondary};
|
|
22
|
-
--xt-color-text-placeholder: #{$xt-color-text-placeholder};
|
|
23
|
-
--xt-color-text-disabled: #{$xt-color-text-disabled};
|
|
24
|
-
|
|
25
|
-
// 背景颜色
|
|
26
|
-
--xt-color-bg-primary: #{$xt-color-bg-primary};
|
|
27
|
-
--xt-color-bg-secondary: #{$xt-color-bg-secondary};
|
|
28
|
-
--xt-color-bg-hover: #{$xt-color-bg-hover};
|
|
29
|
-
--xt-color-bg-container: #{$xt-color-bg-container};
|
|
30
|
-
--xt-color-bg-overlay: #{$xt-color-bg-overlay};
|
|
31
|
-
|
|
32
|
-
// 边框颜色
|
|
33
|
-
--xt-color-border: #{$xt-color-border};
|
|
34
|
-
--xt-color-border-light: #{$xt-color-border-light};
|
|
35
|
-
--xt-color-border-lighter: #{$xt-color-border-lighter};
|
|
36
|
-
--xt-color-border-extra-light: #{$xt-color-border-extra-light};
|
|
37
|
-
|
|
38
|
-
// 字体大小
|
|
39
|
-
--xt-font-size-extra-large: #{$xt-font-size-extra-large};
|
|
40
|
-
--xt-font-size-large: #{$xt-font-size-large};
|
|
41
|
-
--xt-font-size-medium: #{$xt-font-size-medium};
|
|
42
|
-
--xt-font-size-base: #{$xt-font-size-base};
|
|
43
|
-
--xt-font-size-small: #{$xt-font-size-small};
|
|
44
|
-
--xt-font-size-extra-small: #{$xt-font-size-extra-small};
|
|
45
|
-
|
|
46
|
-
// 间距
|
|
47
|
-
--xt-spacing-xs: #{$xt-spacing-xs};
|
|
48
|
-
--xt-spacing-sm: #{$xt-spacing-sm};
|
|
49
|
-
--xt-spacing-md: #{$xt-spacing-md};
|
|
50
|
-
--xt-spacing-lg: #{$xt-spacing-lg};
|
|
51
|
-
--xt-spacing-xl: #{$xt-spacing-xl};
|
|
52
|
-
|
|
53
|
-
// 圆角
|
|
54
|
-
--xt-border-radius-base: #{$xt-border-radius-base};
|
|
55
|
-
--xt-border-radius-small: #{$xt-border-radius-small};
|
|
56
|
-
--xt-border-radius-round: #{$xt-border-radius-round};
|
|
57
|
-
--xt-border-radius-circle: #{$xt-border-radius-circle};
|
|
58
|
-
|
|
59
|
-
// 阴影
|
|
60
|
-
--xt-shadow-sm: #{$xt-shadow-sm};
|
|
61
|
-
--xt-shadow-md: #{$xt-shadow-md};
|
|
62
|
-
--xt-shadow-lg: #{$xt-shadow-lg};
|
|
63
|
-
|
|
64
|
-
// 过渡动画
|
|
65
|
-
--xt-transition-duration: #{$xt-transition-duration};
|
|
66
|
-
--xt-transition-duration-fast: #{$xt-transition-duration-fast};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// 暗色主题 - 只控制颜色
|
|
70
|
-
[data-theme="dark"] {
|
|
71
|
-
--xt-color-primary: #{$xt-color-primary};
|
|
72
|
-
--xt-color-success: #67C23A;
|
|
73
|
-
--xt-color-warning: #E6A23C;
|
|
74
|
-
--xt-color-danger: #F56C6C;
|
|
75
|
-
--xt-color-info: #909399;
|
|
76
|
-
|
|
77
|
-
--xt-color-text-primary: rgba(255, 255, 255, 0.95);
|
|
78
|
-
--xt-color-text-regular: rgba(255, 255, 255, 0.8);
|
|
79
|
-
--xt-color-text-secondary: rgba(255, 255, 255, 0.6);
|
|
80
|
-
--xt-color-text-placeholder: rgba(255, 255, 255, 0.4);
|
|
81
|
-
--xt-color-text-disabled: rgba(255, 255, 255, 0.3);
|
|
82
|
-
|
|
83
|
-
--xt-color-bg-primary: #1f1f1f;
|
|
84
|
-
--xt-color-bg-secondary: #2d2d2d;
|
|
85
|
-
--xt-color-bg-hover: #3d3d3d;
|
|
86
|
-
--xt-color-bg-container: #1f1f1f;
|
|
87
|
-
--xt-color-bg-overlay: #2d2d2d;
|
|
88
|
-
|
|
89
|
-
--xt-color-border: #434343;
|
|
90
|
-
--xt-color-border-light: #3d3d3d;
|
|
91
|
-
--xt-color-border-lighter: #3d3d3d;
|
|
92
|
-
--xt-color-border-extra-light: #434343;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 紧凑主题
|
|
96
|
-
[data-theme="compact"] {
|
|
97
|
-
--xt-font-size-base: 13px;
|
|
98
|
-
--xt-font-size-small: 12px;
|
|
99
|
-
|
|
100
|
-
--xt-spacing-xs: 3px;
|
|
101
|
-
--xt-spacing-sm: 6px;
|
|
102
|
-
--xt-spacing-md: 10px;
|
|
103
|
-
--xt-spacing-lg: 14px;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 大字体主题
|
|
107
|
-
[data-size="large"] {
|
|
108
|
-
--xt-font-size-base: 16px;
|
|
109
|
-
--xt-font-size-medium: 18px;
|
|
110
|
-
--xt-font-size-large: 20px;
|
|
111
|
-
|
|
112
|
-
--xt-spacing-xs: 5px;
|
|
113
|
-
--xt-spacing-sm: 10px;
|
|
114
|
-
--xt-spacing-md: 15px;
|
|
115
|
-
--xt-spacing-lg: 20px;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 小字体主题
|
|
119
|
-
[data-size="small"] {
|
|
120
|
-
--xt-font-size-base: 12px;
|
|
121
|
-
--xt-font-size-small: 11px;
|
|
122
|
-
--xt-font-size-extra-small: 10px;
|
|
123
|
-
|
|
124
|
-
--xt-spacing-xs: 3px;
|
|
125
|
-
--xt-spacing-sm: 6px;
|
|
126
|
-
--xt-spacing-md: 9px;
|
|
127
|
-
--xt-spacing-lg: 12px;
|
|
128
|
-
}
|