css2class 2.0.0 → 2.0.1
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/.github/workflows/deploy-docs.yml +53 -0
- package/.head_config.mjs +68 -0
- package/CONFIG.md +38 -1
- package/README.md +595 -633
- package/bin/class2css.js +32 -4
- package/common.css +1 -1
- package/configs/typography.config.js +1 -0
- package/docs/.vitepress/config.mjs +68 -65
- package/docs/guide/cli.md +97 -97
- package/docs/guide/config-template.md +16 -1
- package/docs/guide/config.md +129 -64
- package/docs/guide/faq.md +202 -202
- package/docs/guide/getting-started.md +86 -83
- package/docs/guide/incremental.md +164 -162
- package/docs/guide/rules-reference.md +73 -1
- package/docs/index.md +71 -68
- package/examples/weapp/README.md +15 -0
- package/examples/weapp/class2css.config.js +70 -0
- package/examples/weapp/src/placeholder.wxml +0 -0
- package/examples/weapp/styles.config.js +201 -0
- package/examples/web/README.md +25 -0
- package/examples/web/class2css.config.js +70 -0
- package/examples/web/demo.html +105 -0
- package/examples/web/src/placeholder.html +5 -0
- package/examples/web/styles.config.js +201 -0
- package/package.json +7 -2
- package/src/README.md +99 -0
- package/src/core/ConfigManager.js +440 -431
- package/src/core/FullScanManager.js +438 -430
- package/src/generators/DynamicClassGenerator.js +270 -72
- package/src/index.js +1091 -1046
- package/src/parsers/ClassParser.js +8 -2
- package/src/utils/CssFormatter.js +400 -47
- package/src/utils/UnitProcessor.js +4 -3
- package/src/watchers/ConfigWatcher.js +413 -413
- package/src/watchers/FileWatcher.js +148 -133
- package/src/writers/FileWriter.js +444 -302
- package/src/writers/UnifiedWriter.js +413 -370
- package/class2css.config.js +0 -124
- package/styles.config.js +0 -250
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Deploy VitePress docs to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
pages: write
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: pages
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Node
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: npm install
|
|
31
|
+
|
|
32
|
+
- name: Build docs
|
|
33
|
+
run: npx vitepress build docs
|
|
34
|
+
|
|
35
|
+
- name: Setup Pages
|
|
36
|
+
uses: actions/configure-pages@v5
|
|
37
|
+
|
|
38
|
+
- name: Upload artifact
|
|
39
|
+
uses: actions/upload-pages-artifact@v3
|
|
40
|
+
with:
|
|
41
|
+
path: docs/.vitepress/dist
|
|
42
|
+
|
|
43
|
+
deploy:
|
|
44
|
+
needs: build
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
environment:
|
|
47
|
+
name: github-pages
|
|
48
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
49
|
+
steps:
|
|
50
|
+
- name: Deploy to GitHub Pages
|
|
51
|
+
id: deployment
|
|
52
|
+
uses: actions/deploy-pages@v4
|
|
53
|
+
|
package/.head_config.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @LastEditors: biz
|
|
3
|
+
*/
|
|
4
|
+
import { defineConfig } from 'vitepress';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
// GitHub Pages(Project Pages)部署路径: https://<user>.github.io/<repo>/
|
|
8
|
+
// 所以这里必须设置为 `/<repo>/`(末尾带 /)
|
|
9
|
+
base: '/css2class/',
|
|
10
|
+
title: 'Class2CSS',
|
|
11
|
+
description: '企业级原子化CSS生成工具,支持智能单位处理、配置验证、性能缓存和向后兼容',
|
|
12
|
+
lang: 'zh-CN',
|
|
13
|
+
|
|
14
|
+
themeConfig: {
|
|
15
|
+
nav: [
|
|
16
|
+
{ text: '文档', link: '/guide/getting-started' },
|
|
17
|
+
{ text: '参考', link: '/guide/config' },
|
|
18
|
+
{ text: 'FAQ', link: '/guide/faq' },
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
sidebar: {
|
|
22
|
+
'/guide/': [
|
|
23
|
+
{
|
|
24
|
+
text: '开始',
|
|
25
|
+
items: [
|
|
26
|
+
{ text: '快速开始', link: '/guide/getting-started' },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
text: '核心概念',
|
|
31
|
+
items: [
|
|
32
|
+
{ text: '类名语法与生成规则', link: '/guide/concepts' },
|
|
33
|
+
{ text: '单位与转换策略', link: '/guide/units' },
|
|
34
|
+
{ text: 'Important 与静态类', link: '/guide/important-and-static' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
text: '参考',
|
|
39
|
+
items: [
|
|
40
|
+
{ text: 'CLI', link: '/guide/cli' },
|
|
41
|
+
{ text: '规则参考', link: '/guide/rules-reference' },
|
|
42
|
+
{ text: '配置模板(可复制)', link: '/guide/config-template' },
|
|
43
|
+
{ text: '配置', link: '/guide/config' },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
text: '进阶',
|
|
48
|
+
items: [
|
|
49
|
+
{ text: '增量模式(只增不删)', link: '/guide/incremental' },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
text: '帮助',
|
|
54
|
+
items: [{ text: '常见问题', link: '/guide/faq' }],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
socialLinks: [{ icon: 'github', link: 'https://github.com/wnagchi/css2class' }],
|
|
60
|
+
|
|
61
|
+
search: {
|
|
62
|
+
provider: 'local',
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
outline: { level: [2, 3] },
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
package/CONFIG.md
CHANGED
|
@@ -535,10 +535,20 @@ typography: {
|
|
|
535
535
|
text: { properties: ['font-size'], defaultUnit: 'rpx' },
|
|
536
536
|
font: { properties: ['font-weight'], defaultUnit: '' },
|
|
537
537
|
leading: { properties: ['line-height'], defaultUnit: '' },
|
|
538
|
+
lh: { properties: ['line-height'], defaultUnit: 'rpx', skipSpecialProcessing: true },
|
|
538
539
|
tracking: { properties: ['letter-spacing'], defaultUnit: 'rpx' }
|
|
539
540
|
}
|
|
540
541
|
```
|
|
541
542
|
|
|
543
|
+
> **`leading` vs `lh` 行高前缀区别:**
|
|
544
|
+
>
|
|
545
|
+
> | 前缀 | 示例类名 | 生成 CSS | 说明 |
|
|
546
|
+
> |------|---------|---------|------|
|
|
547
|
+
> | `leading` | `leading-15` | `line-height: 0.9375` | 数值 > 10 时自动除以 16,输出无单位倍数 |
|
|
548
|
+
> | `leading` | `leading-1` | `line-height: 1` | 数值 ≤ 10 时直接输出无单位倍数 |
|
|
549
|
+
> | `lh` | `lh-32` | `line-height: 32rpx` | 跳过倍数转换,直接输出数值 × 单位 |
|
|
550
|
+
> | `lh` | `lh-48` | `line-height: 48rpx` | 适用于需要固定像素行高的场景 |
|
|
551
|
+
|
|
542
552
|
#### positioning - 定位系统
|
|
543
553
|
|
|
544
554
|
```javascript
|
|
@@ -832,12 +842,39 @@ breakpoints: {
|
|
|
832
842
|
|
|
833
843
|
### 状态变体 (states)
|
|
834
844
|
|
|
835
|
-
|
|
845
|
+
状态变体配置(Tailwind 风格伪类前缀)。当 class 以 `hover:` / `focus:` / `active:` 等前缀开头时,会生成对应的伪类选择器。
|
|
836
846
|
|
|
837
847
|
```javascript
|
|
838
848
|
states: ['hover', 'focus', 'active', 'disabled', 'first', 'last', 'odd', 'even']
|
|
839
849
|
```
|
|
840
850
|
|
|
851
|
+
#### 使用示例
|
|
852
|
+
|
|
853
|
+
```html
|
|
854
|
+
<div class="hover:bg-red hover:w-20"></div>
|
|
855
|
+
<input class="focus:w-30" />
|
|
856
|
+
<button class="active:opacity-50"></button>
|
|
857
|
+
<div class="lg:hover:w-20"></div>
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
#### 生成的 CSS 示例
|
|
861
|
+
|
|
862
|
+
```css
|
|
863
|
+
.hover\:w-20:hover { width: 20px; }
|
|
864
|
+
@media (min-width: 1024px) { .lg\:hover\:w-20:hover { width: 20px; } }
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
#### 伪类映射规则
|
|
868
|
+
|
|
869
|
+
- `hover` → `:hover`
|
|
870
|
+
- `focus` → `:focus`
|
|
871
|
+
- `active` → `:active`
|
|
872
|
+
- `disabled` → `:disabled`
|
|
873
|
+
- `first` → `:first-child`
|
|
874
|
+
- `last` → `:last-child`
|
|
875
|
+
- `odd` → `:nth-child(odd)`
|
|
876
|
+
- `even` → `:nth-child(even)`
|
|
877
|
+
|
|
841
878
|
### 暗色模式 (darkMode)
|
|
842
879
|
|
|
843
880
|
暗色模式变体配置(计划中的功能,当前仅配置名称)。
|