xt-element-ui 1.0.5 → 1.0.7

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.
@@ -1,41 +1,119 @@
1
- $xt-color-primary: #1890ff;
2
- $xt-color-success: #52c41a;
3
- $xt-color-warning: #faad14;
4
- $xt-color-danger: #f5222d;
5
- $xt-color-info: #1890ff;
6
-
7
- $xt-color-text-primary: rgba(0, 0, 0, 0.85);
8
- $xt-color-text-secondary: rgba(0, 0, 0, 0.65);
9
- $xt-color-text-placeholder: rgba(0, 0, 0, 0.45);
10
- $xt-color-text-disabled: rgba(0, 0, 0, 0.25);
11
-
12
- $xt-color-bg-primary: #ffffff;
13
- $xt-color-bg-secondary: #f5f5f5;
14
- $xt-color-bg-hover: #f5f5f5;
15
-
16
- $xt-color-border: #d9d9d9;
17
- $xt-color-border-light: #f0f0f0;
18
-
19
- $xt-font-size-xs: 12px;
20
- $xt-font-size-sm: 14px;
21
- $xt-font-size-md: 16px;
22
- $xt-font-size-lg: 18px;
23
- $xt-font-size-xl: 20px;
24
-
25
- $xt-spacing-xs: 4px;
26
- $xt-spacing-sm: 8px;
27
- $xt-spacing-md: 16px;
28
- $xt-spacing-lg: 24px;
29
- $xt-spacing-xl: 32px;
30
-
31
- $xt-border-radius-sm: 4px;
32
- $xt-border-radius-md: 6px;
33
- $xt-border-radius-lg: 8px;
34
-
35
- $xt-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
36
- $xt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
37
- $xt-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
38
-
39
- $xt-transition-fast: 0.15s ease;
40
- $xt-transition-normal: 0.2s ease;
41
- $xt-transition-slow: 0.3s ease;
1
+ // ===========================
2
+ // Element UI 标准颜色变量
3
+ // ===========================
4
+
5
+ // 主色调系列
6
+ $xt-color-primary: #409EFF; // 主颜色 - Element UI 标准蓝色
7
+ $xt-color-success: #67C23A; // 成功色 - Element UI 标准绿色
8
+ $xt-color-warning: #E6A23C; // 警告色 - Element UI 标准橙色
9
+ $xt-color-danger: #F56C6C; // 危险色 - Element UI 标准红色
10
+ $xt-color-info: #909399; // 信息色 - Element UI 标准灰色
11
+
12
+ // 主色调浅色系列(用于 hover、active 等状态)
13
+ $xt-color-primary-light-3: #79BBFF; // 主色浅色 30%
14
+ $xt-color-primary-light-5: #A0CFFF; // 主色浅色 50%
15
+ $xt-color-primary-light-7: #C6E2FF; // 主色浅色 70%
16
+ $xt-color-primary-light-8: #D9ECFF; // 主色浅色 80%
17
+ $xt-color-primary-light-9: #ECF5FF; // 主色浅色 90%
18
+
19
+ // ===========================
20
+ // 文字颜色
21
+ // ===========================
22
+ $xt-color-text-primary: #303133; // 主要文字颜色 - 最深
23
+ $xt-color-text-regular: #606266; // 常规文字颜色 - 中等
24
+ $xt-color-text-secondary: #909399; // 次要文字颜色 - 较浅
25
+ $xt-color-text-placeholder: #C0C4CC; // 占位符文字颜色
26
+ $xt-color-text-disabled: #C0C4CC; // 禁用状态文字颜色
27
+
28
+ // ===========================
29
+ // 背景颜色
30
+ // ===========================
31
+ $xt-color-bg-primary: #ffffff; // 主背景色 - 白色
32
+ $xt-color-bg-secondary: #f5f7fa; // 次要背景色 - 浅灰
33
+ $xt-color-bg-hover: #f5f5f5; // 悬停背景色
34
+ $xt-color-bg-container: #f5f7fa; // 容器背景色
35
+ $xt-color-bg-main: #ffffff; // 主内容区域背景色
36
+ $xt-color-bg-overlay: #ffffff; // 浮层背景色
37
+
38
+ // ===========================
39
+ // 边框颜色
40
+ // ===========================
41
+ $xt-color-border: #DCDFE6; // 边框颜色 - 标准
42
+ $xt-color-border-light: #E4E7ED; // 边框浅色
43
+ $xt-color-border-lighter: #EBEEF5; // 边框更浅色
44
+ $xt-color-border-extra-light: #F2F6FC; // 边框极浅色
45
+
46
+ // ===========================
47
+ // 字体大小
48
+ // ===========================
49
+ $xt-font-size-extra-large: 20px; // 特大字体
50
+ $xt-font-size-large: 18px; // 大字体
51
+ $xt-font-size-medium: 16px; // 中等字体
52
+ $xt-font-size-base: 14px; // 基准字体 - Element UI 默认
53
+ $xt-font-size-small: 13px; // 小字体
54
+ $xt-font-size-extra-small: 12px; // 特小字体
55
+
56
+ // ===========================
57
+ // 间距
58
+ // ===========================
59
+ $xt-spacing-xs: 4px; // 最小间距
60
+ $xt-spacing-sm: 8px; // 小间距
61
+ $xt-spacing-md: 12px; // 中间距
62
+ $xt-spacing-lg: 16px; // 大间距
63
+ $xt-spacing-xl: 20px; // 特大间距
64
+
65
+ // ===========================
66
+ // 圆角
67
+ // ===========================
68
+ $xt-border-radius-base: 4px; // 基准圆角
69
+ $xt-border-radius-small: 2px; // 小圆角
70
+ $xt-border-radius-round: 20px; // 圆角(胶囊状)
71
+ $xt-border-radius-circle: 50%; // 圆形
72
+
73
+ // ===========================
74
+ // 阴影
75
+ // ===========================
76
+ $xt-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04); // 小阴影
77
+ $xt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08); // 中等阴影
78
+ $xt-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12); // 大阴影
79
+
80
+ // ===========================
81
+ // 过渡动画
82
+ // ===========================
83
+ $xt-transition-duration: 0.3s; // 默认过渡时长
84
+ $xt-transition-duration-fast: 0.2s; // 快速过渡时长
85
+ $xt-transition-ease: ease; // 缓动函数
86
+
87
+ // ===========================
88
+ // 布局 / 头部 / 导航 专用变量
89
+ // ===========================
90
+
91
+ // 头部导航
92
+ $xt-header-bg: #ffffff; // 头部背景色
93
+ $xt-header-text-color: #303133; // 头部文字颜色
94
+ $xt-header-active-text: #409EFF; // 头部激活状态文字颜色
95
+ $xt-header-hover-text: #409EFF; // 头部悬停状态文字颜色
96
+
97
+ // 汉堡菜单按钮
98
+ $xt-hamburger-bg: #409EFF; // 汉堡按钮背景色
99
+
100
+ // 侧边菜单
101
+ $xt-menu-bg: #304156; // 菜单背景色
102
+ $xt-menu-hover: #263445; // 菜单悬停背景色
103
+ $xt-menu-text: #bfcbd9; // 菜单文字颜色
104
+ $xt-menu-active-text: #ffffff; // 菜单激活状态文字颜色
105
+
106
+ // 子菜单
107
+ $xt-sub-menu-bg: #1f2d3d; // 子菜单背景色
108
+ $xt-sub-menu-hover: #001528; // 子菜单悬停背景色
109
+
110
+ // ===========================
111
+ // 弹窗专用变量
112
+ // ===========================
113
+ $xt-dialog-bg: #ffffff; // 弹窗背景色
114
+ $xt-dialog-title: #303133; // 弹窗标题文字颜色
115
+
116
+ // ===========================
117
+ // TAG 标签专用变量
118
+ // ===========================
119
+ $xt-tag-bg: #ffffff; // 标签背景色
@@ -0,0 +1,124 @@
1
+
2
+ // 默认配置
3
+ const defaultConfig = {
4
+ theme: 'light',
5
+ size: 'medium',
6
+ primaryColor: '#1890ff'
7
+ }
8
+
9
+ // 当前配置
10
+ let currentConfig = { ...defaultConfig }
11
+
12
+ // 配置变更事件处理
13
+ const configChangeListeners = []
14
+
15
+ const emitConfigChange = function(key, value) {
16
+ configChangeListeners.forEach(listener => {
17
+ listener(key, value)
18
+ })
19
+ }
20
+
21
+ // 获取所有配置
22
+ export const getConfig = function() {
23
+ return { ...currentConfig }
24
+ }
25
+
26
+ // 设置全局配置
27
+ export const setConfig = function(config) {
28
+ if (typeof config !== 'object' || config === null) {
29
+ console.warn('[XtElementUI] setConfig 必须传入对象参数')
30
+ return
31
+ }
32
+
33
+ if (config.theme !== undefined) {
34
+ setTheme(config.theme)
35
+ }
36
+ if (config.size !== undefined) {
37
+ setSize(config.size)
38
+ }
39
+ if (config.primaryColor !== undefined) {
40
+ setPrimaryColor(config.primaryColor)
41
+ }
42
+ }
43
+
44
+
45
+ // 设置主题
46
+ export const setTheme = function(theme) {
47
+ const validThemes = ['light', 'dark', 'compact']
48
+ if (!validThemes.includes(theme)) {
49
+ console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
50
+ return
51
+ }
52
+
53
+ currentConfig.theme = theme
54
+ document.documentElement.setAttribute('data-theme', theme)
55
+ emitConfigChange('theme', theme)
56
+ }
57
+
58
+ // 设置字体大小
59
+ export const setSize = function(size) {
60
+ const validSizes = ['small', 'medium', 'large']
61
+ if (!validSizes.includes(size)) {
62
+ console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
63
+ return
64
+ }
65
+
66
+ currentConfig.size = size
67
+ document.documentElement.setAttribute('data-size', size)
68
+ emitConfigChange('size', size)
69
+ }
70
+
71
+ // 设置主色调
72
+ export const setPrimaryColor = function(color) {
73
+ // 简单的颜色格式验证
74
+ const colorRegex = /^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/
75
+ if (!colorRegex.test(color)) {
76
+ console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
77
+ return
78
+ }
79
+
80
+ currentConfig.primaryColor = color
81
+ document.documentElement.style.setProperty('--xt-color-primary', color)
82
+ emitConfigChange('primaryColor', color)
83
+ }
84
+
85
+ // 获取当前主题
86
+ export const getTheme = function() {
87
+ return currentConfig.theme
88
+ }
89
+
90
+ // 获取当前字体大小
91
+ export const getSize = function() {
92
+ return currentConfig.size
93
+ }
94
+
95
+ // 获取当前主色调
96
+ export const getPrimaryColor = function() {
97
+ return currentConfig.primaryColor
98
+ }
99
+
100
+ // 重置为默认配置
101
+ export const resetConfig = function() {
102
+ setConfig(defaultConfig)
103
+ }
104
+
105
+ // 监听配置变更
106
+ export const onConfigChange = function(listener) {
107
+ if (typeof listener === 'function') {
108
+ configChangeListeners.push(listener)
109
+ return function() {
110
+ const index = configChangeListeners.indexOf(listener)
111
+ if (index > -1) {
112
+ configChangeListeners.splice(index, 1)
113
+ }
114
+ }
115
+ } else {
116
+ console.warn('[XtElementUI] onConfigChange 必须传入函数')
117
+ }
118
+ }
119
+
120
+ export default {
121
+ setTheme,
122
+ setSize,
123
+ setPrimaryColor
124
+ }