styimat 4.0.0 → 4.2.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.
package/README.md CHANGED
@@ -56,36 +56,26 @@ npm install styimat
56
56
 
57
57
  ### 5. ESModule使用
58
58
  ```javascript
59
- import styimat from 'https://cdn.jsdelivr.net/npm/styimat/styimat.min.mjs'
59
+ import styimat from 'https://unpkg.com/styimat/esm'
60
60
  const css = `
61
61
  $primary: lab(54.7 77.9 80.1);
62
62
  .button { background-color: $primary; }
63
63
  `;
64
64
 
65
- const result = styimat.convent(css);
65
+ const result = styimat.convert(css);
66
66
  console.log(result);
67
67
  ```
68
68
 
69
- ```javascript
70
- import styimat from 'https://cdn.jsdelivr.net/npm/styimat/styimat.min.mjs'
71
- const css = `
72
- $primary: lab(54.7 77.9 80.1);
73
- .button { background-color: $primary; }
74
- `;
75
-
76
- const result = styimat(css);
77
- console.log(result);
78
- ```
79
69
  **也可以按需导入**
80
70
 
81
71
  ```javascript
82
- import { convent, apply } from 'https://cdn.jsdelivr.net/npm/styimat/styimat.min.mjs'
72
+ import { convert, apply } from 'https://unpkg.com/styimat/esm'
83
73
  const css = `
84
74
  $primary: lab(54.7 77.9 80.1);
85
75
  .button { background-color: $primary; }
86
76
  `;
87
77
 
88
- const result = convent(css);
78
+ const result = convert(css);
89
79
  console.log(result);
90
80
  apply();
91
81
  ```
@@ -101,6 +91,7 @@ apply();
101
91
  - **轻量高效** - 无依赖,压缩后仅约 20KB
102
92
  - **多种使用方式** - 浏览器、Node.js、命令行均可使用
103
93
  - **灵活API** - 支持函数调用、模板标签、对象配置等多种用法
94
+ - **现代ESModule导入** - 支持`import`按需导入
104
95
 
105
96
  ## 快速开始
106
97
 
@@ -359,6 +350,37 @@ body {
359
350
  <style src="head.css" e></style>
360
351
  ```
361
352
 
353
+ ### 宏语法
354
+
355
+ #### 您可以在CSS文件使用宏,应该以`@macro开头`:
356
+
357
+ ```css
358
+ @macro grid($columns, $gap: 10px) {
359
+ display: grid;
360
+ grid-template-columns: repeat($columns, 1fr);
361
+ gap: $gap;
362
+ }
363
+
364
+ .container {
365
+ @grid(3, 20px);
366
+ }
367
+ ```
368
+
369
+ ### 别名语法
370
+
371
+ #### 您可以在CSS文件的开头使用别名来让css属性名更简单,应该以`@alias开头`:
372
+
373
+ ```css
374
+ @alias bg background-color;
375
+
376
+ /* 然后写您的CSS代码 */
377
+ $primary-color: lab#32a852;
378
+
379
+ body {
380
+ bg: $primary-color;
381
+ }
382
+ ```
383
+
362
384
  ### 配置头语法
363
385
 
364
386
  您可以在CSS文件的开头使用配置头来设置预处理选项,配置行以 `#` 开头: