@templmf/temp-solf-lmf 0.0.160 → 0.0.161

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/SKILL.md ADDED
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: figma-to-css
3
+ description: 将 Figma 节点数据(通过 Figma MCP 获取)转换为 CSS/HTML 时应遵循的规则。当用户提供 Figma 节点 JSON(fills、size、padding、cornerRadius、effects、layoutMode 等字段),要求还原为网页样式、生成 HTML/CSS 代码、或将设计稿转换为前端代码时触发此技能。
4
+ ---
5
+
6
+ # Figma 节点 → CSS 转换规则
7
+
8
+ 本技能定义了将 Figma MCP 返回的节点数据字段,映射为 CSS 样式的标准规则。转换代码或手动还原样式时,严格按以下规则执行,不要引入未在规则中说明的默认值或推测行为。
9
+
10
+ ## 1. 填充 Fill(`fills` 字段)
11
+
12
+ - **非文本节点**:`fills` 代表背景,可能是 image、gradient 或纯色(color)
13
+ - 转换为对应的 `background` / `background-image` / `background-color`
14
+ - 若 `fills` 为空数组,**不要**设置任何背景色,不能自动补默认背景
15
+ - 若填充类型为 image,额外设置 `background-size: contain`
16
+ - **文本节点**:`fills` 代表文字颜色,转换为 `color`
17
+
18
+ ## 2. 盒模型(Box Model)
19
+
20
+ - 严格遵守 `size` 字段还原元素的 `width` / `height`
21
+ - 严格遵守 `paddingLeft`、`paddingRight`、`paddingTop`、`paddingBottom`,一一对应转换为 CSS 的 `padding-left` / `padding-right` / `padding-top` / `padding-bottom`
22
+ - 不要用简写 `padding` 合并四个方向导致精度丢失,除非四个值恰好相等
23
+
24
+ ## 3. 圆角(Corner Radius)
25
+
26
+ - `cornerRadius`(单一数值)→ `border-radius`(统一四角)
27
+ - `rectangleCornerRadii`(数组,顺序为 `[topLeft, topRight, bottomRight, bottomLeft]`)→ 按位顺序直接映射:
28
+ ```css
29
+ border-radius: {topLeft} {topRight} {bottomRight} {bottomLeft};
30
+ ```
31
+ 该数组顺序与 CSS `border-radius` 简写的顺时针顺序一致,无需重新排序
32
+
33
+ ## 4. 阴影(Shadow)
34
+
35
+ - 遍历 `effects` 字段,取其中 `type === 'DROP_SHADOW'` 的项
36
+ - 转换为 CSS `box-shadow`,映射关系:
37
+ - `offset.x` → `box-shadow` 第一个长度值
38
+ - `offset.y` → `box-shadow` 第二个长度值
39
+ - `radius` → 模糊半径(第三个值)
40
+ - `spread`(若存在)→ 扩散半径(第四个值)
41
+ - `color`(含透明度)→ 阴影颜色
42
+ - 若存在多个 `DROP_SHADOW`,用逗号拼接为多重阴影
43
+
44
+ ## 5. 布局方式(优先级从高到低)
45
+
46
+ ### 5.1 绝对定位优先
47
+ - 若节点 `layoutPositioning === 'ABSOLUTE'`:
48
+ - 该节点使用 `position: absolute`
49
+ - 其父节点必须设置 `position: relative`(作为定位上下文)
50
+
51
+ ### 5.2 无 `layoutMode`:自然布局
52
+ - 节点不存在 `layoutMode` 字段时,使用自然文档流:
53
+ - 若内部元素为**横向排列**:子元素使用 `display: inline-block` + `vertical-align`(对齐方式),元素间距使用 `margin`(如 `margin-right`)模拟,不使用 `gap`
54
+ - 若内部元素为**纵向排列**:使用默认块级文档流(块级元素天然纵向堆叠),无需额外设置 display
55
+
56
+ ### 5.3 存在 `layoutMode`:Flex 布局
57
+ - 节点存在 `layoutMode` 字段时,使用 `display: flex`:
58
+ - `layoutMode: HORIZONTAL` → `flex-direction: row`
59
+ - `layoutMode: VERTICAL` → `flex-direction: column`
60
+ - `itemSpacing` → `gap`
61
+ - `primaryAxisAlignItems` → `justify-content`(主轴对齐):
62
+ | Figma 值 | CSS 值 |
63
+ |---|---|
64
+ | MIN | flex-start |
65
+ | CENTER | center |
66
+ | MAX | flex-end |
67
+ | SPACE_BETWEEN | space-between |
68
+ - `counterAxisAlignItems` → `align-items`(交叉轴对齐):
69
+ | Figma 值 | CSS 值 |
70
+ |---|---|
71
+ | MIN | flex-start |
72
+ | CENTER | center |
73
+ | MAX | flex-end |
74
+ | BASELINE | baseline |
75
+
76
+ ## 6. 特殊节点类型
77
+
78
+ - `type === 'VECTOR'` 的节点,不做 SVG 内联转换,统一转换为图片引用方式:
79
+ ```html
80
+ <img src="xxx.svg" />
81
+ ```
82
+
83
+ ## 转换检查清单
84
+
85
+ 处理每个节点时,按以下顺序检查并应用规则:
86
+
87
+ 1. 是否 `layoutPositioning === ABSOLUTE`?→ 定位方式
88
+ 2. 节点类型是否为 `VECTOR`?→ 转 `<img>` 引用
89
+ 3. 是否有 `fills`?→ 区分文本/非文本节点,转背景或颜色
90
+ 4. `size` / `paddingLeft` / `paddingRight` / `paddingTop` / `paddingBottom` → 盒模型
91
+ 5. `cornerRadius` / `rectangleCornerRadii` → 圆角
92
+ 6. `effects` 中的 `DROP_SHADOW` → 阴影
93
+ 7. 是否有 `layoutMode`?→ 决定用 flex 还是自然布局,并处理对齐与间距
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@templmf/temp-solf-lmf",
3
- "version": "0.0.160",
3
+ "version": "0.0.161",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/partone.zip DELETED
Binary file
package/partthree.zip DELETED
Binary file
package/parttwo.zip DELETED
Binary file