csszyx 0.1.1 → 0.1.2
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 +81 -28
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,52 +2,105 @@
|
|
|
2
2
|
|
|
3
3
|
> Universal CSS-in-JS for Tailwind CSS with WASM core.
|
|
4
4
|
|
|
5
|
-
**csszyx** is a zero-runtime, framework-agnostic CSS-in-JS library that compiles your styles into atomic CSS classes at build time. It leverages a Rust-based WASM core for blisteringly fast performance and safety.
|
|
6
|
-
|
|
7
5
|
## Features
|
|
8
6
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- **Build-time transforms** -- `sz` prop compiles to atomic Tailwind classes
|
|
8
|
+
- **Zero-runtime overhead** -- Styles extracted to static CSS at build time
|
|
9
|
+
- **SSR hydration safety** -- SHA-256 checksum validation, abort on mismatch
|
|
10
|
+
- **Tailwind CSS v4** -- Full compatibility with Tailwind's JIT engine
|
|
11
|
+
- **Production minification** -- Class names mangled (`p-4` -> `z`) for smaller output
|
|
12
|
+
- **TypeScript support** -- Fully typed `sz` prop with autocomplete
|
|
14
13
|
|
|
15
14
|
## Installation
|
|
16
15
|
|
|
17
16
|
```bash
|
|
18
|
-
npm install csszyx
|
|
19
|
-
# or
|
|
20
17
|
pnpm add csszyx
|
|
21
|
-
# or
|
|
22
|
-
yarn add csszyx
|
|
23
18
|
```
|
|
24
19
|
|
|
25
20
|
## Quick Start
|
|
26
21
|
|
|
27
|
-
1.
|
|
22
|
+
### 1. Configure your build tool
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// vite.config.ts
|
|
26
|
+
import { defineConfig } from "vite";
|
|
27
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
28
|
+
import react from "@vitejs/plugin-react";
|
|
29
|
+
import csszyx from "csszyx/vite";
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
plugins: [...csszyx(), tailwindcss(), react()],
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Use the `sz` prop
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
function Button() {
|
|
40
|
+
return (
|
|
41
|
+
<button sz={{ bg: "blue-500", color: "white", p: 4 }}>Click me</button>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
At build time, `sz={{ bg: 'blue-500', color: 'white', p: 4 }}` compiles to `className="bg-blue-500 text-white p-4"`.
|
|
47
|
+
|
|
48
|
+
## Object Syntax
|
|
49
|
+
|
|
50
|
+
The `sz` prop accepts an object where keys are Tailwind property names and values are their arguments.
|
|
28
51
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
```tsx
|
|
53
|
+
// Basic utilities
|
|
54
|
+
<div sz={{ p: 4, m: 2, bg: "blue-500" }} />
|
|
55
|
+
// -> className="p-4 m-2 bg-blue-500"
|
|
32
56
|
|
|
33
|
-
|
|
57
|
+
// Text color uses `color`, not `text`
|
|
58
|
+
<div sz={{ color: "white" }} />
|
|
59
|
+
// -> className="text-white"
|
|
34
60
|
|
|
35
|
-
|
|
36
|
-
|
|
61
|
+
// Font weight and family
|
|
62
|
+
<div sz={{ fontWeight: "bold", fontFamily: "mono" }} />
|
|
63
|
+
// -> className="font-bold font-mono"
|
|
37
64
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
65
|
+
// Hover state
|
|
66
|
+
<button sz={{ bg: "blue-500", hover: { bg: "blue-600" } }} />
|
|
67
|
+
// -> className="bg-blue-500 hover:bg-blue-600"
|
|
68
|
+
|
|
69
|
+
// Responsive breakpoints
|
|
70
|
+
<div sz={{ p: 4, md: { p: 8 }, lg: { p: 12 } }} />
|
|
71
|
+
// -> className="p-4 md:p-8 lg:p-12"
|
|
72
|
+
|
|
73
|
+
// Negative values
|
|
74
|
+
<div sz={{ m: -4 }} />
|
|
75
|
+
// -> className="-m-4"
|
|
76
|
+
|
|
77
|
+
// Opacity modifier
|
|
78
|
+
<div sz={{ bg: "blue-500/20" }} />
|
|
79
|
+
// -> className="bg-blue-500/20"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Runtime Helpers
|
|
83
|
+
|
|
84
|
+
For dynamic class composition, use the runtime helpers from `@csszyx/runtime` (re-exported by `csszyx`):
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { _sz, _szIf, _szSwitch } from "@csszyx/runtime";
|
|
88
|
+
|
|
89
|
+
<div className={_sz("p-4", _szIf(isActive, "bg-blue-500", "bg-gray-200"))} />;
|
|
90
|
+
```
|
|
44
91
|
|
|
45
92
|
## Packages
|
|
46
93
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
94
|
+
| Package | Description |
|
|
95
|
+
| -------------------------------------------------------------------- | --------------------------------------- |
|
|
96
|
+
| [`csszyx`](https://www.npmjs.com/package/csszyx) | Umbrella package (re-exports all) |
|
|
97
|
+
| [`@csszyx/unplugin`](https://www.npmjs.com/package/@csszyx/unplugin) | Vite + Webpack + esbuild plugin |
|
|
98
|
+
| [`@csszyx/compiler`](https://www.npmjs.com/package/@csszyx/compiler) | sz object to Tailwind class transform |
|
|
99
|
+
| [`@csszyx/runtime`](https://www.npmjs.com/package/@csszyx/runtime) | Runtime helpers + SSR hydration |
|
|
100
|
+
| [`@csszyx/core`](https://www.npmjs.com/package/@csszyx/core) | Rust/WASM: encoder, checksum, collision |
|
|
101
|
+
| [`@csszyx/cli`](https://www.npmjs.com/package/@csszyx/cli) | Migration CLI + type generator |
|
|
102
|
+
| [`@csszyx/types`](https://www.npmjs.com/package/@csszyx/types) | Shared TypeScript types |
|
|
50
103
|
|
|
51
104
|
## License
|
|
52
105
|
|
|
53
|
-
MIT
|
|
106
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "csszyx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Universal CSS-in-JS for Tailwind CSS with WASM core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"dist"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@csszyx/core": "0.1.
|
|
54
|
-
"@csszyx/runtime": "0.1.
|
|
55
|
-
"@csszyx/
|
|
56
|
-
"@csszyx/
|
|
57
|
-
"@csszyx/
|
|
53
|
+
"@csszyx/core": "0.1.2",
|
|
54
|
+
"@csszyx/runtime": "0.1.2",
|
|
55
|
+
"@csszyx/compiler": "0.1.2",
|
|
56
|
+
"@csszyx/unplugin": "0.1.2",
|
|
57
|
+
"@csszyx/types": "0.1.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"tsup": "^8.0.2",
|