@melcanz85/chaincss 1.9.3 → 1.9.5
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 +25 -74
- package/package.json +2 -1
- package/strVal.js +43 -0
package/README.md
CHANGED
|
@@ -12,7 +12,6 @@ ChainCSS is a revolutionary CSS-in-JS solution that gives you **two powerful mod
|
|
|
12
12
|
|
|
13
13
|
**Runtime hooks** → Dynamic, prop-based styles when you need them
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
## Installation
|
|
17
16
|
|
|
18
17
|
```bash
|
|
@@ -28,7 +27,7 @@ ChainCSS is a revolutionary CSS-in-JS solution that gives you **two powerful mod
|
|
|
28
27
|
├── src/
|
|
29
28
|
│ ├── main.jcss # Entry point - imports & compiles
|
|
30
29
|
│ └── *.jcss # Your style definitions
|
|
31
|
-
├── style/ # Generated CSS will be stored
|
|
30
|
+
├── style/ # Generated CSS will be stored here
|
|
32
31
|
├── index.html # Your web page
|
|
33
32
|
└── package.json
|
|
34
33
|
```
|
|
@@ -48,13 +47,13 @@ ChainCSS is a revolutionary CSS-in-JS solution that gives you **two powerful mod
|
|
|
48
47
|
.borderRadius('4px')
|
|
49
48
|
.block('.btn');
|
|
50
49
|
|
|
51
|
-
module.exports =
|
|
50
|
+
module.exports = button;
|
|
52
51
|
````
|
|
53
52
|
**in your main.jcss**
|
|
54
53
|
|
|
55
54
|
```javascript
|
|
56
55
|
<@
|
|
57
|
-
const button = get('./button.
|
|
56
|
+
const button = get('./button.jcss');
|
|
58
57
|
|
|
59
58
|
compile(button);
|
|
60
59
|
@>
|
|
@@ -72,9 +71,10 @@ OR with vanilla nodejs project
|
|
|
72
71
|
# ./style/global.css generated!
|
|
73
72
|
````
|
|
74
73
|
* Note: running `npx chaincss ./src/main.jcss ./style --watch ` for the first time will
|
|
75
|
-
generate chaincss.config.js with default values. You can edit this to
|
|
74
|
+
generate ./chaincss.config.js with default values. You can edit this to
|
|
76
75
|
customize your build!.
|
|
77
76
|
|
|
77
|
+
|
|
78
78
|
### Mode 2: Runtime (React Hooks)
|
|
79
79
|
|
|
80
80
|
**Perfect for:** Dynamic styles that respond to props, state, or themes.
|
|
@@ -98,9 +98,9 @@ OR with vanilla nodejs project
|
|
|
98
98
|
|
|
99
99
|
return <button className={styles.button}>{children}</button>;
|
|
100
100
|
}
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
101
|
+
// Styles injected at runtime
|
|
102
|
+
// Automatic cleanup on unmount
|
|
103
|
+
// Fully dynamic based on props
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
```
|
|
@@ -146,8 +146,6 @@ OR with vanilla nodejs project
|
|
|
146
146
|
|
|
147
147
|
Watch Mode ✅ Instant recompilation
|
|
148
148
|
|
|
149
|
-
VM Security ✅ Safe code execution
|
|
150
|
-
|
|
151
149
|
|
|
152
150
|
## The ChainCSS API
|
|
153
151
|
|
|
@@ -156,7 +154,7 @@ OR with vanilla nodejs project
|
|
|
156
154
|
```javascript
|
|
157
155
|
// jQuery-like fluent API
|
|
158
156
|
const style = $()
|
|
159
|
-
.propertyName('value')
|
|
157
|
+
.propertyName('value')
|
|
160
158
|
.anotherProperty('value')
|
|
161
159
|
.block('.selector'); // End the chain with selector(s)
|
|
162
160
|
|
|
@@ -185,13 +183,13 @@ OR with vanilla nodejs project
|
|
|
185
183
|
.fontWeight('600')
|
|
186
184
|
.block('.btn');
|
|
187
185
|
|
|
188
|
-
module.exports =
|
|
186
|
+
module.exports = button;
|
|
189
187
|
```
|
|
190
188
|
**chaincss/main.jcss**
|
|
191
189
|
|
|
192
190
|
```javascript
|
|
193
191
|
<@
|
|
194
|
-
const
|
|
192
|
+
const button = get('./button.jcss');
|
|
195
193
|
compile({ button });
|
|
196
194
|
@>
|
|
197
195
|
````
|
|
@@ -239,10 +237,6 @@ OR with vanilla nodejs project
|
|
|
239
237
|
**Before (standard CSS):** 4,823 chars
|
|
240
238
|
**After (atomic CSS):** 499 chars → **90% smaller!**
|
|
241
239
|
|
|
242
|
-
### Built-in Security
|
|
243
|
-
|
|
244
|
-
ChainCSS uses **secure VM sandboxing** to safely execute your .jcss files. No eval, no global leaks, no security risks.
|
|
245
|
-
|
|
246
240
|
|
|
247
241
|
## Quick Start Guides
|
|
248
242
|
|
|
@@ -304,9 +298,9 @@ compile({ hello });" > chaincss/main.jcss
|
|
|
304
298
|
|
|
305
299
|
Approach Runtime Cost Bundle Size Dynamic Styles Learning Curve
|
|
306
300
|
|
|
307
|
-
|
|
301
|
+
ChainCSS (Build) Zero Just CSS Build-time Low
|
|
308
302
|
|
|
309
|
-
|
|
303
|
+
ChainCSS (Runtime) Minimal Small runtime Full Low
|
|
310
304
|
|
|
311
305
|
Styled Components 5-10KB runtime CSS + runtime Full Medium
|
|
312
306
|
|
|
@@ -316,33 +310,7 @@ compile({ hello });" > chaincss/main.jcss
|
|
|
316
310
|
|
|
317
311
|
CSS Modules Zero Just CSS None Low
|
|
318
312
|
|
|
319
|
-
**ChainCSS is the ONLY library that gives you
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
## Configuration
|
|
323
|
-
|
|
324
|
-
Create chaincss.config.js in your project root:
|
|
325
|
-
|
|
326
|
-
```javascript
|
|
327
|
-
|
|
328
|
-
module.exports = {
|
|
329
|
-
// Atomic CSS optimization
|
|
330
|
-
atomic: {
|
|
331
|
-
enabled: true,
|
|
332
|
-
threshold: 3, // Min usage for atomic conversion
|
|
333
|
-
naming: 'hash' // 'hash' | 'readable' | 'short'
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
// Prefixer options
|
|
337
|
-
prefixer: {
|
|
338
|
-
mode: 'auto', // 'auto' or 'full'
|
|
339
|
-
browsers: ['> 0.5%', 'last 2 versions']
|
|
340
|
-
},
|
|
341
|
-
|
|
342
|
-
// Source maps
|
|
343
|
-
sourceMaps: true
|
|
344
|
-
};
|
|
345
|
-
```
|
|
313
|
+
**ChainCSS is the ONLY library that gives you DUAL options**
|
|
346
314
|
|
|
347
315
|
## API Reference
|
|
348
316
|
|
|
@@ -350,32 +318,32 @@ Create chaincss.config.js in your project root:
|
|
|
350
318
|
|
|
351
319
|
Function Description
|
|
352
320
|
|
|
353
|
-
|
|
321
|
+
$() Create a new chain builder
|
|
354
322
|
|
|
355
|
-
|
|
323
|
+
.block(selector) End chain and assign selector(s)
|
|
356
324
|
|
|
357
|
-
|
|
325
|
+
compile(styles) Compile style objects to CSS
|
|
358
326
|
|
|
359
|
-
|
|
327
|
+
run(...styles) Process inline styles
|
|
360
328
|
|
|
361
|
-
|
|
329
|
+
get(filename) Import .jcss files
|
|
362
330
|
|
|
363
|
-
|
|
331
|
+
processor(input, output) Build-time processor
|
|
364
332
|
|
|
365
333
|
|
|
366
334
|
### React Hooks
|
|
367
335
|
|
|
368
336
|
Hook Description
|
|
369
337
|
|
|
370
|
-
|
|
338
|
+
useChainStyles(styles, options) Basic styles hook
|
|
371
339
|
|
|
372
|
-
|
|
340
|
+
useDynamicChainStyles(factory, deps) Styles that depend on props/state
|
|
373
341
|
|
|
374
|
-
|
|
342
|
+
useThemeChainStyles(styles, theme) Theme-aware styles
|
|
375
343
|
|
|
376
|
-
|
|
344
|
+
ChainCSSGlobal Global styles component
|
|
377
345
|
|
|
378
|
-
|
|
346
|
+
cx(...classes) Conditional class merging
|
|
379
347
|
|
|
380
348
|
|
|
381
349
|
## Editor Support
|
|
@@ -402,23 +370,6 @@ Create chaincss.config.js in your project root:
|
|
|
402
370
|
au BufRead,BufNewFile `*.jcss` setfiletype javascript
|
|
403
371
|
```
|
|
404
372
|
|
|
405
|
-
## Roadmap
|
|
406
|
-
|
|
407
|
-
* Zero-runtime compilation
|
|
408
|
-
|
|
409
|
-
* React hooks
|
|
410
|
-
|
|
411
|
-
* Atomic CSS optimization
|
|
412
|
-
|
|
413
|
-
* Design tokens
|
|
414
|
-
|
|
415
|
-
* TypeScript support
|
|
416
|
-
|
|
417
|
-
* Vue/Svelte integrations (coming soon)
|
|
418
|
-
|
|
419
|
-
* Plugin system (coming soon)
|
|
420
|
-
|
|
421
|
-
|
|
422
373
|
## Contributing
|
|
423
374
|
|
|
424
375
|
Contributions are welcome! Whether it's:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melcanz85/chaincss",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"description": "A simple package transpiler for js to css",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.react.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"transpiler.js",
|
|
22
22
|
"tokens.js",
|
|
23
23
|
"react-hooks.js",
|
|
24
|
+
"strVal.js",
|
|
24
25
|
"atomic-optimizer.js",
|
|
25
26
|
"cache-manager.js",
|
|
26
27
|
"prefixer.js",
|
package/strVal.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const strVal = {
|
|
2
|
+
userConf: `// ChainCSS Configuration
|
|
3
|
+
module.exports = {
|
|
4
|
+
atomic: {
|
|
5
|
+
enabled: false,
|
|
6
|
+
threshold: 3,
|
|
7
|
+
naming: 'hash',
|
|
8
|
+
cache: true,
|
|
9
|
+
cachePath: './.chaincss-cache',
|
|
10
|
+
minify: true
|
|
11
|
+
},
|
|
12
|
+
prefixer: {
|
|
13
|
+
mode: 'full',
|
|
14
|
+
browsers: ['> 0.5%', 'last 2 versions', 'not dead'],
|
|
15
|
+
enabled: true,
|
|
16
|
+
sourceMap: false,
|
|
17
|
+
sourceMapInline: false
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
`,
|
|
21
|
+
cli_opt_guide: `
|
|
22
|
+
ChainCSS - JavaScript-powered CSS preprocessor
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
chaincss <inputFile> <outputFile> [options]
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--watch Watch for changes
|
|
29
|
+
--no-prefix Disable automatic prefixing
|
|
30
|
+
--prefixer-mode <mode> Set prefixer mode (auto|lightweight|full)
|
|
31
|
+
--browsers <list> Browser support list (comma-separated)
|
|
32
|
+
--no-source-map Disable source maps
|
|
33
|
+
--source-map-inline Use inline source maps
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
chaincss style.jcss style.css
|
|
37
|
+
chaincss style.jcss style.css --watch
|
|
38
|
+
chaincss style.jcss style.css --browsers ">5%,last 2 versions"
|
|
39
|
+
chaincss style.jcss style.css --no-prefix
|
|
40
|
+
`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = strVal;
|