css2class 2.0.0

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.
Files changed (57) hide show
  1. package/API.md +1143 -0
  2. package/CHANGELOG.md +291 -0
  3. package/CONFIG.md +1096 -0
  4. package/CONTRIBUTING.md +571 -0
  5. package/MIGRATION.md +402 -0
  6. package/README.md +634 -0
  7. package/bin/class2css.js +380 -0
  8. package/class2css.config.js +124 -0
  9. package/common.css +3 -0
  10. package/configs/colors.config.js +62 -0
  11. package/configs/layout.config.js +110 -0
  12. package/configs/spacing.config.js +37 -0
  13. package/configs/typography.config.js +41 -0
  14. package/docs/.vitepress/config.mjs +65 -0
  15. package/docs/.vitepress/theme/custom.css +74 -0
  16. package/docs/.vitepress/theme/index.js +7 -0
  17. package/docs/guide/cli.md +97 -0
  18. package/docs/guide/concepts.md +63 -0
  19. package/docs/guide/config-template.md +365 -0
  20. package/docs/guide/config.md +275 -0
  21. package/docs/guide/faq.md +202 -0
  22. package/docs/guide/getting-started.md +83 -0
  23. package/docs/guide/important-and-static.md +67 -0
  24. package/docs/guide/incremental.md +162 -0
  25. package/docs/guide/rules-reference.md +354 -0
  26. package/docs/guide/units.md +57 -0
  27. package/docs/index.md +68 -0
  28. package/package.json +49 -0
  29. package/run.js +90 -0
  30. package/src/README.md +571 -0
  31. package/src/core/CacheManager.js +650 -0
  32. package/src/core/CompatibilityAdapter.js +264 -0
  33. package/src/core/ConfigManager.js +431 -0
  34. package/src/core/ConfigValidator.js +350 -0
  35. package/src/core/EventBus.js +77 -0
  36. package/src/core/FullScanManager.js +430 -0
  37. package/src/core/StateManager.js +631 -0
  38. package/src/docs/DocsServer.js +179 -0
  39. package/src/example.js +106 -0
  40. package/src/generators/DynamicClassGenerator.js +674 -0
  41. package/src/index.js +1046 -0
  42. package/src/parsers/ClassParser.js +572 -0
  43. package/src/parsers/ImportantParser.js +279 -0
  44. package/src/parsers/RegexCompiler.js +200 -0
  45. package/src/utils/ClassChangeTracker.js +366 -0
  46. package/src/utils/ConfigDiagnostics.js +673 -0
  47. package/src/utils/CssFormatter.js +261 -0
  48. package/src/utils/FileUtils.js +230 -0
  49. package/src/utils/Logger.js +150 -0
  50. package/src/utils/Throttle.js +172 -0
  51. package/src/utils/UnitProcessor.js +334 -0
  52. package/src/utils/WxssClassExtractor.js +137 -0
  53. package/src/watchers/ConfigWatcher.js +413 -0
  54. package/src/watchers/FileWatcher.js +133 -0
  55. package/src/writers/FileWriter.js +302 -0
  56. package/src/writers/UnifiedWriter.js +370 -0
  57. package/styles.config.js +250 -0
@@ -0,0 +1,380 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const Class2CSS = require('../src/index');
7
+ const DocsServer = require('../src/docs/DocsServer');
8
+
9
+ // 命令行参数解析
10
+ function parseArgs() {
11
+ const args = process.argv.slice(2);
12
+ const options = {
13
+ config: './class2css.config.js',
14
+ watch: true,
15
+ help: false,
16
+ version: false,
17
+ inputPath: null,
18
+ outputPath: null,
19
+ outputFileName: null,
20
+ outputType: null,
21
+ docs: false,
22
+ docsPort: 5173,
23
+ docsHost: '127.0.0.1',
24
+ docsOpen: false,
25
+ docsOnly: false,
26
+ };
27
+
28
+ for (let i = 0; i < args.length; i++) {
29
+ const arg = args[i];
30
+
31
+ switch (arg) {
32
+ case '--config':
33
+ case '-c':
34
+ options.config = args[++i];
35
+ break;
36
+ case '--no-watch':
37
+ options.watch = false;
38
+ break;
39
+ case '--input':
40
+ case '-i':
41
+ options.inputPath = args[++i];
42
+ break;
43
+ case '--output':
44
+ case '-o':
45
+ options.outputPath = args[++i];
46
+ break;
47
+ case '--output-file':
48
+ case '-f':
49
+ options.outputFileName = args[++i];
50
+ break;
51
+ case '--output-type':
52
+ case '-t':
53
+ options.outputType = args[++i];
54
+ break;
55
+ case '--docs':
56
+ options.docs = true;
57
+ break;
58
+ case '--docs-port':
59
+ options.docsPort = parseInt(args[++i], 10);
60
+ break;
61
+ case '--docs-host':
62
+ options.docsHost = args[++i];
63
+ break;
64
+ case '--docs-open':
65
+ options.docsOpen = true;
66
+ break;
67
+ case '--docs-only':
68
+ options.docsOnly = true;
69
+ options.docs = true;
70
+ break;
71
+ case '--help':
72
+ case '-h':
73
+ options.help = true;
74
+ break;
75
+ case '--version':
76
+ case '-v':
77
+ options.version = true;
78
+ break;
79
+ default:
80
+ if (arg.startsWith('-')) {
81
+ console.error(`Unknown option: ${arg}`);
82
+ process.exit(1);
83
+ }
84
+ }
85
+ }
86
+
87
+ if (Number.isNaN(options.docsPort)) {
88
+ console.error('❌ Invalid --docs-port value. It must be a number.');
89
+ process.exit(1);
90
+ }
91
+
92
+ return options;
93
+ }
94
+
95
+ function openUrl(url) {
96
+ try {
97
+ if (process.platform === 'win32') {
98
+ // Use "start" via cmd
99
+ const child = spawn('cmd', ['/c', 'start', '""', url], { stdio: 'ignore', detached: true });
100
+ child.unref();
101
+ } else if (process.platform === 'darwin') {
102
+ const child = spawn('open', [url], { stdio: 'ignore', detached: true });
103
+ child.unref();
104
+ } else {
105
+ const child = spawn('xdg-open', [url], { stdio: 'ignore', detached: true });
106
+ child.unref();
107
+ }
108
+ } catch (_) {
109
+ // ignore
110
+ }
111
+ }
112
+
113
+ // 显示帮助信息
114
+ function showHelp() {
115
+ console.log(`
116
+ Class2CSS - Dynamic CSS Generator for WeChat Mini Program
117
+
118
+ Usage: class2css [options]
119
+
120
+ Options:
121
+ -c, --config <path> Configuration file path (default: ./class2css.config.js)
122
+ -i, --input <path> Override input directory path (runtime override)
123
+ -o, --output <path> Override output directory path (runtime override)
124
+ -f, --output-file <name> Override output file name (runtime override)
125
+ -t, --output-type <type> Override output type: filePath or uniFile (runtime override)
126
+ --no-watch Disable file watching mode
127
+ --docs Start VitePress docs server alongside Class2CSS
128
+ --docs-port <port> Docs server port (default: 5173; auto-increment if occupied)
129
+ --docs-host <host> Docs server host (default: 127.0.0.1)
130
+ --docs-open Open docs URL in browser after start (default: off)
131
+ --docs-only Only start docs server (no Class2CSS run)
132
+ -h, --help Show this help message
133
+ -v, --version Show version information
134
+
135
+ Examples:
136
+ class2css # Run with default config
137
+ class2css -c ./config.js # Run with custom config
138
+ class2css --no-watch # Run without file watching
139
+ class2css -i ./src -o ./dist # Override input and output directories
140
+ class2css -i ./pages -o ./styles -f app.wxss # Override input, output and filename
141
+ class2css -i ./src -o ./dist -t uniFile # Override input, output and output type
142
+ class2css --docs # Run and start docs server
143
+ class2css --docs-only --docs-open # Only start docs and open browser
144
+
145
+ Configuration:
146
+ The tool reads configuration from class2css.config.js by default.
147
+ Runtime overrides (--input, --output, etc.) will override values in the config file.
148
+ See documentation for configuration options.
149
+ `);
150
+ }
151
+
152
+ // 显示版本信息
153
+ function showVersion() {
154
+ const packagePath = path.join(__dirname, '../package.json');
155
+ try {
156
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
157
+ console.log(`Class2CSS v${packageJson.version || '1.0.0'}`);
158
+ } catch (error) {
159
+ console.log('Class2CSS v1.0.0');
160
+ }
161
+ }
162
+
163
+ // 检查配置文件是否存在
164
+ function checkConfig(configPath) {
165
+ const absolutePath = path.resolve(configPath);
166
+ if (!fs.existsSync(absolutePath)) {
167
+ console.error(`Configuration file not found: ${absolutePath}`);
168
+ console.error('Please create a class2css.config.js file or specify a valid config path.');
169
+ process.exit(1);
170
+ }
171
+ return absolutePath;
172
+ }
173
+
174
+ // 主函数
175
+ async function main() {
176
+ let docsServer = null;
177
+ let class2css = null;
178
+ let shuttingDown = false;
179
+
180
+ const shutdown = async (signal, exitCode = 0, error = null) => {
181
+ if (shuttingDown) return;
182
+ shuttingDown = true;
183
+
184
+ if (error) {
185
+ console.error(`\n❌ ${signal}:`, error);
186
+ } else {
187
+ console.log(`\n🛑 Received ${signal}, stopping...`);
188
+ }
189
+
190
+ try {
191
+ if (class2css) {
192
+ await class2css.stop();
193
+ }
194
+ } catch (_) {}
195
+
196
+ try {
197
+ if (docsServer) {
198
+ await docsServer.stop();
199
+ }
200
+ } catch (_) {}
201
+
202
+ process.exit(exitCode);
203
+ };
204
+
205
+ // 兜底:异常/拒绝时也清理 docs 子进程
206
+ process.on('uncaughtException', (err) => shutdown('uncaughtException', 1, err));
207
+ process.on('unhandledRejection', (reason) => shutdown('unhandledRejection', 1, reason));
208
+
209
+ try {
210
+ const options = parseArgs();
211
+
212
+ // 处理特殊命令
213
+ if (options.help) {
214
+ showHelp();
215
+ return;
216
+ }
217
+
218
+ if (options.version) {
219
+ showVersion();
220
+ return;
221
+ }
222
+
223
+ // docs-only mode: only start docs server
224
+ if (options.docsOnly) {
225
+ docsServer = new DocsServer();
226
+ const { url } = await docsServer.start({ port: options.docsPort, host: options.docsHost });
227
+ console.log(`📚 Docs: ${url}`);
228
+ if (options.docsOpen) {
229
+ openUrl(url);
230
+ }
231
+
232
+ process.once('SIGINT', () => shutdown('SIGINT', 0));
233
+ process.once('SIGTERM', () => shutdown('SIGTERM', 0));
234
+
235
+ console.log('🎯 Docs server is running...');
236
+ console.log('Press Ctrl+C to stop');
237
+ return;
238
+ }
239
+
240
+ // 检查配置文件
241
+ const configPath = checkConfig(options.config);
242
+
243
+ console.log('🚀 Starting Class2CSS...');
244
+ console.log(`📁 Config: ${configPath}`);
245
+ console.log(`👀 Watch mode: ${options.watch ? 'enabled' : 'disabled'}`);
246
+
247
+ // 创建Class2CSS实例
248
+ class2css = new Class2CSS({
249
+ configPath: configPath,
250
+ cacheSize: 1000,
251
+ logger: {
252
+ level: 'info',
253
+ enableDebug: true,
254
+ enableTimestamp: true,
255
+ },
256
+ });
257
+
258
+ // 应用运行时配置覆盖
259
+ if (options.inputPath || options.outputPath || options.outputFileName || options.outputType) {
260
+ const overrides = {};
261
+
262
+ // 解析输入路径为绝对路径
263
+ if (options.inputPath) {
264
+ overrides.inputPath = path.isAbsolute(options.inputPath)
265
+ ? path.normalize(options.inputPath)
266
+ : path.resolve(process.cwd(), options.inputPath);
267
+ }
268
+
269
+ // 解析输出路径为绝对路径
270
+ if (options.outputPath) {
271
+ overrides.outputPath = path.isAbsolute(options.outputPath)
272
+ ? path.normalize(options.outputPath)
273
+ : path.resolve(process.cwd(), options.outputPath);
274
+ }
275
+
276
+ if (options.outputFileName) {
277
+ overrides.outputFileName = options.outputFileName;
278
+ }
279
+
280
+ if (options.outputType) {
281
+ if (options.outputType !== 'filePath' && options.outputType !== 'uniFile') {
282
+ console.error(`❌ Invalid output type: ${options.outputType}. Must be 'filePath' or 'uniFile'`);
283
+ process.exit(1);
284
+ }
285
+ overrides.outputType = options.outputType;
286
+ }
287
+
288
+ class2css.configManager.overrideConfig(overrides);
289
+
290
+ // 如果输出类型改变,更新统一文件模式状态
291
+ if (options.outputType) {
292
+ const isUnifiedMode = options.outputType === 'uniFile';
293
+ class2css.stateManager.setUnifiedFileMode(isUnifiedMode);
294
+ }
295
+
296
+ // 显示运行时覆盖信息
297
+ console.log('⚙️ Runtime overrides applied:');
298
+ if (overrides.inputPath) console.log(` Input: ${overrides.inputPath}`);
299
+ if (overrides.outputPath) console.log(` Output: ${overrides.outputPath}`);
300
+ if (overrides.outputFileName) console.log(` Output file: ${overrides.outputFileName}`);
301
+ if (overrides.outputType) console.log(` Output type: ${overrides.outputType}`);
302
+ }
303
+
304
+ // 获取事件总线用于监听事件
305
+ const eventBus = class2css.getEventBus();
306
+
307
+ // docs mode: start docs server alongside
308
+ if (options.docs) {
309
+ docsServer = new DocsServer(eventBus);
310
+ const { url } = await docsServer.start({ port: options.docsPort, host: options.docsHost });
311
+ console.log(`📚 Docs: ${url}`);
312
+ if (options.docsOpen) {
313
+ openUrl(url);
314
+ }
315
+ }
316
+
317
+ // 监听重要事件
318
+ eventBus.on('class2css:started', () => {
319
+ console.log('✅ Class2CSS started successfully');
320
+ });
321
+
322
+ eventBus.on('class2css:stopped', () => {
323
+ console.log('🛑 Class2CSS stopped');
324
+ });
325
+
326
+ eventBus.on('config:loaded', (config) => {
327
+ console.log('📋 Configuration loaded successfully');
328
+ });
329
+
330
+ eventBus.on('parser:completed', (stats) => {
331
+ // console.log(`🔍 Parsing completed: ${stats.totalCount} classes found`);
332
+ });
333
+
334
+ eventBus.on('generator:dynamic:completed', (stats) => {
335
+ console.log(`🎨 Dynamic CSS generated: ${stats.generatedCount} classes`);
336
+ });
337
+
338
+ eventBus.on('log:error', (data) => {
339
+ console.error('❌ Error:', data);
340
+ });
341
+
342
+ // 启动Class2CSS
343
+ await class2css.start();
344
+
345
+ // 如果不是监听模式,执行一次扫描后退出
346
+ if (!options.watch) {
347
+ console.log('🔍 Performing one-time scan...');
348
+ await class2css.performFullScan();
349
+ console.log('✅ Scan completed, exiting...');
350
+ await shutdown('no-watch', 0);
351
+ }
352
+
353
+ // 监听模式:处理进程信号
354
+ process.once('SIGINT', () => shutdown('SIGINT', 0));
355
+
356
+ process.once('SIGTERM', () => shutdown('SIGTERM', 0));
357
+
358
+ // 显示状态信息
359
+ // console.log('\n📊 Current Status:');
360
+ const status = class2css.getStatus();
361
+ // console.log(JSON.stringify(status, null, 2));
362
+
363
+ console.log('\n🎯 Class2CSS is running in watch mode...');
364
+ console.log('Press Ctrl+C to stop');
365
+ } catch (error) {
366
+ console.error('❌ Failed to start Class2CSS:', error.message);
367
+ if (error.stack) console.error(error.stack);
368
+ await shutdown('startup-error', 1, error);
369
+ }
370
+ }
371
+
372
+ // 运行主函数
373
+ if (require.main === module) {
374
+ main().catch((error) => {
375
+ console.error('❌ Unhandled error:', error);
376
+ process.exit(1);
377
+ });
378
+ }
379
+
380
+ module.exports = { main, parseArgs, showHelp, showVersion };
@@ -0,0 +1,124 @@
1
+ // ========== 工具配置文件 ==========
2
+ // 此文件包含工具运行相关的配置(系统设置、输出路径等)
3
+ // 样式规则配置请查看 styles.config.js
4
+
5
+ // 引入样式规则配置
6
+ const stylesConfig = require('./styles.config.js');
7
+
8
+ const config = {
9
+ // ========== 系统基础配置 ==========
10
+ system: {
11
+ // 基础单位设置
12
+ cssFormat: 'compressed', // 'multiLine' | 'singleLine' | 'compressed'
13
+ baseUnit: 'rpx',
14
+ // 单位转换比例 生成样式单位=设置单位*比例
15
+ unitConversion: 2,
16
+ // 是否压缩CSS
17
+ compression: true,
18
+ // 是否对生成的CSS类进行字母排序
19
+ sortClasses: true, // true | false,启用后会将CSS规则按选择器名称进行字母排序
20
+ // 智能单位处理策略
21
+ unitStrategy: {
22
+ // 自动检测:如果用户写了单位,保持原单位;如果没写,使用默认单位
23
+ autoDetect: true,
24
+ // 属性默认单位映射
25
+ propertyUnits: {
26
+ 'font-size': 'rpx',
27
+ 'width|height': 'rpx',
28
+ opacity: '', // 无单位
29
+ 'z-index': '', // 无单位
30
+ 'line-height': '', // 可以无单位
31
+ 'border-radius': 'rpx',
32
+ },
33
+ },
34
+ },
35
+
36
+ // ========== 输出配置 ==========
37
+ output: {
38
+ //文件输出目录
39
+ path: 'D:/code/membership-weapp/subpackages/portal/lib',
40
+ // 输出文件信息 可设置文件名,扩展名
41
+ fileName: 'commom12.wxss',
42
+ commonCssPath: 'D:/code/css2class/common.css', // 共用CSS文件路径
43
+ },
44
+
45
+ // ========== Important标识配置(从样式配置引入) ==========
46
+ importantFlags: stylesConfig.importantFlags,
47
+ // 多文件构建 如果存在该字段 则覆盖 cssOutPath fileName
48
+ multiFile: {
49
+ entry: {
50
+ // 扫描/监听入口:
51
+ // - string:单目录/单文件
52
+ // - string[]:多目录/多文件(目录与文件可混用)
53
+ path: 'D:/code/membership-weapp/subpackages/portal',
54
+ // 需要监听的文件名
55
+ // fileName:[
56
+ // 'index1.html'
57
+ // ],
58
+ // 文件类型 需要监听的文件扩展名用逗号隔开
59
+ fileType: ['html', 'wxml'],
60
+ },
61
+ // 多文件监听时的导出配置
62
+ output: {
63
+ // css文件导出目录
64
+ // filePath:将css文件导出到监听文件对应的目录下,并且生成同名的样式文件
65
+ //uniFile:将所有样式导出到单文件中
66
+ cssOutType: 'uniFile',
67
+ //文件输出目录
68
+ // 如果填写该目录 css文件就会生成到该目录下
69
+ path: 'D:/code/membership-weapp/subpackages/portal/lib',
70
+ // 输出文件名 cssOutType为uniFile的情况下生效
71
+ fileName: 'index.wxss',
72
+ // 输出文件格式 在cssOutType为filePath的情况下生效
73
+ fileType: 'wxss',
74
+
75
+ // ========== 增量模式配置 ==========
76
+ // incrementalOnlyAdd: 是否启用"只增不删"增量模式
77
+ // 当设置为 true 时:
78
+ // 1. 启动时会从输出文件(uniFile)中解析已存在的 class 作为基线
79
+ // 2. 后续文件变更时,只会新增 class,不会删除已存在的 class(包括基线中的 class)
80
+ // 3. 初次扫描后会提示输出文件中存在但当前项目未使用的 class,由用户决定是否清理
81
+ // 默认值: false(标准模式:会删除不再使用的 class)
82
+ // 注意:启用此模式后,输出文件可能会随时间增长,建议定期检查未使用的 class
83
+ incrementalOnlyAdd: true,
84
+
85
+ // incrementalBaseline: 增量基线来源策略(当前仅支持 'fromOutputFile')
86
+ // 'fromOutputFile': 从输出文件(uniFile)中解析已存在的 class
87
+ incrementalBaseline: 'fromOutputFile',
88
+
89
+ // rebuildOnStart: 是否在启动时重建输出文件(仅在 incrementalOnlyAdd=true 时生效)
90
+ // 当设置为 true 时:
91
+ // 1. 每次启动都会先执行全量扫描,清理上一次运行累积的多余规则
92
+ // 2. 重新生成并排序/格式化输出文件,确保输出文件只包含当前扫描到的 class
93
+ // 3. 然后进入 watch 增量模式(运行期只增不删)
94
+ // 默认值: true(推荐开启,保证每次启动输出文件都是干净且排序好的)
95
+ rebuildOnStart: true,
96
+
97
+ // unusedReportLimit: 未使用 class 报告的最大显示数量
98
+ // 启动重建时,如果发现上一版输出文件中存在但当前项目未使用的 class,会在控制台打印
99
+ // 此配置限制打印的示例数量,避免输出过长
100
+ // 默认值: 200
101
+ unusedReportLimit: 200,
102
+
103
+ // ========== uniFile 写入模式配置 ==========
104
+ // uniFileWriteMode: uniFile 模式的写入策略
105
+ // 'rewrite': 每次写入全量重算并覆盖写文件(默认,保持兼容)
106
+ // 'appendDelta': 启动时全量重建写入基础段(已压缩/排序),运行期只把新增 class 的规则追加到文件末尾
107
+ // 注意:当 uniFileWriteMode='appendDelta' 时,rebuildOnStart 必须为 true(否则历史垃圾无法自动清理)
108
+ // 默认值: 'rewrite'
109
+ uniFileWriteMode: 'appendDelta',
110
+ },
111
+ },
112
+
113
+ // ========== 样式规则配置(从 styles.config.js 引入) ==========
114
+ atomicRules: stylesConfig.atomicRules,
115
+ baseClassName: stylesConfig.baseClassName,
116
+ variants: stylesConfig.variants,
117
+ breakpoints: stylesConfig.breakpoints,
118
+ };
119
+
120
+ function getConfig() {
121
+ return config;
122
+ }
123
+
124
+ module.exports = getConfig();
package/common.css ADDED
@@ -0,0 +1,3 @@
1
+ .bg{
2
+ background-color: #f00;
3
+ }
@@ -0,0 +1,62 @@
1
+ // 颜色配置模块
2
+ const baseColors = {
3
+ // 自定义颜色
4
+ 466580: '#466580',
5
+ 818182: '#818182',
6
+ 595959: '#595959',
7
+ 333333: '#333333',
8
+ 666666: '#666666',
9
+ fffffe: '#fffffe',
10
+ B10A32: '#B10A32',
11
+ f4: '#F4F4F4',
12
+ cc: '#CCCCCC',
13
+
14
+ // 基础颜色
15
+ white: '#ffffff',
16
+ black: '#000000',
17
+ transparent: 'transparent',
18
+
19
+ // 灰度色
20
+ slate: '#64748b',
21
+ gray: '#6b7280',
22
+ gray1: '',
23
+ zinc: '#71717a',
24
+
25
+ // 暖色系
26
+ red: '#ef4444',
27
+ orange: '#f97316',
28
+ amber: '#f59e0b',
29
+ yellow: '#eab308',
30
+ lime: '#84cc16',
31
+
32
+ // 冷色系
33
+ green: '#22c55e',
34
+ emerald: '#10b981',
35
+ teal: '#14b8a6',
36
+ cyan: '#06b6d4',
37
+ sky: '#0ea5e9',
38
+ blue: '#142640',
39
+ indigo: '#6366f1',
40
+ violet: '#8b5cf6',
41
+ purple: '#a855f7',
42
+ fuchsia: '#d946ef',
43
+ pink: '#ec4899',
44
+ rose: '#f43f5e',
45
+ };
46
+
47
+ module.exports = {
48
+ baseColors,
49
+
50
+ // 颜色相关的class配置
51
+ colorClasses: {
52
+ color: {
53
+ ABBR: 'color',
54
+ },
55
+ bg: {
56
+ ABBR: 'background-color',
57
+ },
58
+ bcolor: {
59
+ ABBR: 'border-color',
60
+ },
61
+ },
62
+ };
@@ -0,0 +1,110 @@
1
+ // 布局配置模块
2
+ module.exports = {
3
+ // 显示属性
4
+ display: {
5
+ block: 'display: block;',
6
+ inline: 'display: inline;',
7
+ 'inline-block': 'display: inline-block;',
8
+ flex: 'display: flex;',
9
+ 'inline-flex': 'display: inline-flex;',
10
+ grid: 'display: grid;',
11
+ 'inline-grid': 'display: inline-grid;',
12
+ table: 'display: table;',
13
+ hidden: 'display: none;',
14
+ },
15
+
16
+ // 定位
17
+ position: {
18
+ static: 'position: static;',
19
+ fixed: 'position: fixed;',
20
+ absolute: 'position: absolute;',
21
+ relative: 'position: relative;',
22
+ sticky: 'position: sticky;',
23
+ position: {
24
+ re: 'relative',
25
+ ab: 'absolute',
26
+ fi: 'fixed',
27
+ sta: 'static',
28
+ sti: 'sticky',
29
+ },
30
+ },
31
+
32
+ // Flexbox
33
+ flexbox: {
34
+ 'flex-1': 'flex: 1;',
35
+ 'shrink-0': 'flex-shrink: 0;',
36
+ 'flex-cen': 'align-items: center;justify-content: center;',
37
+ 'flex-row': 'flex-direction: row;',
38
+ 'flex-col': 'flex-direction: column;',
39
+ 'flex-wrap': 'flex-wrap: wrap;',
40
+ 'flex-nowrap': 'flex-wrap: nowrap;',
41
+ 'items-start': 'align-items: flex-start;',
42
+ 'items-center': 'align-items: center;',
43
+ 'items-end': 'align-items: flex-end;',
44
+ 'items-stretch': 'align-items: stretch;',
45
+ 'justify-start': 'justify-content: flex-start;',
46
+ 'justify-center': 'justify-content: center;',
47
+ 'justify-end': 'justify-content: flex-end;',
48
+ 'justify-between': 'justify-content: space-between;',
49
+ 'justify-around': 'justify-content: space-around;',
50
+ 'justify-evenly': 'justify-content: space-evenly;',
51
+ flex_tb_cen: 'align-items: center;',
52
+ flex_lr: 'justify-content: space-between;',
53
+ flex_lr_end: 'justify-content: flex-end;',
54
+ flex_lr_cen: 'justify-content: center;',
55
+ flex_cen: 'align-items: center;justify-content: center;',
56
+ },
57
+
58
+ // 尺寸
59
+ sizing: {
60
+ 'w-full': 'width: 100%;',
61
+ 'h-full': 'height: 100%;',
62
+ 'w-screen': 'width: 100vw;',
63
+ 'h-screen': 'height: 100vh;',
64
+ },
65
+
66
+ // 溢出
67
+ overflow: {
68
+ 'overflow-auto': 'overflow: auto;',
69
+ 'overflow-hidden': 'overflow: hidden;',
70
+ 'overflow-visible': 'overflow: visible;',
71
+ 'overflow-scroll': 'overflow: scroll;',
72
+ 'overflow-x-auto': 'overflow-x: auto;',
73
+ 'overflow-x-hidden': 'overflow-x: hidden;',
74
+ 'overflow-x-scroll': 'overflow-x: scroll;',
75
+ 'overflow-y-auto': 'overflow-y: auto;',
76
+ 'overflow-y-hidden': 'overflow-y: hidden;',
77
+ 'overflow-y-scroll': 'overflow-y: scroll;',
78
+ overflow: ['hidden', 'auto', 'scroll'],
79
+ overflow_x: ['hidden', 'auto', 'scroll'],
80
+ overflow_y: ['hidden', 'auto', 'scroll'],
81
+ },
82
+
83
+ // 盒模型
84
+ boxModel: {
85
+ 'box-border': 'box-sizing: border-box;',
86
+ 'box-content': 'box-sizing: content-box;',
87
+ box_sizing: 'box-sizing:border-box;',
88
+ },
89
+
90
+ // 边框
91
+ borders: {
92
+ 'border-solid': 'border-style: solid;',
93
+ 'border-dashed': 'border-style: dashed;',
94
+ 'border-dotted': 'border-style: dotted;',
95
+ 'border-none': 'border: none;',
96
+ border_no: ' border:none !important;',
97
+ },
98
+
99
+ // 光标
100
+ cursor: {
101
+ 'cursor-auto': 'cursor: auto;',
102
+ 'cursor-default': 'cursor: default;',
103
+ 'cursor-pointer': 'cursor: pointer;',
104
+ 'cursor-wait': 'cursor: wait;',
105
+ 'cursor-text': 'cursor: text;',
106
+ 'cursor-move': 'cursor: move;',
107
+ 'cursor-not-allowed': 'cursor: not-allowed;',
108
+ cursor: ['pointer', 'auto', 'move'],
109
+ },
110
+ };