Skip to content

Commit 308b4d0

Browse files
committed
feat: Added Readme, and created how to use Visual Walk through
1 parent 1f166ef commit 308b4d0

File tree

6 files changed

+295
-25
lines changed

6 files changed

+295
-25
lines changed

README.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@
44

55
Pre‑render your UI once, flip a `data-*` attribute to update — that's it.
66

7-
<a href="https://www.npmjs.com/package/@austinserb/react-zero-ui" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/bundlephobia/min/@austinserb/[email protected]" alt="npm version" />
8-
</a>
7+
<a href="https://bundlephobia.com/package/@austinserb/[email protected]" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/bundlephobia/min/@austinserb/[email protected]" alt="npm version" /> </a><a href="https://www.npmjs.com/package/@austinserb/react-zero-ui" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/npm/v/@austinserb/react-zero-ui" alt="npm version" /></a> <a href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a> ![CI](https://github.com/austin1serb/react-zero-ui/actions/workflows/ci.yml/badge.svg?branch=main)
98

10-
<a href="https://www.npmjs.com/package/@austinserb/react-zero-ui" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/npm/v/@austinserb/react-zero-ui" alt="npm version" /></a> <a href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a> ![CI](https://github.com/austin1serb/react-zero-ui/actions/workflows/ci.yml/badge.svg?branch=main)
9+
---
10+
11+
12+
## 📚 Quick Links
13+
14+
- [⚡️ Quick Start](#️-quick-start)
15+
- [🏄‍♂️ Usage](#-usage)
16+
- [🧬 How it works](#-how-it-works)
17+
- [✅ Features](#-features)
18+
- [🏗 Best Practices](#-best-practices)
1119

1220
---
1321

@@ -109,23 +117,7 @@ export default {
109117

110118
## 🏄‍♂️ Usage
111119

112-
### Theme toggle example
113-
114-
```tsx
115-
import { useUI } from '@austinserb/react-zero-ui';
116-
117-
export function ThemeToggle() {
118-
const [, setTheme] = useUI<'light' | 'dark'>('theme', 'light');
119-
120-
return <button onClick={() => setTheme('dark')}>Switch to dark</button>;
121-
}
122-
```
123-
124-
Consume the state anywhere with Tailwind variants:
125-
126-
```jsx
127-
<div className="theme-light:bg-white theme-dark:bg-black" />
128-
```
120+
![react zero ui usage explained](docs/assets/useui-explained.webp)
129121

130122
---
131123

@@ -192,4 +184,4 @@ PRs & issues welcome! Please read the [Contributing Guide](CONTRIBUTING.md).
192184

193185
---
194186

195-
Built with ❤️ for the React community. If Zero‑UI makes your app feel snappier, please ⭐️ the repo!
187+
Built with ❤️ for the React community. If Zero‑UI makes your app feel ZERO fast, please ⭐️ the repo!

docs/assets/useui-explained.webp

70.3 KB
Loading

packages/cli/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Create Zero-UI
2+
3+
A blazing-fast React CLI starter powered by **React Zero-UI** — the pre-rendered UI state engine with zero re-renders and zero runtime overhead.
4+
5+
```bash
6+
npx create-zero-ui
7+
```
8+
9+
🏁 Instantly scaffold and patch your **Next.js (App Router)** or **Vite** app with:
10+
11+
✅ Tailwind CSS v4 integration
12+
✅ Zero-UI Babel + PostCSS setup
13+
✅ Autogenerated `data-*` UI state system
14+
✅ One command, production-ready result
15+
16+
---
17+
18+
## 🧠 What is Zero-UI?
19+
20+
Zero-UI is a global UI state engine that updates your interface using `data-*` attributes — **no React state, no VDOM, no re-renders**.
21+
22+
It works by:
23+
24+
1. Scanning your components for `useUI()` hooks
25+
2. Pre-generating Tailwind variants for each UI state
26+
3. Updating `data-*` attributes on `<body>` to drive the UI instantly
27+
28+
👉 Live Demo: [https://react-zero-ui.vercel.app](https://react-zero-ui.vercel.app)
29+
👉 Package: [https://www.npmjs.com/package/@austinserb/react-zero-ui](https://www.npmjs.com/package/@austinserb/react-zero-ui)
30+
31+
---
32+
33+
## 🚀 Quickstart
34+
35+
Inside your project root:
36+
37+
```bash
38+
npx create-zero-ui
39+
```
40+
41+
That's it — you'll get:
42+
43+
* `.zero-ui/attributes.js` autogen
44+
* Working PostCSS + Tailwind integration
45+
* Babel config patched if needed
46+
* Ready to use `useUI()` in components
47+
48+
---
49+
50+
## 📦 Package Used
51+
52+
Powered by:
53+
54+
```json
55+
"@austinserb/react-zero-ui": "^1.0.20"
56+
```
57+
58+
Full docs and live benchmarks:
59+
👉 [https://github.com/austin1serb/react-zero-ui](https://github.com/austin1serb/react-zero-ui)
60+
61+
---
62+
63+
## 🧬 Example Usage
64+
65+
66+
## 🏄‍♂️ Usage
67+
68+
![react zero ui usage explained](docs/assets/useui-explained.webp)
69+
70+
71+
---
72+
73+
## 🛠 Tech Notes
74+
75+
* This CLI only supports Tailwind v4+ projects
76+
* It does **not** install Tailwind for you — install Tailwind first
77+
* You must restart your dev server after running the CLI to see effects
78+
79+
---
80+
81+
## 🙌 Author
82+
83+
Made by [@austinserb](https://github.com/austin1serb)
84+
85+
Built with ❤️ for the React community. If Zero‑UI makes your app feel ZERO fast, please ⭐️ the repo!
86+
87+
---
88+
89+
## 📜 License
90+
91+
[MIT](LICENSE) © Austin Serb

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-zero-ui",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"type": "module",
55
"main": "./bin.js",
66
"bin": {
@@ -14,9 +14,9 @@
1414
"package.json"
1515
],
1616
"dependencies": {
17-
"@austinserb/react-zero-ui": "workspace:^",
17+
"@austinserb/react-zero-ui": "^1.0.20",
1818
"postcss": "^8.4.27",
1919
"tailwindcss": "^4.0.0",
2020
"@tailwindcss/postcss": "^4.1.8"
2121
}
22-
}
22+
}

packages/core/README.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# React Zero‑UI (Beta)
2+
3+
**Instant UI state updates. ZERO React re‑renders. <1 KB runtime.**
4+
5+
Pre‑render your UI once, flip a `data-*` attribute to update — that's it.
6+
7+
<a href="https://bundlephobia.com/package/@austinserb/[email protected]" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/bundlephobia/min/@austinserb/[email protected]" alt="npm version" /> </a><a href="https://www.npmjs.com/package/@austinserb/react-zero-ui" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/npm/v/@austinserb/react-zero-ui" alt="npm version" /></a> <a href="https://opensource.org/licenses/MIT" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a> ![CI](https://github.com/austin1serb/react-zero-ui/actions/workflows/ci.yml/badge.svg?branch=main)
8+
9+
---
10+
11+
12+
## 📚 Quick Links
13+
14+
- [⚡️ Quick Start](#️-quick-start)
15+
- [🏄‍♂️ Usage](#-usage)
16+
- [🧬 How it works](#-how-it-works)
17+
- [✅ Features](#-features)
18+
- [🏗 Best Practices](#-best-practices)
19+
20+
---
21+
22+
## 🚀 Live Demo
23+
24+
| Example | Link | What it shows | Link to Code |
25+
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
26+
| Interactive menu with render tracker | <a href="https://react-zero-ui.vercel.app/" target="_blank" rel="noopener noreferrer"><strong>Main Demo↗</strong></a> | Compare Zero‑UI vs. React side‑by‑side while toggling a menu. | <a href="https://github.com/Austin1serb/React-Zero-UI/tree/main/examples/demo" target="_blank" rel="noopener noreferrer">Github</a> |
27+
| React benchmark (10 000 nested nodes) | <a href="https://react-zero-ui.vercel.app/react" target="_blank" rel="noopener noreferrer"><strong>React 10k↗</strong></a> | How long the traditional React render path takes. | <a href="https://github.com/Austin1serb/React-Zero-UI/tree/main/examples/demo/src/app/react" target="_blank" rel="noopener noreferrer">Github</a> |
28+
| Zero‑UI benchmark (10 000 nested nodes) | <a href="https://react-zero-ui.vercel.app/zero-ui" target="_blank" rel="noopener noreferrer"><strong style="text-align: nowrap;">Zero‑UI 10k↗</strong></a> | Identical DOM, but powered by Zero‑UI's `data-*` switch. | <a href="https://github.com/Austin1serb/React-Zero-UI/tree/main/examples/demo/src/app/zero-ui" target="_blank" rel="noopener noreferrer">Github</a> |
29+
30+
---
31+
32+
## 🧐 Why Zero‑UI?
33+
34+
Every `setState` in React triggers the full VDOM → Diff → Reconciliation → Paint pipeline. For _pure UI state_ (themes, menus, toggles) that work is wasted.
35+
36+
**Zero‑UI introduces "_PRE‑rendering_":**
37+
38+
1. Tailwind variants for every state are **generated at build‑time**.
39+
2. The app **pre‑renders once**.
40+
3. Runtime state changes only **flip a `data-*` attribute on `<body>`**.
41+
42+
Result → **5-10× faster visual updates** with **ZERO additional bundle cost**.
43+
44+
### 📊 Micro‑benchmarks (Apple M1)
45+
46+
| Nodes updated | React state | Zero‑UI | Speed‑up |
47+
| ------------- | ----------- | ------- | -------- |
48+
| 10,000 | \~50 ms | \~5 ms | **10×** |
49+
| 25,000 | \~180 ms | \~15 ms | **12×** |
50+
| 50,000 | \~300 ms | \~20 ms | **15×** |
51+
52+
Re‑run these numbers yourself via the links above.
53+
54+
---
55+
56+
## ⚡️ Quick Start
57+
58+
> **Prerequisite:** Tailwind CSS v4 must already be initialized in your project.
59+
60+
```bash
61+
# Inside an existing *Next.js (App Router)* or *Vite* repo
62+
npx create-zero-ui
63+
```
64+
65+
That's it — the CLI patch‑installs the required Babel & PostCSS plugins and updates `configs` for you.
66+
67+
### Manual Install
68+
69+
```bash
70+
npm install @austinserb/react-zero-ui
71+
```
72+
73+
Then follow **Setup →** for your bundler.
74+
75+
---
76+
77+
## 🔧 Setup
78+
79+
### Vite
80+
81+
```js
82+
// vite.config.*
83+
import { zeroUIPlugin } from '@austinserb/react-zero-ui/vite';
84+
85+
export default {
86+
// ❗️Remove the default `tailwindcss()` plugin — Zero‑UI extends it internally
87+
plugins: [zeroUIPlugin()],
88+
};
89+
```
90+
91+
### Next.js (App Router)
92+
93+
1. **Spread `bodyAttributes` on `<body>`** in your root layout.
94+
95+
```tsx
96+
// app/layout.tsx
97+
import { bodyAttributes } from '@austinserb/react-zero-ui/attributes';
98+
// or: import { bodyAttributes } from '../.zero-ui/attributes';
99+
100+
export default function RootLayout({ children }) {
101+
return (
102+
<html lang="en">
103+
<body {...bodyAttributes}>{children}</body>
104+
</html>
105+
);
106+
}
107+
```
108+
109+
2. **Add the PostCSS plugin (must come _before_ Tailwind).**
110+
111+
```js
112+
// postcss.config.js
113+
module.exports = { plugins: { '@austinserb/react-zero-ui/postcss': {}, tailwindcss: {} } };
114+
```
115+
116+
---
117+
118+
## 🏄‍♂️ Usage
119+
120+
![react zero ui usage explained](docs/assets/useui-explained.webp)
121+
122+
---
123+
124+
## 🛠 API
125+
126+
### `useUI(key, defaultValue)`
127+
128+
```ts
129+
const [staleValue, setValue] = useUI<'open' | 'closed'>('sidebar', 'closed');
130+
```
131+
132+
- `key` → becomes `data-{key}` on `<body>`.
133+
- `defaultValue` → optional, prevents FOUC.
134+
- **Note:** the returned `staleValue` does **not** update (`useUI` is write‑only).
135+
136+
### Tailwind variants
137+
138+
```jsx
139+
<div className="sidebar-open:translate-x-0 sidebar-closed:-translate-x-full" />
140+
```
141+
142+
Any `data-{key}="{value}"` pair becomes a variant: `{key}-{value}:`.
143+
144+
---
145+
146+
## 🧬 How it works
147+
148+
1. **`useUI`** → writes to `data-*` attributes on `<body>`.
149+
2. **Babel plugin** → scans code, finds every `key/value`, injects them into **PostCSS**.
150+
3. **PostCSS plugin** → generates static Tailwind classes **at build‑time**.
151+
4. **Runtime** → changing state only touches the attribute — no VDOM, no reconciliation, no re‑paint.
152+
153+
---
154+
155+
## ✅ Features
156+
157+
- **Zero React re‑renders** for UI‑only state.
158+
- **Global setters** — call from any component or util.
159+
- **Tiny**: < 1 KB gzipped runtime.
160+
- **TypeScript‑first**.
161+
- **SSR‑friendly** (Next.js & Vite SSR).
162+
- **Framework‑agnostic CSS** — generated classes work in plain HTML / Vue / Svelte as well.
163+
164+
---
165+
166+
## 🏗 Best Practices
167+
168+
1. **UI state only** → themes, layout toggles, feature flags.
169+
2. **Business logic stays in React** → fetching, data mutation, etc.
170+
3. **Kebab‑case keys** → e.g. `sidebar-open`.
171+
4. **Provide defaults** to avoid Flash‑Of‑Unstyled‑Content.
172+
173+
---
174+
175+
## 🤝 Contributing
176+
177+
PRs & issues welcome! Please read the [Contributing Guide](CONTRIBUTING.md).
178+
179+
---
180+
181+
## 📜 License
182+
183+
[MIT](LICENSE) © Austin Serb
184+
185+
---
186+
187+
Built with ❤️ for the React community. If Zero‑UI makes your app feel ZERO fast, please ⭐️ the repo!

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@austinserb/react-zero-ui",
3-
"version": "1.0.19",
3+
"version": "1.0.20",
44
"description": "Zero re-render UI state management for React",
55
"private": false,
66
"type": "module",

0 commit comments

Comments
 (0)