Skip to content

Commit 8e9897b

Browse files
authored
v0.3.4
* added new development next environment * v3.3.4 * update ci node version to v22 * add prepack test to cli * chore: add prepare script to cli package * added css file scanning * fix: test + console.log
1 parent 6234259 commit 8e9897b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3386
-815
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ React Zero-UI uses a hyper-optimized AST resolver in development that scans your
6363

6464
<small>Zero-UI CLI</small>
6565

66-
**Pre-requisites:**
67-
* <small>Vite or Next.js (App Router)</small>
68-
* <small>Tailwind V4 Configured. See [Tailwind V4 Installation](https://tailwindcss.com/docs/installation/using-vite)</small>
66+
**Pre-requisites:**
67+
68+
- <small>Vite or Next.js (App Router)</small>
69+
- <small>Tailwind V4 Configured. See [Tailwind V4 Installation](https://tailwindcss.com/docs/installation/using-vite)</small>
6970

7071
```bash
7172
npx create-zero-ui
@@ -141,9 +142,10 @@ Sometimes CSS variables are more efficient. React Zero-UI makes it trivial by pa
141142
```diff
142143
+ Pass `CssVar` to either hook to use CSS variables
143144

144-
useUI(<cssVariable>, <defaultValue>, CssVar);
145+
useUI(<cssVariable>, <defaultValue>, CssVar);
145146

146147
```
148+
147149
<small>automatically adds `--` to the Css Variable</small>
148150

149151
**Global CSS Variable:**
@@ -200,26 +202,26 @@ React Zero-UI delivers the fastest, simplest, most performant way to handle glob
200202

201203
### 📚 Complete Guide Collection
202204

203-
| Guide | Description |
204-
|-------|-------------|
205-
| [📚 API Reference](/docs/api-reference.md) | Complete API documentation for all hooks and utilities |
206-
| [📋 Usage Examples](/docs/usage-examples.md) | Practical patterns and real-world use cases |
207-
| [🔄 Migration Guide](/docs/migration-guide.md) | Step-by-step migration from useState, Context, Redux |
208-
| [🔧 Troubleshooting](/docs/troubleshooting.md) | Common issues and debugging techniques |
209-
| [❓ FAQ](/docs/faq.md) | Frequently asked questions and answers |
210-
| [🧪 Experimental Features](/docs/experimental.md) | SSR-safe server component interactivity |
205+
| Guide | Description |
206+
| ------------------------------------------------- | ------------------------------------------------------ |
207+
| [📚 API Reference](/docs/api-reference.md) | Complete API documentation for all hooks and utilities |
208+
| [📋 Usage Examples](/docs/usage-examples.md) | Practical patterns and real-world use cases |
209+
| [🔄 Migration Guide](/docs/migration-guide.md) | Step-by-step migration from useState, Context, Redux |
210+
| [🔧 Troubleshooting](/docs/troubleshooting.md) | Common issues and debugging techniques |
211+
| [❓ FAQ](/docs/faq.md) | Frequently asked questions and answers |
212+
| [🧪 Experimental Features](/docs/experimental.md) | SSR-safe server component interactivity |
211213

212214
### 🛠️ Setup Guides
213215

214-
| Framework | Guide |
215-
|-----------|-------|
216+
| Framework | Guide |
217+
| ------------------------------------------------ | --------------------------------------- |
216218
| [Next.js App Router](/docs/installation-next.md) | Complete Next.js setup with SSR support |
217-
| [Vite + React](/docs/installation-vite.md) | Vite configuration and optimization |
219+
| [Vite + React](/docs/installation-vite.md) | Vite configuration and optimization |
218220

219221
### 🎯 Learn by Example
220222

221223
- [🎮 **Live Demo**](https://zero-ui.dev/) - Interactive playground
222-
- [📊 **Performance Demo**](https://zero-ui.dev/react) - 10k component benchmark
224+
- [📊 **Performance Demo**](https://zero-ui.dev/react) - 10k component benchmark
223225
- [📁 **Demo Source Code**](/examples/demo/) - Complete example project
224226

225227
---

docs/api-reference.md

Lines changed: 48 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<div align="center">
32

43
# 📚 API Reference
@@ -12,6 +11,7 @@ Detailed reference for all hooks, utilities, and configuration options.
1211
---
1312

1413
## 📚 Table of Contents
14+
1515
- [🔨 Core Hooks](#-core-hooks)
1616
- [🌈 Utilities](#-utilities)
1717
- [🧪 Experimental APIs](#-experimental-apis)
@@ -34,18 +34,18 @@ const [staleValue, setter] = useUI(key, initial, flag?);
3434
3535
#### Parameters
3636
37-
| Parameter | Type | Description |
38-
|-----------|------|-------------|
39-
| `key` | `string` | The state key (becomes `data-{key}` attribute) |
40-
| `initial` | `T` | Initial/default value for SSR |
41-
| `flag?` | `typeof CssVar` | Optional: Use CSS variables instead of data attributes |
37+
| Parameter | Type | Description |
38+
| --------- | --------------- | ------------------------------------------------------ |
39+
| `key` | `string` | The state key (becomes `data-{key}` attribute) |
40+
| `initial` | `T` | Initial/default value for SSR |
41+
| `flag?` | `typeof CssVar` | Optional: Use CSS variables instead of data attributes |
4242
4343
#### Returns
4444
45-
| Return | Type | Description |
46-
|--------|------|-------------|
47-
| `staleValue` | `T` | Initial value (doesn't update, use for SSR only) |
48-
| `setter` | `GlobalSetterFn<T>` | Function to update the global state |
45+
| Return | Type | Description |
46+
| ------------ | ------------------- | ------------------------------------------------ |
47+
| `staleValue` | `T` | Initial value (doesn't update, use for SSR only) |
48+
| `setter` | `GlobalSetterFn<T>` | Function to update the global state |
4949
5050
#### Examples
5151
@@ -62,7 +62,7 @@ const [color, setColor] = useUI('primary', '#blue', CssVar);
6262
setColor('#red'); // Sets --primary: #red on <body>
6363

6464
// Functional updates
65-
setTheme(prev => prev === 'light' ? 'dark' : 'light');
65+
setTheme((prev) => (prev === 'light' ? 'dark' : 'light'));
6666
```
6767
6868
---
@@ -81,35 +81,33 @@ Same as `useUI`, but affects only the element assigned to `setter.ref`.
8181
8282
#### Returns
8383
84-
| Return | Type | Description |
85-
|--------|------|-------------|
86-
| `staleValue` | `T` | Initial value (doesn't update, use for SSR only) |
87-
| `setter` | `ScopedSetterFn<T>` | Function with attached `ref` property |
84+
| Return | Type | Description |
85+
| ------------ | ------------------- | ------------------------------------------------ |
86+
| `staleValue` | `T` | Initial value (doesn't update, use for SSR only) |
87+
| `setter` | `ScopedSetterFn<T>` | Function with attached `ref` property |
8888
8989
#### Examples
9090
9191
```tsx
9292
// Basic scoped usage
9393
const [modal, setModal] = useScopedUI('modal', 'closed');
9494

95-
<div
95+
<div
9696
ref={setModal.ref}
9797
data-modal={modal} // Prevents FOUC
98-
className="modal-closed:hidden modal-open:block"
99-
>
98+
className="modal-closed:hidden modal-open:block">
10099
Modal content
101-
</div>
100+
</div>;
102101

103102
// With CSS variables
104103
const [blur, setBlur] = useScopedUI('blur', '0px', CssVar);
105104

106-
<div
105+
<div
107106
ref={setBlur.ref}
108107
style={{ '--blur': blur }}
109-
className="backdrop-blur-[var(--blur)]"
110-
>
108+
className="backdrop-blur-[var(--blur)]">
111109
Blurred content
112-
</div>
110+
</div>;
113111
```
114112
115113
---
@@ -148,10 +146,10 @@ const clickHandler = zeroSSR.onClick(key, values);
148146
149147
#### Parameters
150148
151-
| Parameter | Type | Description |
152-
|-----------|------|-------------|
153-
| `key` | `string` | State key (kebab-case required) |
154-
| `values` | `string[]` | Array of values to cycle through |
149+
| Parameter | Type | Description |
150+
| --------- | ---------- | -------------------------------- |
151+
| `key` | `string` | State key (kebab-case required) |
152+
| `values` | `string[]` | Array of values to cycle through |
155153
156154
#### Returns
157155
@@ -189,13 +187,9 @@ Same as `zeroSSR.onClick`, but affects the closest ancestor with `data-{key}` at
189187
190188
```tsx
191189
<div data-modal="closed">
192-
<button {...scopedZeroSSR.onClick('modal', ['closed', 'open'])}>
193-
Open Modal
194-
</button>
195-
196-
<div className="modal-closed:hidden modal-open:block">
197-
Modal content
198-
</div>
190+
<button {...scopedZeroSSR.onClick('modal', ['closed', 'open'])}>Open Modal</button>
191+
192+
<div className="modal-closed:hidden modal-open:block">Modal content</div>
199193
</div>
200194
```
201195
@@ -214,8 +208,8 @@ activateZeroUiRuntime(variantKeyMap);
214208
215209
#### Parameters
216210
217-
| Parameter | Type | Description |
218-
|-----------|------|-------------|
211+
| Parameter | Type | Description |
212+
| ------------ | -------------------------- | -------------------------------------------- |
219213
| `variantMap` | `Record<string, string[]>` | Generated variant mapping from build process |
220214
221215
#### Setup
@@ -285,16 +279,13 @@ interface ScopedSetterFn<T extends string = string> {
285279
## 🚨 Limitations & Constraints
286280
287281
### State Key Requirements
282+
288283
- DO NOT USE IMPORTED VARIABLES IN THE STATE KEY
289284
- Must be valid HTML attribute names
290285
- Kebab-case required: `'sidebar-state'` not `'sidebarState'`
291286
- Avoid conflicts with existing data attributes
292287
- Must resolve to a non-spaced string: `'sidebar-state'` not `'sidebar State'`
293-
- Must be a local constant that resolves to a string:
294-
295-
296-
297-
288+
- Must be a local constant that resolves to a string:
298289
299290
### Scoped UI Constraints
300291
@@ -325,12 +316,11 @@ Generated variant mapping for runtime activation.
325316
```ts
326317
/* AUTO-GENERATED - DO NOT EDIT */
327318
export const bodyAttributes = {
328-
"data-theme": "light",
329-
"data-accent": "violet",
330-
"data-scrolled": "up",
331-
// ...
319+
'data-theme': 'light',
320+
'data-accent': 'violet',
321+
'data-scrolled': 'up',
322+
// ...
332323
};
333-
334324
```
335325
336326
### `.zero-ui/styles.css` (Vite)
@@ -339,7 +329,7 @@ Generated CSS variants for Vite projects.
339329
340330
```css
341331
/* Auto-generated Tailwind variants */
342-
[data-theme="dark"] .theme-dark\:bg-gray-900 {
332+
[data-theme='dark'] .theme-dark\:bg-gray-900 {
343333
background-color: rgb(17 24 39);
344334
}
345335
/* ... */
@@ -385,14 +375,14 @@ cat .zero-ui/attributes.ts
385375
386376
```tsx
387377
// ✅ Good: Descriptive and clear
388-
useUI('theme', 'light')
389-
useUI('sidebar-state', 'collapsed')
390-
useUI('modal-visibility', 'hidden')
378+
useUI('theme', 'light');
379+
useUI('sidebar-state', 'collapsed');
380+
useUI('modal-visibility', 'hidden');
391381

392382
// ❌ Avoid: Generic or unclear
393-
useUI('state', 'on')
394-
useUI('x', 'y')
395-
useUI('toggle', 'true')
383+
useUI('state', 'on');
384+
useUI('x', 'y');
385+
useUI('toggle', 'true');
396386
```
397387
398388
### TypeScript Usage
@@ -411,13 +401,13 @@ const [, setModal] = useUI<ModalState>('modal', 'closed');
411401
412402
```tsx
413403
// ✅ Use CSS for conditional rendering
414-
<div className="modal-closed:hidden modal-open:block">
415-
Modal content
416-
</div>
404+
<div className="modal-closed:hidden modal-open:block">Modal content</div>;
417405

418406
// ❌ Avoid reading stale values for logic
419407
const [modal, setModal] = useUI('modal', 'closed');
420-
{modal === 'open' && <Modal />} // Won't work as expected
408+
{
409+
modal === 'open' && <Modal />;
410+
} // Won't work as expected
421411
```
422412
423413
---
@@ -428,4 +418,4 @@ const [modal, setModal] = useUI('modal', 'closed');
428418
429419
[**📋 Usage Examples**](./usage-examples.md) | [**🔧 Troubleshooting**](./troubleshooting.md) | [**🔄 Migration Guide**](./migration-guide.md)
430420
431-
</div>
421+
</div>

docs/demo.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Experience the difference between React re-renders and Zero-UI's instant updates
1414

1515
## 🎯 Interactive Examples
1616

17-
| Demo | Description | Live Link | Source Code |
18-
| -- | -- | -- | -- |
19-
| **🎛️ Interactive Menu** | Side-by-side comparison with render tracker | [Main Demo](https://zero-ui.dev/) | [GitHub](https://zero-ui.dev/react) |
20-
| **⚛️ React Benchmark** | Traditional React render path (10k nodes) | [React 10k](https://zero-ui.dev/react) | [GitHub](https://github.com/react-zero-ui/core/tree/main/examples/demo/src/app/react) |
17+
| Demo | Description | Live Link | Source Code |
18+
| ------------------------- | ------------------------------------------------- | ------------------------------------------ | --------------------------------------------------------------------------------------- |
19+
| **🎛️ Interactive Menu** | Side-by-side comparison with render tracker | [Main Demo](https://zero-ui.dev/) | [GitHub](https://zero-ui.dev/react) |
20+
| **⚛️ React Benchmark** | Traditional React render path (10k nodes) | [React 10k](https://zero-ui.dev/react) | [GitHub](https://github.com/react-zero-ui/core/tree/main/examples/demo/src/app/react) |
2121
| **⚡️ Zero-UI Benchmark** | Identical DOM with `data-*` switching (10k nodes) | [Zero-UI 10k](https://zero-ui.dev/zero-ui) | [GitHub](https://github.com/react-zero-ui/core/tree/main/examples/demo/src/app/zero-ui) |
2222

2323
> **📁 Full Demo Source:** [Zero Rerender Demo](/examples/demo/)
@@ -47,10 +47,10 @@ _Tested on Apple M1 - Chrome DevTools Performance Tab_
4747
</div>
4848

4949
| **Nodes Updated** | **React State** | **Zero-UI** | **Speed Improvement** |
50-
| :--: | :--: | :--: | :--: |
51-
| 10,000 | ~50 ms | ~5 ms | **🚀 10× faster** |
52-
| 25,000 | ~180 ms | ~15 ms | **🚀 12× faster** |
53-
| 50,000 | ~300 ms | ~20 ms | **🚀 15× faster** |
50+
| :---------------: | :-------------: | :---------: | :-------------------: |
51+
| 10,000 | ~50 ms | ~5 ms | **🚀 10× faster** |
52+
| 25,000 | ~180 ms | ~15 ms | **🚀 12× faster** |
53+
| 50,000 | ~300 ms | ~20 ms | **🚀 15× faster** |
5454

5555
> **🔬 Try it yourself:** Re-run these benchmarks using the demo links above with Chrome DevTools.
5656

0 commit comments

Comments
 (0)