chaincss 2.3.0 → 2.3.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/README.md +240 -372
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,36 +1,51 @@
|
|
|
1
1
|
<h1 align="center">ChainCSS</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<strong>The
|
|
5
|
-
Zero runtime by default.
|
|
4
|
+
<strong>The CSS-in-JS platform with compiler intelligence.</strong><br>
|
|
5
|
+
Zero runtime by default. Semantic styling. WCAG-aware. Intent-driven.
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<a href="https://www.npmjs.com/package/chaincss">
|
|
10
10
|
<img src="https://img.shields.io/npm/v/chaincss" alt="npm">
|
|
11
11
|
</a>
|
|
12
|
+
|
|
12
13
|
<a href="https://github.com/melcanz08/chaincss/blob/main/LICENSE">
|
|
13
14
|
<img src="https://img.shields.io/github/license/melcanz08/chaincss" alt="license">
|
|
14
15
|
</a>
|
|
15
|
-
|
|
16
|
-
<img src="https://img.shields.io/badge/docs-chaincss.dev-blue" alt="docs">
|
|
17
|
-
</a>
|
|
16
|
+
|
|
18
17
|
<a href="https://github.com/melcanz08/chaincss/actions">
|
|
19
|
-
<img src="https://img.shields.io/badge/tests-
|
|
18
|
+
<img src="https://img.shields.io/badge/tests-708%20passed-brightgreen" alt="tests">
|
|
19
|
+
</a>
|
|
20
|
+
|
|
21
|
+
<a href="https://github.com/melcanz08/chaincss">
|
|
22
|
+
<img src="https://img.shields.io/badge/modules-17-blue" alt="modules">
|
|
20
23
|
</a>
|
|
21
24
|
</p>
|
|
22
25
|
|
|
23
26
|
|
|
27
|
+
|
|
24
28
|
# What is ChainCSS?
|
|
25
29
|
|
|
26
30
|
ChainCSS lets you write styles as **native JavaScript method chains** — no CSS syntax, no template literals, no object literals.
|
|
27
31
|
|
|
28
32
|
It automatically detects which styles are static (compiled to zero-runtime CSS) and which are dynamic (stay in JS), then splits them automatically.
|
|
29
33
|
|
|
34
|
+
ChainCSS is also a **CSS intelligence platform** — not just a styling library.
|
|
35
|
+
|
|
36
|
+
It writes, checks, and optimizes your styles at build time with zero runtime cost.
|
|
37
|
+
|
|
30
38
|
```ts
|
|
31
39
|
import { chain } from "chaincss";
|
|
32
40
|
|
|
41
|
+
// A single intent expands to a full,
|
|
42
|
+
// accessible, responsive card:
|
|
33
43
|
const card = chain()
|
|
44
|
+
.intent("card")
|
|
45
|
+
.$el("card");
|
|
46
|
+
|
|
47
|
+
// Or write explicit styles:
|
|
48
|
+
const hero = chain()
|
|
34
49
|
.display("flex")
|
|
35
50
|
.flexDirection("column")
|
|
36
51
|
.gap(16)
|
|
@@ -41,10 +56,32 @@ const card = chain()
|
|
|
41
56
|
.boxShadow("0 4px 12px rgba(0,0,0,0.15)")
|
|
42
57
|
.transform("translateY(-2px)")
|
|
43
58
|
.end()
|
|
44
|
-
.$el("
|
|
59
|
+
.$el("hero");
|
|
45
60
|
```
|
|
46
61
|
|
|
47
|
-
**No CSS syntax. No template literals.
|
|
62
|
+
**No CSS syntax. No template literals. Compiler-enforced quality.**
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# What Makes ChainCSS Different
|
|
67
|
+
|
|
68
|
+
| Capability | ChainCSS | Tailwind | StyleX | Vanilla Extract |
|
|
69
|
+
|---|---|---|---|---|
|
|
70
|
+
| Zero runtime | ✅ | ✅ | ✅ | ✅ |
|
|
71
|
+
| Intent-based API | ✅ | ❌ | ❌ | ❌ |
|
|
72
|
+
| Semantic tokens | ✅ | ❌ | ❌ | ❌ |
|
|
73
|
+
| WCAG accessibility checking | ✅ | ❌ | ❌ | ❌ |
|
|
74
|
+
| Responsive inference | ✅ | ❌ | ❌ | ❌ |
|
|
75
|
+
| Pattern learning | ✅ | ❌ | ❌ | ❌ |
|
|
76
|
+
| CSS `if()` transpiler | ✅ | ❌ | ❌ | ❌ |
|
|
77
|
+
| Constraint-based styling | ✅ | ❌ | ❌ | ❌ |
|
|
78
|
+
| Layout intelligence | ✅ | ❌ | ❌ | ❌ |
|
|
79
|
+
| Scroll-driven animations | ✅ | ❌ | ❌ | ❌ |
|
|
80
|
+
| Self-healing CSS | ✅ | ❌ | ❌ | ❌ |
|
|
81
|
+
| Source-aware optimization | ✅ | ❌ | ❌ | ❌ |
|
|
82
|
+
| Design system extraction | ✅ | ❌ | ❌ | ❌ |
|
|
83
|
+
| 3 modes (build/runtime/hybrid) | ✅ | ❌ | ❌ | ❌ |
|
|
84
|
+
|
|
48
85
|
|
|
49
86
|
|
|
50
87
|
# Installation
|
|
@@ -53,35 +90,137 @@ const card = chain()
|
|
|
53
90
|
npm install chaincss
|
|
54
91
|
```
|
|
55
92
|
|
|
56
|
-
|
|
93
|
+
|
|
94
|
+
# Quick Start
|
|
57
95
|
|
|
58
96
|
| Environment | Setup |
|
|
59
97
|
|---|---|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
| **Browser + import map** | Map `"chaincss"` to `./node_modules/chaincss/dist/browser.js` |
|
|
98
|
+
| Vite | Add `chaincss()` plugin to `vite.config.ts` |
|
|
99
|
+
| Node.js | `import { chain } from "chaincss"` |
|
|
100
|
+
| Browser CDN | `import { chain } from "https://cdn.jsdelivr.net/npm/chaincss/dist/browser.js"` |
|
|
64
101
|
|
|
65
102
|
|
|
66
|
-
|
|
103
|
+
# Intent API (v2.3)
|
|
104
|
+
|
|
105
|
+
The highest-level API.
|
|
106
|
+
|
|
107
|
+
Write what you want — the compiler figures out how.
|
|
67
108
|
|
|
68
109
|
```ts
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
110
|
+
// Layout intents
|
|
111
|
+
chain().intent("center-content").$el("centered");
|
|
112
|
+
chain().intent("stack").$el("stack");
|
|
113
|
+
chain().intent("sidebar-layout").$el("dashboard");
|
|
72
114
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
115
|
+
// Component intents
|
|
116
|
+
chain().intent("card").$el("card");
|
|
117
|
+
chain().intent("button-primary").$el("cta");
|
|
118
|
+
chain().intent("modal").$el("dialog");
|
|
119
|
+
|
|
120
|
+
// Semantic intents
|
|
121
|
+
chain().intent("hero-section").$el("hero");
|
|
122
|
+
chain().intent("sticky-header").$el("nav");
|
|
123
|
+
|
|
124
|
+
// Interaction intents
|
|
125
|
+
chain().intent("hover-lift").$el("interactive");
|
|
126
|
+
chain().intent("focus-ring").$el("accessible");
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Each intent triggers:
|
|
130
|
+
- semantic tokens
|
|
131
|
+
- responsive overrides
|
|
132
|
+
- accessibility checks
|
|
133
|
+
- theme adaptation
|
|
134
|
+
|
|
135
|
+
—all at build time.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# Semantic Tokens
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
chain()
|
|
143
|
+
.surface("interactive")
|
|
144
|
+
.text("primary")
|
|
145
|
+
.elevation("floating")
|
|
146
|
+
.spacing("comfortable")
|
|
147
|
+
.state("hover")
|
|
148
|
+
.state("focus")
|
|
149
|
+
.$el("composed");
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| Category | Available Intents |
|
|
153
|
+
|---|---|
|
|
154
|
+
| surface | interactive, container, overlay, sheet |
|
|
155
|
+
| text | primary, secondary, muted, link |
|
|
156
|
+
| elevation | flat, raised, floating, modal |
|
|
157
|
+
| spacing | none, tight, compact, spacious |
|
|
158
|
+
| state | hover, active, focus, disabled |
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# Compiler Intelligence
|
|
163
|
+
|
|
164
|
+
ChainCSS analyzes your styles at build time and reports issues before they ship.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
chain()
|
|
168
|
+
.width("1200px")
|
|
169
|
+
.color("#999")
|
|
170
|
+
.fontSize("10px")
|
|
171
|
+
.outline("none")
|
|
172
|
+
.animation("fadeIn 1s")
|
|
173
|
+
.$el("risky-button");
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The compiler can:
|
|
177
|
+
- detect WCAG contrast failures
|
|
178
|
+
- fix invalid font sizes
|
|
179
|
+
- add focus-visible fallbacks
|
|
180
|
+
- wrap animations in reduced-motion queries
|
|
181
|
+
- prevent mobile overflow
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# Constraint-Based Styling
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
chain()
|
|
189
|
+
.constrain("width", "< parent")
|
|
190
|
+
.constrain("height", "= width * 0.5")
|
|
191
|
+
.constrain("columns", ">= 3 when > 768px")
|
|
192
|
+
.$el("responsive-card");
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
# Scroll Timeline Engine
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
import {
|
|
201
|
+
createScrollAnimation,
|
|
202
|
+
compileScrollAnimation
|
|
203
|
+
} from "chaincss";
|
|
204
|
+
|
|
205
|
+
const fadeIn = createScrollAnimation(
|
|
206
|
+
"fadeIn",
|
|
207
|
+
".reveal"
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const parallax = createScrollAnimation(
|
|
211
|
+
"parallax",
|
|
212
|
+
".bg"
|
|
213
|
+
);
|
|
76
214
|
```
|
|
77
215
|
|
|
216
|
+
Native scroll-driven animations with zero JavaScript runtime.
|
|
217
|
+
|
|
218
|
+
|
|
78
219
|
|
|
79
220
|
# Core API
|
|
80
221
|
|
|
81
222
|
## The Chain
|
|
82
223
|
|
|
83
|
-
Every style starts with `chain()` and ends with `$el()`.
|
|
84
|
-
|
|
85
224
|
```ts
|
|
86
225
|
import { chain } from "chaincss";
|
|
87
226
|
|
|
@@ -92,7 +231,7 @@ const styles = chain()
|
|
|
92
231
|
.$el("my-component");
|
|
93
232
|
```
|
|
94
233
|
|
|
95
|
-
## Smart Chain
|
|
234
|
+
## Smart Chain
|
|
96
235
|
|
|
97
236
|
```ts
|
|
98
237
|
import { smartChain } from "chaincss";
|
|
@@ -105,24 +244,9 @@ const styles = smartChain()
|
|
|
105
244
|
.$el("hybrid-card");
|
|
106
245
|
```
|
|
107
246
|
|
|
108
|
-
## Runtime Injection
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
import { chain, injectChainStyles } from "chaincss";
|
|
112
|
-
|
|
113
|
-
const heading = chain()
|
|
114
|
-
.fs(48)
|
|
115
|
-
.fw(800)
|
|
116
|
-
.textGradient(["#6366f1", "#06b6d4"])
|
|
117
|
-
.$el("h1");
|
|
118
|
-
|
|
119
|
-
injectChainStyles({ heading });
|
|
120
|
-
```
|
|
121
|
-
|
|
122
247
|
|
|
123
|
-
# Feature Reference
|
|
124
248
|
|
|
125
|
-
|
|
249
|
+
# Shorthands
|
|
126
250
|
|
|
127
251
|
```ts
|
|
128
252
|
chain()
|
|
@@ -132,293 +256,142 @@ chain()
|
|
|
132
256
|
.br(8)
|
|
133
257
|
.fs(16)
|
|
134
258
|
.fw(700)
|
|
135
|
-
.c("#333")
|
|
136
|
-
.w(200)
|
|
137
|
-
.h(100)
|
|
138
|
-
.d("flex")
|
|
139
|
-
.z(10)
|
|
140
|
-
.op(0.5)
|
|
141
|
-
.ov("hidden")
|
|
142
|
-
.pos("relative");
|
|
259
|
+
.c("#333");
|
|
143
260
|
```
|
|
144
261
|
|
|
145
262
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
### Layout & Display
|
|
263
|
+
# Macros
|
|
149
264
|
|
|
150
265
|
```ts
|
|
151
266
|
chain().flex();
|
|
152
267
|
chain().grid();
|
|
153
268
|
chain().center();
|
|
154
|
-
chain().flexCenter();
|
|
155
|
-
chain().gridCenter();
|
|
156
269
|
chain().stack(16);
|
|
157
|
-
chain().cols(3);
|
|
158
|
-
chain().rows(2);
|
|
159
|
-
chain().bento(4);
|
|
160
|
-
chain().gridTable("200px");
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### Spacing
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
chain().mx(10);
|
|
167
|
-
chain().my(20);
|
|
168
|
-
chain().px(16);
|
|
169
|
-
chain().py(24);
|
|
170
|
-
chain().size(50);
|
|
171
|
-
chain().gap(16);
|
|
172
|
-
chain().gapX(8);
|
|
173
|
-
chain().gapY(12);
|
|
174
|
-
chain().inset(0);
|
|
175
|
-
chain().insetX(16);
|
|
176
|
-
chain().insetY(8);
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Borders
|
|
180
|
-
|
|
181
|
-
```ts
|
|
182
|
-
chain().borderX("1px solid red");
|
|
183
|
-
chain().borderY("1px solid blue");
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Positioning
|
|
187
|
-
|
|
188
|
-
```ts
|
|
189
|
-
chain().absolute({ top: 0, left: 0 });
|
|
190
|
-
chain().fixed({ top: 0, right: 0 });
|
|
191
|
-
chain().sticky({ top: 0 });
|
|
192
|
-
chain().relative();
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Visibility & Behavior
|
|
196
|
-
|
|
197
|
-
```ts
|
|
198
|
-
chain().hide();
|
|
199
|
-
chain().show();
|
|
200
|
-
chain().unselectable();
|
|
201
|
-
chain().scrollable("y");
|
|
202
|
-
chain().safeArea("top");
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### Shapes & Typography
|
|
206
|
-
|
|
207
|
-
```ts
|
|
208
|
-
chain().circle(50);
|
|
209
|
-
chain().square(40);
|
|
210
|
-
chain().pill();
|
|
211
|
-
chain().truncate();
|
|
212
|
-
chain().aspect("16/9");
|
|
213
|
-
chain().aspect("square");
|
|
214
|
-
chain().fluidText({ min: 16, max: 24 });
|
|
215
|
-
chain().lineClamp(3);
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### Aesthetic Effects
|
|
219
|
-
|
|
220
|
-
```ts
|
|
221
270
|
chain().glass();
|
|
222
|
-
chain().
|
|
223
|
-
chain().glow("#ff0000");
|
|
224
|
-
chain().glow({ color: "#6366f1", size: 20 });
|
|
225
|
-
chain().textGradient(["#667eea", "#764ba2"]);
|
|
226
|
-
chain().meshGradient(["#f0f", "#0ff", "#ff0", "#0f0"]);
|
|
227
|
-
chain().noise(0.05);
|
|
228
|
-
chain().shimmer();
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### State & Interactions
|
|
232
|
-
|
|
233
|
-
```ts
|
|
234
|
-
chain().clickScale(0.95);
|
|
235
|
-
chain().pressable();
|
|
271
|
+
chain().glow("#6366f1");
|
|
236
272
|
chain().focusRing("#3b82f6");
|
|
237
|
-
chain().skeleton(true);
|
|
238
|
-
|
|
239
|
-
chain()
|
|
240
|
-
.dark(c => c.bg("#1a202c").c("white"))
|
|
241
|
-
.light(c => c.bg("white").c("#1a202c"));
|
|
242
273
|
```
|
|
243
274
|
|
|
244
|
-
### Utility
|
|
245
275
|
|
|
246
|
-
```ts
|
|
247
|
-
chain().fullScreen();
|
|
248
|
-
chain().containerMacro(1200);
|
|
249
|
-
chain().outlineDebug();
|
|
250
|
-
chain().parallax(2);
|
|
251
|
-
chain().frostedNav(15);
|
|
252
|
-
```
|
|
253
276
|
|
|
254
|
-
|
|
277
|
+
# Conditional Styles
|
|
255
278
|
|
|
256
279
|
```ts
|
|
257
280
|
chain()
|
|
258
281
|
.padding(12)
|
|
259
|
-
.when(isActive, c =>
|
|
260
|
-
|
|
282
|
+
.when(isActive, c =>
|
|
283
|
+
c.background("#10b981")
|
|
284
|
+
.color("white")
|
|
285
|
+
)
|
|
261
286
|
.$el("stateful-btn");
|
|
262
287
|
```
|
|
263
288
|
|
|
264
|
-
## Nested Selectors
|
|
265
289
|
|
|
266
|
-
```ts
|
|
267
|
-
chain()
|
|
268
|
-
.display("flex")
|
|
269
|
-
.nest("& > *", c => c.flex(1))
|
|
270
|
-
.nest("&:first-child", c => c.fontWeight(700))
|
|
271
|
-
.nest(".child", c => c.color("red"))
|
|
272
|
-
.$el("flex-container");
|
|
273
|
-
```
|
|
274
290
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
```ts
|
|
278
|
-
const shared = { display: "flex", alignItems: "center", gap: 8 };
|
|
279
|
-
chain().use(shared).padding(20).$el("reused");
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
## Responsive Design
|
|
291
|
+
# Responsive Design
|
|
283
292
|
|
|
284
293
|
```ts
|
|
285
294
|
chain()
|
|
286
295
|
.display("flex")
|
|
287
296
|
.flexDirection("column")
|
|
288
|
-
.responsive("md", c =>
|
|
289
|
-
|
|
297
|
+
.responsive("md", c =>
|
|
298
|
+
c.flexDirection("row")
|
|
299
|
+
)
|
|
290
300
|
.$el("responsive");
|
|
291
301
|
```
|
|
292
302
|
|
|
293
|
-
**Built-in breakpoints (20):** `sm`, `md`, `lg`, `xl`, `2xl`, `mobile`, `tablet`, `desktop`, `portrait`, `landscape`, `dark`, `light`, `reducedMotion`, `highContrast`, `print`, `hover`, `no-hover`, `fine`, `coarse`
|
|
294
303
|
|
|
295
|
-
|
|
304
|
+
|
|
305
|
+
# Math Engine
|
|
296
306
|
|
|
297
307
|
```ts
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
308
|
+
import {
|
|
309
|
+
math,
|
|
310
|
+
add,
|
|
311
|
+
fluidType,
|
|
312
|
+
convert
|
|
313
|
+
} from "chaincss";
|
|
314
|
+
|
|
315
|
+
add("10px", "2rem");
|
|
316
|
+
|
|
317
|
+
fluidType({
|
|
318
|
+
minSize: 14,
|
|
319
|
+
maxSize: 20
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
convert("32px", "rem");
|
|
305
323
|
```
|
|
306
324
|
|
|
307
|
-
### Math Helpers (15)
|
|
308
325
|
|
|
309
|
-
```ts
|
|
310
|
-
chain()
|
|
311
|
-
.width(helpers.calc("100% - 20px"))
|
|
312
|
-
.fontSize(helpers.clamp(16, 4, 24))
|
|
313
|
-
.margin(helpers.add(10, 20))
|
|
314
|
-
.$el("calculated");
|
|
315
|
-
|
|
316
|
-
// helpers.add(), .sub(), .mul(), .div(), .sum(), .difference()
|
|
317
|
-
// helpers.mpx(), .rem(), .em(), .percent(), .vw(), .vh()
|
|
318
|
-
// helpers.min(), .max(), .clamp(), .round(), .rgba(), .hsla()
|
|
319
|
-
// helpers.fluidType(min, max, minWidth, maxWidth)
|
|
320
|
-
```
|
|
321
326
|
|
|
322
|
-
|
|
327
|
+
# Design Tokens
|
|
323
328
|
|
|
324
329
|
```ts
|
|
325
|
-
import {
|
|
330
|
+
import {
|
|
331
|
+
createTokens,
|
|
332
|
+
createThemeContract,
|
|
333
|
+
createTheme
|
|
334
|
+
} from "chaincss";
|
|
326
335
|
|
|
327
336
|
const tokens = createTokens({
|
|
328
337
|
colors: {
|
|
329
338
|
primary: "#6366f1",
|
|
330
|
-
secondary: "#10b981"
|
|
331
|
-
}
|
|
332
|
-
spacing: {
|
|
333
|
-
sm: "8px",
|
|
334
|
-
md: "16px",
|
|
335
|
-
lg: "24px",
|
|
336
|
-
},
|
|
339
|
+
secondary: "#10b981"
|
|
340
|
+
}
|
|
337
341
|
});
|
|
338
342
|
```
|
|
339
343
|
|
|
340
|
-
### Theme Contracts
|
|
341
|
-
|
|
342
|
-
```ts
|
|
343
|
-
import { createThemeContract, createTheme, validateTheme } from "chaincss";
|
|
344
|
-
|
|
345
|
-
const contract = createThemeContract({
|
|
346
|
-
colors: { primary: "", background: "" },
|
|
347
|
-
spacing: { sm: "", md: "" },
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
const light = createTheme(contract, {
|
|
351
|
-
colors: { primary: "#3b82f6", background: "#fff" },
|
|
352
|
-
spacing: { sm: "8px", md: "16px" },
|
|
353
|
-
});
|
|
354
344
|
|
|
355
|
-
const theme = new Theme(light);
|
|
356
|
-
theme.toCSSVariables("my-theme"); // -> :root { --my-theme-colors-primary: #3b82f6; ... }
|
|
357
|
-
```
|
|
358
345
|
|
|
359
|
-
|
|
346
|
+
# Recipe System
|
|
360
347
|
|
|
361
348
|
```ts
|
|
362
349
|
import { recipe } from "chaincss";
|
|
363
350
|
|
|
364
351
|
const button = recipe({
|
|
365
|
-
base: {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
},
|
|
371
|
-
color: {
|
|
372
|
-
primary: { background: "#3b82f6", color: "white" },
|
|
373
|
-
danger: { background: "#ef4444", color: "white" },
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
defaultVariants: { size: "md", color: "primary" },
|
|
377
|
-
compoundVariants: [
|
|
378
|
-
{ variants: { size: "lg", color: "primary" }, style: { fontWeight: 800 } },
|
|
379
|
-
],
|
|
352
|
+
base: {
|
|
353
|
+
selectors: ["btn"],
|
|
354
|
+
display: "inline-flex",
|
|
355
|
+
borderRadius: "8px"
|
|
356
|
+
}
|
|
380
357
|
});
|
|
381
|
-
|
|
382
|
-
const styles = button({ size: "lg", color: "danger" });
|
|
383
358
|
```
|
|
384
359
|
|
|
385
|
-
### Animations (42 presets)
|
|
386
360
|
|
|
387
|
-
```ts
|
|
388
|
-
chain().fadeIn().$el("el"); chain().slideInUp().$el("el"); chain().slideInUp().$el("el");
|
|
389
|
-
chain().zoomIn().$el("el"); chain().bounce().$el("el"); chain().bounce().$el("el");
|
|
390
|
-
chain().pulse().$el("el"); chain().spin().$el("el"); chain().spin().$el("el");
|
|
391
|
-
chain().shake().$el("el"); chain().wiggle().$el("el"); chain().wiggle().$el("el");
|
|
392
|
-
chain().float().$el("el"); chain().flash().$el("el"); chain().flash().$el("el");
|
|
393
|
-
chain().textReveal().$el("el");
|
|
394
|
-
|
|
395
|
-
// Custom animation
|
|
396
|
-
chain().animate("myName", { "0%": { opacity: 0 }, "100%": { opacity: 1 } }, { duration: "0.5s" }).$el("el");
|
|
397
|
-
```
|
|
398
361
|
|
|
399
|
-
|
|
362
|
+
# Animations
|
|
400
363
|
|
|
401
364
|
```ts
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
365
|
+
chain()
|
|
366
|
+
.fadeIn()
|
|
367
|
+
.slideInUp()
|
|
368
|
+
.zoomIn()
|
|
369
|
+
.bounce()
|
|
370
|
+
.pulse()
|
|
371
|
+
.$el("animated");
|
|
407
372
|
```
|
|
408
373
|
|
|
409
|
-
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
# Self-Healing CSS
|
|
410
377
|
|
|
411
378
|
```ts
|
|
412
|
-
import {
|
|
379
|
+
import { correct, heal } from "chaincss";
|
|
413
380
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
381
|
+
correct("display", "flexbox");
|
|
382
|
+
correct("position", "abs");
|
|
383
|
+
|
|
384
|
+
heal(
|
|
385
|
+
{
|
|
386
|
+
display: "flexbox",
|
|
387
|
+
position: "abs"
|
|
388
|
+
},
|
|
389
|
+
"smart"
|
|
390
|
+
);
|
|
419
391
|
```
|
|
420
392
|
|
|
421
393
|
|
|
394
|
+
|
|
422
395
|
# CLI
|
|
423
396
|
|
|
424
397
|
```bash
|
|
@@ -426,120 +399,10 @@ chaincss init
|
|
|
426
399
|
chaincss build
|
|
427
400
|
chaincss watch
|
|
428
401
|
chaincss cache clear
|
|
429
|
-
chaincss
|
|
430
|
-
chaincss
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
# Configuration
|
|
435
|
-
|
|
436
|
-
```ts
|
|
437
|
-
// chaincss.config.js
|
|
438
|
-
export default {
|
|
439
|
-
inputs: ["src/**/*.chain.{js,ts}", "src/**/*.tsx"],
|
|
440
|
-
|
|
441
|
-
output: {
|
|
442
|
-
cssFile: "global.css",
|
|
443
|
-
minify: true,
|
|
444
|
-
},
|
|
445
|
-
|
|
446
|
-
atomic: {
|
|
447
|
-
enabled: true,
|
|
448
|
-
mode: "hybrid",
|
|
449
|
-
threshold: 2,
|
|
450
|
-
naming: "hash",
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
breakpoints: {
|
|
454
|
-
sm: "(min-width: 640px)",
|
|
455
|
-
md: "(min-width: 768px)",
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
tokens: {
|
|
459
|
-
enabled: true,
|
|
460
|
-
prefix: "$",
|
|
461
|
-
},
|
|
462
|
-
};
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
# Framework Integration
|
|
467
|
-
|
|
468
|
-
## React
|
|
469
|
-
|
|
470
|
-
```tsx
|
|
471
|
-
import { chain } from "chaincss";
|
|
472
|
-
|
|
473
|
-
function Card() {
|
|
474
|
-
const styles = chain()
|
|
475
|
-
.bg("white")
|
|
476
|
-
.p(24)
|
|
477
|
-
.rounded(12)
|
|
478
|
-
.$el("card");
|
|
479
|
-
|
|
480
|
-
return (
|
|
481
|
-
<div className={styles.selectors[0]}>
|
|
482
|
-
Content
|
|
483
|
-
</div>
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
## Vue
|
|
489
|
-
|
|
490
|
-
```ts
|
|
491
|
-
import { chain } from "chaincss";
|
|
492
|
-
|
|
493
|
-
const styles = chain().display("grid").cols(3).gap(16).$el("grid");
|
|
494
|
-
// <div :class="styles.selectors[0]">
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
## Svelte
|
|
498
|
-
|
|
499
|
-
```ts
|
|
500
|
-
import { chain } from "chaincss";
|
|
501
|
-
|
|
502
|
-
const styles = chain().flex().center().$el("centered");
|
|
503
|
-
// <div class={styles.selectors[0]}>
|
|
402
|
+
chaincss optimize --report
|
|
403
|
+
chaincss doctor
|
|
504
404
|
```
|
|
505
405
|
|
|
506
|
-
### Vanilla JS
|
|
507
|
-
|
|
508
|
-
```html
|
|
509
|
-
<script type="module">
|
|
510
|
-
import { chain, injectChainStyles } from "https://cdn.jsdelivr.net/npm/chaincss/dist/browser.js";
|
|
511
|
-
const h1 = chain()
|
|
512
|
-
.fs(48)
|
|
513
|
-
.fw(800)
|
|
514
|
-
.textGradient(["#6366f1","#06b6d4"])
|
|
515
|
-
.$el("h1");
|
|
516
|
-
|
|
517
|
-
injectChainStyles({ h1 });
|
|
518
|
-
|
|
519
|
-
document.body.innerHTML = '<h1 class="' + h1.selectors[0] + '">Hello!</h1>';
|
|
520
|
-
</script>
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
## Complete Feature List
|
|
525
|
-
|
|
526
|
-
| Category | Count | Details |
|
|
527
|
-
|----------|-------|---------|
|
|
528
|
-
| Macros | 57 | Layout, spacing, borders, positioning, visibility, shapes, effects, state, utility |
|
|
529
|
-
| Shorthand Properties | 80 | 1-to-1 CSS property mappings |
|
|
530
|
-
| Animation Presets | 42 | Fades, slides, zooms, bounces, shakes, spins, flips, special effects |
|
|
531
|
-
| Breakpoints | 20 | Mobile-first, desktop-first, device-specific, feature queries |
|
|
532
|
-
| Chain API Methods | 30+ | hover, nest, when, use, responsive, media, supports, containerQuery, layer |
|
|
533
|
-
| Math Helpers | 15 | calc, add, sub, mul, div, clamp, min, max, unit conversions, fluidType |
|
|
534
|
-
| CSS Properties | 300+ | Every standard CSS property via type definitions |
|
|
535
|
-
| CLI Commands | 5 | init, build, watch, cache, timeline |
|
|
536
|
-
| Framework Integrations | 4 | React, Vue, Svelte, Solid |
|
|
537
|
-
| Plugins | 2 | Vite, Webpack |
|
|
538
|
-
| Bundles | 5 | Main, Runtime, Browser, Compiler, CLI |
|
|
539
|
-
| React Hooks | 6 | useSmartStyles, createSmartComponent, useChainStyles, useDynamicChainStyles, useThemeChainStyles, withSmartStyles |
|
|
540
|
-
| Design Systems | 3 | Tokens, Theme Contracts, Recipes |
|
|
541
|
-
| Dev Tools | 3 | Suggestions Engine, Timeline, Component Generator |
|
|
542
|
-
| Tests | 258 | 18 test files, 0 failures |
|
|
543
406
|
|
|
544
407
|
|
|
545
408
|
# Performance
|
|
@@ -547,8 +410,9 @@ const styles = chain().flex().center().$el("centered");
|
|
|
547
410
|
- Zero runtime for static styles
|
|
548
411
|
- Atomic CSS extraction
|
|
549
412
|
- Smart static/dynamic splitting
|
|
550
|
-
-
|
|
551
|
-
-
|
|
413
|
+
- Cross-file dead code elimination
|
|
414
|
+
- Multi-pass optimization pipeline
|
|
415
|
+
|
|
552
416
|
|
|
553
417
|
|
|
554
418
|
# Contributing
|
|
@@ -564,11 +428,15 @@ npm test
|
|
|
564
428
|
```
|
|
565
429
|
|
|
566
430
|
|
|
431
|
+
|
|
567
432
|
# License
|
|
568
433
|
|
|
569
434
|
MIT © Rommel Caneos
|
|
570
435
|
|
|
571
436
|
<p align="center">
|
|
572
|
-
<strong>ChainCSS</strong> —
|
|
573
|
-
|
|
437
|
+
<strong>ChainCSS v2.3</strong> — The CSS intelligence platform.<br>
|
|
438
|
+
|
|
439
|
+
<a href="https://github.com/melcanz08/chaincss">
|
|
440
|
+
github.com/melcanz08/chaincss
|
|
441
|
+
</a>
|
|
574
442
|
</p>
|
package/package.json
CHANGED