claudecode-omc 5.6.6 → 5.6.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.
- package/.local/skills/h5-to-swiftui/SKILL.md +201 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/README.md +176 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/h5-twin/index.html +52 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/h5-twin/style.css +133 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin/Package.swift +26 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin/Sources/CalibrationScreen/CalibrationScreen.swift +142 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin-divergent/Package.swift +32 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/swiftui-twin-divergent/Sources/CalibrationScreenDivergent/CalibrationScreenDivergent.swift +122 -0
- package/.local/skills/h5-to-swiftui/assets/calibration/tokens.json +42 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/index.html +14 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/package.json +20 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/public/api/articles/001.json +96 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/public/api/articles/index.json +89 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/App.jsx +22 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/App.module.css +11 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/ArticleCard.jsx +53 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/ArticleCard.module.css +139 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/NavBar.jsx +37 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/NavBar.module.css +72 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TagCloud.jsx +30 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TagCloud.module.css +50 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TrendChart.jsx +159 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/components/TrendChart.module.css +21 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/main.jsx +12 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/ArticleScreen.jsx +182 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/ArticleScreen.module.css +294 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/FeedScreen.jsx +147 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/screens/FeedScreen.module.css +161 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/styles/global.css +50 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/src/styles/tokens.css +103 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-react/vite.config.js +6 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/data/tasks.js +67 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/index.html +26 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/router.js +73 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/screens/detail.js +164 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/screens/home.js +53 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/screens/list.js +87 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/styles/app.css +342 -0
- package/.local/skills/h5-to-swiftui/assets/sample-h5-vanilla/styles/tokens.css +68 -0
- package/.local/skills/h5-to-swiftui/references/css-to-swiftui-map.md +205 -0
- package/.local/skills/h5-to-swiftui/references/design-token-extraction.md +209 -0
- package/.local/skills/h5-to-swiftui/references/high-risk-triage.md +209 -0
- package/.local/skills/h5-to-swiftui/references/render-equivalence-calibration.md +193 -0
- package/.local/skills/h5-to-swiftui/references/stack-detection.md +160 -0
- package/.local/skills/h5-to-swiftui/references/visual-diff-loop-protocol.md +365 -0
- package/.local/skills/h5-to-swiftui/scripts/_calib-consts.mjs +150 -0
- package/.local/skills/h5-to-swiftui/scripts/_imglib.mjs +547 -0
- package/.local/skills/h5-to-swiftui/scripts/_provenance.mjs +123 -0
- package/.local/skills/h5-to-swiftui/scripts/calibrate-render.mjs +625 -0
- package/.local/skills/h5-to-swiftui/scripts/capture-reference.mjs +386 -0
- package/.local/skills/h5-to-swiftui/scripts/detect-stack.mjs +305 -0
- package/.local/skills/h5-to-swiftui/scripts/evaluate-convergence.mjs +1093 -0
- package/.local/skills/h5-to-swiftui/scripts/extract-tokens.mjs +600 -0
- package/.local/skills/h5-to-swiftui/scripts/mark-overlay.mjs +379 -0
- package/.local/skills/h5-to-swiftui/scripts/pixel-diff.mjs +530 -0
- package/.local/skills/h5-to-swiftui/scripts/sim-screenshot.sh +544 -0
- package/bundled/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/* ── Global reset & base ─────────────────────────────────────────────────── */
|
|
2
|
+
|
|
3
|
+
*, *::before, *::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
|
11
|
+
font-size: var(--font-size-body);
|
|
12
|
+
line-height: var(--line-height-normal);
|
|
13
|
+
background-color: var(--color-bg);
|
|
14
|
+
color: var(--color-text);
|
|
15
|
+
min-height: 100vh;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ── Nav bar ─────────────────────────────────────────────────────────────── */
|
|
19
|
+
|
|
20
|
+
#nav-bar {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: var(--space-4);
|
|
24
|
+
padding: 0 var(--space-6);
|
|
25
|
+
height: var(--nav-height);
|
|
26
|
+
background-color: var(--color-surface);
|
|
27
|
+
border-bottom: 1px solid var(--color-border);
|
|
28
|
+
position: sticky;
|
|
29
|
+
top: 0;
|
|
30
|
+
z-index: 10;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nav-link {
|
|
34
|
+
font-size: var(--font-size-body);
|
|
35
|
+
font-weight: var(--font-weight-medium);
|
|
36
|
+
color: var(--color-text-secondary);
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
padding: var(--space-1) var(--space-2);
|
|
39
|
+
border-radius: var(--radius-sm);
|
|
40
|
+
transition: color 0.15s, background-color 0.15s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.nav-link:hover {
|
|
44
|
+
color: var(--color-primary);
|
|
45
|
+
background-color: var(--color-surface-alt);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.nav-link.active {
|
|
49
|
+
color: var(--color-primary);
|
|
50
|
+
font-weight: var(--font-weight-bold);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ── Screen root ─────────────────────────────────────────────────────────── */
|
|
54
|
+
|
|
55
|
+
#screen-root {
|
|
56
|
+
padding: var(--space-6);
|
|
57
|
+
max-width: 640px;
|
|
58
|
+
margin: 0 auto;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ── Screen transition (simple fade) ────────────────────────────────────── */
|
|
62
|
+
|
|
63
|
+
.screen {
|
|
64
|
+
animation: fadeIn 0.2s ease;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@keyframes fadeIn {
|
|
68
|
+
from { opacity: 0; transform: translateY(4px); }
|
|
69
|
+
to { opacity: 1; transform: translateY(0); }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── Home screen ─────────────────────────────────────────────────────────── */
|
|
73
|
+
|
|
74
|
+
.home-hero {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
gap: var(--space-3);
|
|
78
|
+
margin-bottom: var(--space-8);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.home-hero h1 {
|
|
82
|
+
font-size: var(--font-size-title);
|
|
83
|
+
font-weight: var(--font-weight-bold);
|
|
84
|
+
line-height: var(--line-height-tight);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.home-hero p {
|
|
88
|
+
color: var(--color-text-secondary);
|
|
89
|
+
font-size: var(--font-size-body);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.home-stats {
|
|
93
|
+
display: flex;
|
|
94
|
+
gap: var(--space-4);
|
|
95
|
+
flex-wrap: wrap;
|
|
96
|
+
margin-bottom: var(--space-8);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.stat-card {
|
|
100
|
+
flex: 1 1 120px;
|
|
101
|
+
background-color: var(--color-surface);
|
|
102
|
+
border-radius: var(--radius-md);
|
|
103
|
+
padding: var(--space-4);
|
|
104
|
+
box-shadow: var(--shadow-card);
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-direction: column;
|
|
107
|
+
gap: var(--space-1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.stat-card .stat-value {
|
|
111
|
+
font-size: var(--font-size-title);
|
|
112
|
+
font-weight: var(--font-weight-bold);
|
|
113
|
+
color: var(--color-primary);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.stat-card .stat-label {
|
|
117
|
+
font-size: var(--font-size-caption);
|
|
118
|
+
color: var(--color-text-secondary);
|
|
119
|
+
text-transform: uppercase;
|
|
120
|
+
letter-spacing: 0.04em;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.home-cta {
|
|
124
|
+
display: flex;
|
|
125
|
+
gap: var(--space-3);
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* ── Buttons ─────────────────────────────────────────────────────────────── */
|
|
130
|
+
|
|
131
|
+
.btn {
|
|
132
|
+
display: inline-flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
padding: var(--space-3) var(--space-5);
|
|
136
|
+
border-radius: var(--radius-md);
|
|
137
|
+
font-size: var(--font-size-body);
|
|
138
|
+
font-weight: var(--font-weight-medium);
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
border: none;
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
transition: opacity 0.15s, transform 0.1s;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.btn:active { transform: scale(0.97); }
|
|
146
|
+
|
|
147
|
+
.btn-primary {
|
|
148
|
+
background-color: var(--color-primary);
|
|
149
|
+
color: #ffffff;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.btn-primary:hover { background-color: var(--color-primary-dark); }
|
|
153
|
+
|
|
154
|
+
.btn-secondary {
|
|
155
|
+
background-color: var(--color-surface-alt);
|
|
156
|
+
color: var(--color-text);
|
|
157
|
+
border: 1px solid var(--color-border);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.btn-secondary:hover { background-color: var(--color-border); }
|
|
161
|
+
|
|
162
|
+
/* ── List screen ─────────────────────────────────────────────────────────── */
|
|
163
|
+
|
|
164
|
+
.list-header {
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
justify-content: space-between;
|
|
168
|
+
margin-bottom: var(--space-6);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.list-header h2 {
|
|
172
|
+
font-size: var(--font-size-heading);
|
|
173
|
+
font-weight: var(--font-weight-bold);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.task-list {
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
gap: var(--space-3);
|
|
180
|
+
list-style: none;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.task-row {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
gap: var(--space-3);
|
|
187
|
+
background-color: var(--color-surface);
|
|
188
|
+
border-radius: var(--radius-md);
|
|
189
|
+
padding: var(--space-4);
|
|
190
|
+
box-shadow: var(--shadow-card);
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
transition: transform 0.1s, box-shadow 0.1s;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.task-row:hover {
|
|
196
|
+
transform: translateY(-1px);
|
|
197
|
+
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.task-dot {
|
|
201
|
+
width: 10px;
|
|
202
|
+
height: 10px;
|
|
203
|
+
border-radius: var(--radius-full);
|
|
204
|
+
flex-shrink: 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.task-dot.priority-high { background-color: var(--color-danger); }
|
|
208
|
+
.task-dot.priority-medium { background-color: #ff9f0a; }
|
|
209
|
+
.task-dot.priority-low { background-color: var(--color-success); }
|
|
210
|
+
|
|
211
|
+
.task-info {
|
|
212
|
+
flex: 1;
|
|
213
|
+
display: flex;
|
|
214
|
+
flex-direction: column;
|
|
215
|
+
gap: var(--space-1);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.task-title {
|
|
219
|
+
font-size: var(--font-size-body);
|
|
220
|
+
font-weight: var(--font-weight-medium);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.task-meta {
|
|
224
|
+
font-size: var(--font-size-caption);
|
|
225
|
+
color: var(--color-text-secondary);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.task-done .task-title {
|
|
229
|
+
text-decoration: line-through;
|
|
230
|
+
color: var(--color-text-secondary);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.task-badge {
|
|
234
|
+
font-size: var(--font-size-caption);
|
|
235
|
+
font-weight: var(--font-weight-medium);
|
|
236
|
+
padding: var(--space-1) var(--space-2);
|
|
237
|
+
border-radius: var(--radius-full);
|
|
238
|
+
background-color: var(--color-surface-alt);
|
|
239
|
+
color: var(--color-text-secondary);
|
|
240
|
+
white-space: nowrap;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* ── Detail screen ───────────────────────────────────────────────────────── */
|
|
244
|
+
|
|
245
|
+
.detail-back {
|
|
246
|
+
display: inline-flex;
|
|
247
|
+
align-items: center;
|
|
248
|
+
gap: var(--space-2);
|
|
249
|
+
color: var(--color-primary);
|
|
250
|
+
font-size: var(--font-size-body);
|
|
251
|
+
text-decoration: none;
|
|
252
|
+
margin-bottom: var(--space-6);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.detail-card {
|
|
256
|
+
background-color: var(--color-surface);
|
|
257
|
+
border-radius: var(--radius-lg);
|
|
258
|
+
overflow: hidden;
|
|
259
|
+
box-shadow: var(--shadow-card);
|
|
260
|
+
margin-bottom: var(--space-6);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.detail-image-placeholder {
|
|
264
|
+
width: 100%;
|
|
265
|
+
height: 180px;
|
|
266
|
+
background-color: var(--color-surface-alt);
|
|
267
|
+
display: flex;
|
|
268
|
+
align-items: center;
|
|
269
|
+
justify-content: center;
|
|
270
|
+
color: var(--color-text-secondary);
|
|
271
|
+
font-size: var(--font-size-caption);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.detail-body {
|
|
275
|
+
padding: var(--space-5);
|
|
276
|
+
display: flex;
|
|
277
|
+
flex-direction: column;
|
|
278
|
+
gap: var(--space-3);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.detail-title {
|
|
282
|
+
font-size: var(--font-size-heading);
|
|
283
|
+
font-weight: var(--font-weight-bold);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.detail-desc {
|
|
287
|
+
color: var(--color-text-secondary);
|
|
288
|
+
line-height: var(--line-height-normal);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.detail-meta-row {
|
|
292
|
+
display: flex;
|
|
293
|
+
gap: var(--space-3);
|
|
294
|
+
flex-wrap: wrap;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.detail-chip {
|
|
298
|
+
font-size: var(--font-size-caption);
|
|
299
|
+
font-weight: var(--font-weight-medium);
|
|
300
|
+
padding: var(--space-1) var(--space-3);
|
|
301
|
+
border-radius: var(--radius-full);
|
|
302
|
+
background-color: var(--color-surface-alt);
|
|
303
|
+
color: var(--color-text);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* ── Canvas sparkline section ────────────────────────────────────────────── */
|
|
307
|
+
|
|
308
|
+
.sparkline-section {
|
|
309
|
+
margin-bottom: var(--space-6);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.sparkline-section h3 {
|
|
313
|
+
font-size: var(--font-size-body);
|
|
314
|
+
font-weight: var(--font-weight-medium);
|
|
315
|
+
margin-bottom: var(--space-3);
|
|
316
|
+
color: var(--color-text-secondary);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* TIER3: canvas custom drawing */
|
|
320
|
+
#sparkline-canvas {
|
|
321
|
+
display: block;
|
|
322
|
+
width: 100%;
|
|
323
|
+
height: 80px;
|
|
324
|
+
border-radius: var(--radius-md);
|
|
325
|
+
background-color: var(--color-surface);
|
|
326
|
+
border: 1px solid var(--color-border);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* ── Empty state ─────────────────────────────────────────────────────────── */
|
|
330
|
+
|
|
331
|
+
.empty-state {
|
|
332
|
+
text-align: center;
|
|
333
|
+
padding: var(--space-12) var(--space-6);
|
|
334
|
+
color: var(--color-text-secondary);
|
|
335
|
+
display: flex;
|
|
336
|
+
flex-direction: column;
|
|
337
|
+
gap: var(--space-3);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.empty-state p {
|
|
341
|
+
font-size: var(--font-size-body);
|
|
342
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* ── Design Tokens ───────────────────────────────────────────────────────────
|
|
2
|
+
All visual values are defined here as CSS custom properties so that
|
|
3
|
+
extract-tokens.mjs can harvest them in Stage 1.
|
|
4
|
+
─────────────────────────────────────────────────────────────────────────── */
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
/* Colors */
|
|
8
|
+
--color-bg: #f5f5f7;
|
|
9
|
+
--color-surface: #ffffff;
|
|
10
|
+
--color-surface-alt: #f0f0f5;
|
|
11
|
+
--color-primary: #007aff;
|
|
12
|
+
--color-primary-dark: #0055cc;
|
|
13
|
+
--color-text: #1c1c1e;
|
|
14
|
+
--color-text-secondary:#6e6e73;
|
|
15
|
+
--color-border: #d1d1d6;
|
|
16
|
+
--color-danger: #ff3b30;
|
|
17
|
+
--color-success: #34c759;
|
|
18
|
+
|
|
19
|
+
/* Typography */
|
|
20
|
+
--font-size-title: 1.75rem;
|
|
21
|
+
--font-size-heading: 1.25rem;
|
|
22
|
+
--font-size-body: 1rem;
|
|
23
|
+
--font-size-caption: 0.75rem;
|
|
24
|
+
--font-weight-regular: 400;
|
|
25
|
+
--font-weight-medium: 500;
|
|
26
|
+
--font-weight-bold: 700;
|
|
27
|
+
--line-height-tight: 1.2;
|
|
28
|
+
--line-height-normal: 1.5;
|
|
29
|
+
|
|
30
|
+
/* Spacing */
|
|
31
|
+
--space-1: 0.25rem;
|
|
32
|
+
--space-2: 0.5rem;
|
|
33
|
+
--space-3: 0.75rem;
|
|
34
|
+
--space-4: 1rem;
|
|
35
|
+
--space-5: 1.25rem;
|
|
36
|
+
--space-6: 1.5rem;
|
|
37
|
+
--space-8: 2rem;
|
|
38
|
+
--space-12: 3rem;
|
|
39
|
+
|
|
40
|
+
/* Radii */
|
|
41
|
+
--radius-sm: 4px;
|
|
42
|
+
--radius-md: 8px;
|
|
43
|
+
--radius-lg: 16px;
|
|
44
|
+
--radius-full: 9999px;
|
|
45
|
+
|
|
46
|
+
/* Shadows */
|
|
47
|
+
--shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
48
|
+
|
|
49
|
+
/* Nav */
|
|
50
|
+
--nav-height: 3rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ── Dark scheme ─────────────────────────────────────────────────────────── */
|
|
54
|
+
@media (prefers-color-scheme: dark) {
|
|
55
|
+
:root {
|
|
56
|
+
--color-bg: #000000;
|
|
57
|
+
--color-surface: #1c1c1e;
|
|
58
|
+
--color-surface-alt: #2c2c2e;
|
|
59
|
+
--color-primary: #0a84ff;
|
|
60
|
+
--color-primary-dark: #409cff;
|
|
61
|
+
--color-text: #ffffff;
|
|
62
|
+
--color-text-secondary:#aeaeb2;
|
|
63
|
+
--color-border: #38383a;
|
|
64
|
+
--color-danger: #ff453a;
|
|
65
|
+
--color-success: #30d158;
|
|
66
|
+
--shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# CSS → SwiftUI Mapping Reference — Stage 4
|
|
2
|
+
|
|
3
|
+
This is the lookup table used by the Stage 4 LLM prompt and the idiomatic-lint
|
|
4
|
+
checker. Accuracy is critical — this directly drives code generation. Every row
|
|
5
|
+
includes a caveat column because a mapping without its caveat is incomplete.
|
|
6
|
+
|
|
7
|
+
Source: findings.md RQ5 (kean.blog; Hacking with Swift; Swift with Majid;
|
|
8
|
+
swiftuifieldguide; Apple WWDC22-10056; tonsky.me; fatbobman).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Flexbox → SwiftUI
|
|
13
|
+
|
|
14
|
+
| CSS property / value | SwiftUI equivalent | Caveat |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `display: flex; flex-direction: row` | `HStack(alignment:, spacing:)` | Default `HStack()` spacing is non-zero (system-defined); **always pass `spacing: 0`** then add explicit spacing between children |
|
|
17
|
+
| `display: flex; flex-direction: column` | `VStack(alignment:, spacing:)` | Same spacing caveat — pass `spacing: 0` |
|
|
18
|
+
| `flex-direction: row-reverse` | `HStack` + `.environment(\.layoutDirection, .rightToLeft)` or reverse the child array | Prefer reversing child array when order is data-driven |
|
|
19
|
+
| `flex-direction: column-reverse` | `VStack` + reversed child array | No native reverse stack; reversing in data source is cleanest |
|
|
20
|
+
| `justify-content: flex-start` | Default (leading) | No modifier needed |
|
|
21
|
+
| `justify-content: flex-end` | `Spacer()` before first child | `Spacer()` expands to fill available space |
|
|
22
|
+
| `justify-content: center` | `Spacer()` + children + `Spacer()` | Or `.frame(maxWidth: .infinity, alignment: .center)` on the container |
|
|
23
|
+
| `justify-content: space-between` | `Spacer()` between each pair of children | Must insert N−1 spacers manually |
|
|
24
|
+
| `justify-content: space-around` | `Spacer()` before first, between each, after last | Each spacer gets equal weight; use `Spacer(minLength: 0)` |
|
|
25
|
+
| `justify-content: space-evenly` | `Spacer()` at all gaps including edges | Same as `space-around` implementation in SwiftUI |
|
|
26
|
+
| `align-items: flex-start` | `HStack(alignment: .top)` / `VStack(alignment: .leading)` | |
|
|
27
|
+
| `align-items: center` | `HStack(alignment: .center)` / `VStack(alignment: .center)` | `.center` is the default for HStack |
|
|
28
|
+
| `align-items: flex-end` | `HStack(alignment: .bottom)` / `VStack(alignment: .trailing)` | |
|
|
29
|
+
| `align-items: stretch` | Default HStack/VStack behavior for views with no explicit frame | Add `.frame(maxWidth: .infinity)` on children that need to stretch |
|
|
30
|
+
| `align-items: baseline` | `HStack(alignment: .firstTextBaseline)` | Also `.lastTextBaseline`; applies only to text-bearing children |
|
|
31
|
+
| `align-self: <value>` | `.alignmentGuide(alignment, computeValue:)` on the individual child | No direct `align-self` equivalent; alignment guides are complex — use only when necessary |
|
|
32
|
+
| `flex-grow: 1` (uniform on all siblings) | `.frame(maxWidth: .infinity)` (in HStack) or `.frame(maxHeight: .infinity)` (in VStack) | Only correct when all siblings have the same grow ratio |
|
|
33
|
+
| `flex-grow` (non-uniform ratios) | **Custom `Layout` protocol (iOS 16+)** | See "When you MUST use custom Layout" section below |
|
|
34
|
+
| `flex-shrink: 0` | `.fixedSize()` or explicit `.frame(width:, height:)` | Prevents the view from shrinking below its ideal size |
|
|
35
|
+
| `flex-shrink: 1` (default) | Default SwiftUI behavior | SwiftUI views compress by default when space is tight |
|
|
36
|
+
| `flex-basis: <value>` | `.frame(width: value)` / `.frame(height: value)` | Approximate only; no exact CSS `flex-basis` semantics in SwiftUI |
|
|
37
|
+
| `flex-wrap: wrap` | **Custom `Layout` protocol (iOS 16+)** — `FlowLayout` | No `LazyHGrid`/`LazyVGrid` equivalent for true wrapping; see FlowLayout sketch below |
|
|
38
|
+
| `flex-wrap: nowrap` | Default HStack/VStack (no wrapping) | |
|
|
39
|
+
| `gap: <value>` | `spacing: value` parameter on HStack/VStack | Both row-gap and column-gap map to the same `spacing` param — if they differ, use custom Layout |
|
|
40
|
+
| `row-gap: <value>` | `spacing: value` on VStack | |
|
|
41
|
+
| `column-gap: <value>` | `spacing: value` on HStack | |
|
|
42
|
+
| `order: <n>` | Reorder child array in data source | SwiftUI renders children in declaration order; no runtime reorder modifier exists |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## CSS Grid → SwiftUI
|
|
47
|
+
|
|
48
|
+
SwiftUI's grid support is intentionally limited. Know the ceiling.
|
|
49
|
+
|
|
50
|
+
| CSS Grid construct | SwiftUI equivalent | Caveat |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `grid-template-columns: repeat(N, 1fr)` | `LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: N))` | Only works for uniform fraction columns; not for mixed units |
|
|
53
|
+
| `grid-template-columns: auto-fill minmax(min, max)` | `LazyVGrid(columns: [GridItem(.adaptive(minimum: min, maximum: max))])` | `.adaptive` fills available width automatically |
|
|
54
|
+
| `fr` ratios (non-uniform, e.g. `1fr 2fr 1fr`) | **Custom `Layout` protocol (iOS 16+)** | No `LazyVGrid` equivalent; fr ratios require measuring total space and distributing proportionally |
|
|
55
|
+
| `grid-template-areas` | Not supported in LazyVGrid/Grid | Use `ZStack` + `.position` for named-area layouts, or custom Layout |
|
|
56
|
+
| `grid-column: span N` (eager Grid) | `.gridCellColumns(N)` on the child | Only works inside `Grid` (eager), not `LazyVGrid` |
|
|
57
|
+
| `grid-row: span N` | Not supported in LazyVGrid | Requires `Grid` (eager) or custom Layout |
|
|
58
|
+
| Explicit line placement (`grid-column: 2 / 4`) | Not supported natively | Custom Layout required |
|
|
59
|
+
| Auto-placement (dense) | LazyVGrid default | LazyVGrid uses source order auto-placement; no `grid-auto-flow: dense` |
|
|
60
|
+
| `gap` / `column-gap` / `row-gap` | `spacing` on `LazyVGrid` or `Grid` | Sets both axes uniformly; split-axis gap requires custom Layout |
|
|
61
|
+
| `Grid` (eager, iOS 16+) | `Grid { GridRow { … } }` | Full alignment control; use for small, known-count grids |
|
|
62
|
+
| `LazyVGrid` | `LazyVGrid(columns:, spacing:)` | For large/dynamic lists; less alignment control than `Grid` |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Positioning → SwiftUI
|
|
67
|
+
|
|
68
|
+
| CSS value | SwiftUI equivalent | Caveat |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `position: static` (default) | Default SwiftUI layout flow | No modifier needed |
|
|
71
|
+
| `position: relative` + `top/left/right/bottom` | `.offset(x:, y:)` | `.offset` shifts visually but preserves the layout space — the element still occupies its original slot; this matches CSS `relative` semantics |
|
|
72
|
+
| `position: absolute` + `top/left/width/height` | `ZStack` + `.position(x: left + width/2, y: top + height/2)` | **`.position()` takes CENTER coordinates, not top-left.** Compute: `cx = left + width/2`, `cy = top + height/2`. Must be inside a `ZStack` or the position is relative to the parent frame |
|
|
73
|
+
| `position: fixed` | `.overlay(alignment:)` on the root view, or `.safeAreaInset(edge:)` | Fixed elements must be moved outside the scrollable content entirely; common for navbars and tab bars |
|
|
74
|
+
| `position: sticky` | Manual: `onScrollGeometryChange` (iOS 18+) or `ScrollViewReader` + preference key | No built-in sticky modifier before iOS 18 |
|
|
75
|
+
| `z-index: <n>` | `.zIndex(n)` | **Only affects sibling ordering within the same `ZStack`.** A `zIndex` on a view nested inside a VStack has no effect relative to views outside that VStack |
|
|
76
|
+
| `inset: 0` (fill parent) | `.frame(maxWidth: .infinity, maxHeight: .infinity)` inside a ZStack | |
|
|
77
|
+
| `transform: translate(x, y)` | `.offset(x:, y:)` | |
|
|
78
|
+
| `transform: scale(n)` | `.scaleEffect(n)` | Scales visually; does not affect layout space |
|
|
79
|
+
| `transform: rotate(deg)` | `.rotationEffect(.degrees(deg))` | |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Box-model drift — the four sources of invisible divergence
|
|
84
|
+
|
|
85
|
+
These are not missing mappings — they are cases where the CSS and SwiftUI
|
|
86
|
+
constructs look equivalent but behave differently. Each one causes layout
|
|
87
|
+
divergence that passes code review.
|
|
88
|
+
|
|
89
|
+
### 1. Margin collapse
|
|
90
|
+
**CSS:** Adjacent vertical margins collapse to `max(m1, m2)`.
|
|
91
|
+
**SwiftUI:** `VStack(spacing:)` accumulates; two views each with `.padding(.bottom, 16)` produce 32 pt gap, not 16.
|
|
92
|
+
**Fix:** Use `VStack(spacing: max(m1, m2))` and remove per-child bottom padding, or set `spacing: 0` and add padding only to one side of each separator pair.
|
|
93
|
+
|
|
94
|
+
### 2. Border draws inside (not outside)
|
|
95
|
+
**CSS default (`content-box`):** `border` expands the element's visible size outward. The content area stays at declared width.
|
|
96
|
+
**SwiftUI `.border()`:** draws _inside_ the frame, equivalent to CSS `outline`. The frame size does not change.
|
|
97
|
+
**Fix:** Add `.padding(borderWidth)` before `.border()` to match CSS border-box behavior, or use `.overlay(RoundedRectangle(...).stroke(...))` which also draws inside.
|
|
98
|
+
|
|
99
|
+
### 3. No native percentage sizing
|
|
100
|
+
**CSS:** `width: 50%` is resolved by the containing block.
|
|
101
|
+
**SwiftUI:** No `%` sizing modifier exists.
|
|
102
|
+
**Fix:** Use `GeometryReader` — but **only in `.background{}` or `.overlay{}`**, never as a layout container. `GeometryReader` is greedy (takes all proposed space); using it as a primary layout view breaks parent constraints.
|
|
103
|
+
|
|
104
|
+
```swift
|
|
105
|
+
// Correct pattern for percentage width:
|
|
106
|
+
Color.clear
|
|
107
|
+
.frame(maxWidth: .infinity)
|
|
108
|
+
.overlay(
|
|
109
|
+
GeometryReader { geo in
|
|
110
|
+
Rectangle()
|
|
111
|
+
.frame(width: geo.size.width * 0.5)
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. `line-height` vs `.lineSpacing` differ
|
|
117
|
+
**CSS `line-height: 1.5` on 16px font:** applies half-leading (equal space above and below each line). Total line height = 24 px; each side gets 4 px extra.
|
|
118
|
+
**SwiftUI `.lineSpacing(n)`:** adds `n` points of space _below_ each line only (no leading above the first line).
|
|
119
|
+
**Conversion formula:** `lineSpacing = (cssLineHeight_px − coreTextLineHeight_px)` — i.e., the extra space only, applied as below-line gap.
|
|
120
|
+
**iOS 26+:** `.lineHeight(.exact: value)` sets exact line height matching CSS semantics. Use this when `--ios-floor >= 26`.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## When you MUST use the custom `Layout` protocol (iOS 16+)
|
|
125
|
+
|
|
126
|
+
These CSS patterns have **no stock SwiftUI equivalent**. Attempting to approximate
|
|
127
|
+
them with HStack/VStack produces incorrect layout. Use `Layout` protocol.
|
|
128
|
+
|
|
129
|
+
| CSS pattern | Why stock views fail |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `flex-wrap: wrap` | HStack never wraps; LazyHGrid/LazyVGrid are scroll containers, not inline wrapping layouts |
|
|
132
|
+
| Non-uniform `flex-grow` ratios (e.g. `flex-grow: 2` on one child, `flex-grow: 1` on others) | `.frame(maxWidth: .infinity)` distributes equally; no per-child weight |
|
|
133
|
+
| Non-uniform `fr` ratios (e.g. `1fr 2fr`) | `GridItem(.flexible())` is always equal weight |
|
|
134
|
+
| Radial / circular layouts | No stock radial container exists |
|
|
135
|
+
|
|
136
|
+
### Minimal correct FlowLayout sketch (iOS 16+)
|
|
137
|
+
|
|
138
|
+
```swift
|
|
139
|
+
struct FlowLayout: Layout {
|
|
140
|
+
var spacing: CGFloat = 8
|
|
141
|
+
|
|
142
|
+
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
|
|
143
|
+
let maxWidth = proposal.width ?? .infinity
|
|
144
|
+
var x: CGFloat = 0
|
|
145
|
+
var y: CGFloat = 0
|
|
146
|
+
var rowHeight: CGFloat = 0
|
|
147
|
+
|
|
148
|
+
for view in subviews {
|
|
149
|
+
let size = view.sizeThatFits(.unspecified)
|
|
150
|
+
if x + size.width > maxWidth, x > 0 {
|
|
151
|
+
y += rowHeight + spacing
|
|
152
|
+
x = 0
|
|
153
|
+
rowHeight = 0
|
|
154
|
+
}
|
|
155
|
+
x += size.width + spacing
|
|
156
|
+
rowHeight = max(rowHeight, size.height)
|
|
157
|
+
}
|
|
158
|
+
return CGSize(width: maxWidth, height: y + rowHeight)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
|
|
162
|
+
let maxWidth = bounds.maxX
|
|
163
|
+
var x = bounds.minX
|
|
164
|
+
var y = bounds.minY
|
|
165
|
+
var rowHeight: CGFloat = 0
|
|
166
|
+
|
|
167
|
+
for view in subviews {
|
|
168
|
+
let size = view.sizeThatFits(.unspecified)
|
|
169
|
+
if x + size.width > maxWidth, x > bounds.minX {
|
|
170
|
+
y += rowHeight + spacing
|
|
171
|
+
x = bounds.minX
|
|
172
|
+
rowHeight = 0
|
|
173
|
+
}
|
|
174
|
+
view.place(at: CGPoint(x: x, y: y), proposal: ProposedViewSize(size))
|
|
175
|
+
x += size.width + spacing
|
|
176
|
+
rowHeight = max(rowHeight, size.height)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This is a production-usable starting point. Add `alignment` and RTL support as
|
|
183
|
+
needed. The `cache` type is `Void` (no measurement caching) — add a `Cache` type
|
|
184
|
+
when subview measurement is expensive.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Quick-reference: CSS visual properties → SwiftUI modifiers
|
|
189
|
+
|
|
190
|
+
| CSS | SwiftUI | Note |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `border-radius: N` | `.cornerRadius(N)` or `.clipShape(RoundedRectangle(cornerRadius: N))` | `.cornerRadius` is deprecated in iOS 17+ for `.clipShape` |
|
|
193
|
+
| `box-shadow: x y blur spread color` | `.shadow(color:, radius:, x:, y:)` | No `spread` equivalent; `radius` ≈ CSS `blur / 2` |
|
|
194
|
+
| `opacity: N` | `.opacity(N)` | |
|
|
195
|
+
| `background-color` | `.background(Color.token)` | Use token, not hex |
|
|
196
|
+
| `color` | `.foregroundStyle(Color.token)` | `.foregroundColor` deprecated iOS 17+ |
|
|
197
|
+
| `font-size` / `font-weight` | `.font(DesignTokens.Typography.body)` | Use extracted token; never hardcode `Font.system(size: 16)` |
|
|
198
|
+
| `letter-spacing: N` | `.kerning(N)` | Units: CSS `em`-based vs SwiftUI `pt`-based; convert |
|
|
199
|
+
| `text-transform: uppercase` | `.textCase(.uppercase)` | |
|
|
200
|
+
| `text-decoration: underline` | `.underline()` | |
|
|
201
|
+
| `overflow: hidden` | `.clipped()` | |
|
|
202
|
+
| `border: N solid color` | `.overlay(Rectangle().stroke(color, lineWidth: N))` | Draws inside frame |
|
|
203
|
+
| `pointer-events: none` | `.allowsHitTesting(false)` | |
|
|
204
|
+
| `cursor: pointer` | No equivalent; tap gesture implied by `Button` | |
|
|
205
|
+
| `display: none` / `visibility: hidden` | `if condition { view }` or `.opacity(0)` | `if` removes from layout; `.opacity(0)` preserves layout space — choose by CSS analogue |
|