You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-40Lines changed: 53 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ pip install "violetear[server]"
35
35
36
36
## 🚀 Quickstart: The Isomorphic Counter
37
37
38
-
Let's build a fully interactive "Counter" app where the state updates instantly in the browser, but every change is reported back to the server. **Zero JavaScript required.**
38
+
Let's build a fully interactive "Counter" app where the state updates instantly in the browser using our Pythonic DOM API, but every change is reported back to the server. **Zero JavaScript required.**
39
39
40
40
### Step 1: Initialize the App
41
41
@@ -46,6 +46,7 @@ from violetear import App, StyleSheet
46
46
from violetear.markup import Document, Element
47
47
from violetear.color import Colors
48
48
from violetear.style import Style
49
+
from violetear.dom import Event
49
50
50
51
app = App(title="Violetear Counter")
51
52
```
@@ -58,21 +59,25 @@ Instead of writing CSS strings, use the fluent API to define your theme.
Define the interactivity. The `@app.client` decorator compiles this function and sends it to the browser to run inside Pyodide.
100
+
Define the interactivity. The `@app.client` decorator compiles this function and sends it to the browser to run inside Pyodide. We use `violetear.dom` to manipulate the page using a familiar, pythonic API.
96
101
97
102
```python
98
103
@app.client
99
-
asyncdefhandle_change(event):
104
+
asyncdefhandle_change(event: Event):
100
105
"""
101
-
This runs in the BROWSER.
106
+
Runs in the browser.
102
107
"""
103
-
from js import document
108
+
# Import the DOM wrapper (Client-Side implementation)
*`UtilitySystem`: Generate thousands of utility classes (`p-4`, `text-xl`, `flex`, `hover:bg-red-500`) purely in Python without any build step.
179
+
*`Atomic`: A pre-made, completely configurable, Tailwind-like atomic CSS based on the utility system.
167
180
168
181
### 🧱 Component System
169
182
@@ -174,6 +187,7 @@ Run it with `python main.py` and open `http://localhost:8000`. You have a full-s
174
187
### ⚡ Full-Stack Application Engine
175
188
176
189
***Hybrid Architecture**: Supports both **Server-Side Rendering (SSR)** for SEO and speed, and **Client-Side Rendering (CSR)** for interactivity.
190
+
***Pythonic DOM**: A wrapper (`violetear.dom`) that provides a clean, type-safe Python API for DOM manipulation in the browser (`Document.find("id").text("Hello")`).
177
191
***Smart Hydration**: If a page has no interactive elements, `violetear` serves pure HTML. If you add an `@app.client` handler, it automatically injects the runtime.
178
192
***Asset Management**: Stylesheets created in Python are served directly from memory; no need to manage static files manually.
179
193
***Seamless RPC**: Call server functions from the browser as if they were local. Arguments and return values are automatically serialized.
@@ -183,7 +197,6 @@ Run it with `python main.py` and open `http://localhost:8000`. You have a full-s
183
197
We are just getting started. Here is what's coming in v1.1 and beyond:
184
198
185
199
***📱 Progressive Web Apps (PWA)**: Simply pass `App(pwa=True)` to automatically generate `manifest.json` and a Service Worker, making your Python app installable and offline-capable.
186
-
***🐍 Pythonic DOM**: A wrapper around `js.document` so you can manipulate the browser DOM using pythonic idioms and a fluent interface.
187
200
***🔥 JIT CSS**: An optimization engine that scans your Python code and serves *only* the CSS rules actually used by your components, reducing file size to the minimum.
188
201
189
202
## 🤝 Contribution
@@ -197,4 +210,4 @@ We are just getting started. Here is what's coming in v1.1 and beyond:
0 commit comments