Skip to content

Commit 1a52160

Browse files
committed
Some small twerk to Lively Docs
1 parent cccfc1d commit 1a52160

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

docs/source/lively-components.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,76 @@ It leverages **WebSockets with msgpack** for fast communication and supports nav
99
1010
---
1111

12+
## 🚀 What Is the Lively Component System?
13+
14+
The **Lively Component System** is Duck’s way of building interactive web pages using pure Python.
15+
16+
Instead of writing JavaScript for buttons, forms, or live updates, you write Python classes. Duck automatically handles the real-time communication between the browser and the server for you.
17+
18+
Think of it like this:
19+
20+
> You write Python.
21+
> Duck makes the browser react instantly.
22+
23+
---
24+
25+
## 🤔 What Problem Does It Solve?
26+
27+
Normally, web apps need:
28+
29+
- HTML for structure
30+
- CSS for styling
31+
- JavaScript for interactivity
32+
- A backend language for logic
33+
34+
With Lively Components, you can:
35+
36+
- Define UI elements in Python
37+
- Attach event handlers in Python
38+
- Update the page dynamically
39+
- Avoid writing JavaScript for most interactions
40+
41+
The system keeps the page updated without full reloads.
42+
43+
---
44+
45+
## ⚙️ How It Works (Simple Explanation)
46+
47+
1. You create a **Page class** in Python.
48+
2. You add components (like buttons, text, forms).
49+
3. You attach Python functions to events (like button clicks).
50+
4. When a user interacts with the page:
51+
- The browser sends the event to the server.
52+
- Your Python function runs.
53+
- Only the changed parts of the page update.
54+
55+
This feels similar to React or other reactive frameworks — but controlled from Python.
56+
57+
---
58+
59+
## 💡 Why It’s Powerful
60+
61+
- Real-time updates without manual JavaScript
62+
- Cleaner architecture (UI + logic in one place)
63+
- Fast navigation between pages
64+
- Component reuse
65+
- Built-in lifecycle handling
66+
67+
---
68+
69+
## 🧠 Beginner Mental Model
70+
71+
If you’re new, think of it like this:
72+
73+
- A **Page** = a screen
74+
- A **Component** = a piece of UI (button, text, input)
75+
- An **Event** = something the user does (click, type)
76+
- Your Python method = what should happen next
77+
78+
And Duck handles the browser synchronization automatically.
79+
80+
---
81+
1282
## 📄 Page Component Example
1383

1484
```py

0 commit comments

Comments
 (0)