zulip/README.md

99 lines
1.9 KiB
Markdown
Raw Normal View History

2026-03-04 17:45:32 -08:00
# zulip
2026-03-04 11:13:15 -08:00
2026-03-04 17:45:32 -08:00
A minimal, no-build web app kit using only Lit-based web components via importmaps.
2026-03-04 14:18:44 -08:00
2026-03-04 12:23:40 -08:00
## Quick Start Example
2026-03-04 14:18:44 -08:00
### 1. Define a Component
2026-03-04 12:23:40 -08:00
```javascript
// components/counter.js
import { LitElement, html, css } from 'lit'
class Counter extends LitElement {
2026-03-04 14:18:44 -08:00
static properties = {
count: { type: Number, state: true }
}
constructor() {
super()
this.count = 0
}
2026-03-04 12:23:40 -08:00
static styles = css`
button { padding: 1rem; font-size: 1.2rem; }
`
render() {
return html`
<div>
2026-03-04 14:18:44 -08:00
<p>Count: ${this.count}</p>
<button @click=${() => this.count++}>
2026-03-04 12:23:40 -08:00
Increment
</button>
</div>
`
}
}
customElements.define('my-counter', Counter)
```
2026-03-04 17:45:32 -08:00
### 2. Use in App root (or other composition node)
2026-03-04 14:18:44 -08:00
2026-03-04 17:45:32 -08:00
```js
import "./my-counter.js";
2026-03-04 14:18:44 -08:00
class AppRoot extends LitElement {
2026-03-04 17:45:32 -08:00
...
render() {
return html`<my-counter .count=${0}></my-counter>`;
2026-03-04 14:18:44 -08:00
}
2026-03-04 17:45:32 -08:00
}
```
2026-03-04 14:18:44 -08:00
2026-03-04 17:45:32 -08:00
### 3. Define Data Flows
2026-03-04 14:18:44 -08:00
2026-03-04 17:45:32 -08:00
#### Parent-to-Child (Props)
2026-03-04 14:18:44 -08:00
2026-03-04 17:45:32 -08:00
```javascript
// Parent passes data down
html`<child-component .items=${this.items}></child-component>`
// Child receives via properties
static properties = {
items: { type: Array }
2026-03-04 14:18:44 -08:00
}
```
2026-03-04 17:45:32 -08:00
#### Child-to-Parent (Events)
2026-03-04 14:18:44 -08:00
```javascript
2026-03-04 17:45:32 -08:00
// Child emits event
this.dispatchEvent(new CustomEvent('add-item', {
detail: { item: newItem },
bubbles: true,
composed: true
}))
2026-03-04 14:18:44 -08:00
2026-03-04 17:45:32 -08:00
// Parent listens
html`<child-component @add-item=${(e) => this.handleAdd(e.detail.item)}></child-component>`
2026-03-04 14:18:44 -08:00
```
2026-03-04 17:45:32 -08:00
## Benefits Over TSX
1. **No build step** - Edit and refresh, instant feedback
1. **Minimal dependencies** - Just Lit, nothing else
1. **Smaller bundle** - No framework runtime, just standards
1. **Better encapsulation** - Shadow DOM, scoped styles
1. **Framework agnostic** - Works anywhere, even in React apps
1. **Future-proof** - Built on web standards
1. **Easy to learn** - Simple mental model for state, with natural evolution into Zustand/IndexedDB or similar extensions