csszyx 0.1.0 → 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/LICENSE +21 -0
- package/README.md +81 -28
- package/package.json +11 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 csszyx contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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",
|
|
@@ -49,19 +49,19 @@
|
|
|
49
49
|
"files": [
|
|
50
50
|
"dist"
|
|
51
51
|
],
|
|
52
|
-
"scripts": {
|
|
53
|
-
"build": "tsup src/index.ts src/lite.ts src/vite.ts src/webpack.ts --format esm --dts && echo '/// <reference types=\"@csszyx/types/jsx\" />' | cat - dist/index.d.ts > dist/index.d.ts.tmp && mv dist/index.d.ts.tmp dist/index.d.ts",
|
|
54
|
-
"dev": "tsup src/index.ts src/lite.ts src/vite.ts src/webpack.ts --format esm --dts --watch"
|
|
55
|
-
},
|
|
56
52
|
"dependencies": {
|
|
57
|
-
"@csszyx/core": "
|
|
58
|
-
"@csszyx/runtime": "
|
|
59
|
-
"@csszyx/compiler": "
|
|
60
|
-
"@csszyx/unplugin": "
|
|
61
|
-
"@csszyx/types": "
|
|
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"
|
|
62
58
|
},
|
|
63
59
|
"devDependencies": {
|
|
64
60
|
"tsup": "^8.0.2",
|
|
65
61
|
"typescript": "^5.4.5"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup src/index.ts src/lite.ts src/vite.ts src/webpack.ts --format esm --dts && echo '/// <reference types=\"@csszyx/types/jsx\" />' | cat - dist/index.d.ts > dist/index.d.ts.tmp && mv dist/index.d.ts.tmp dist/index.d.ts",
|
|
65
|
+
"dev": "tsup src/index.ts src/lite.ts src/vite.ts src/webpack.ts --format esm --dts --watch"
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|