Skip to content

Commit 7077a7b

Browse files
committed
more docs
1 parent e01f994 commit 7077a7b

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

README.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# petite-vue
22

3-
`petite-vue` is a subset of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model with standard Vue. However, it is specifically optimized for "sprinkling" small amount of interactions on an existing HTML page rendered by a server framework.
3+
`petite-vue` is an alternative distribution of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model with standard Vue. However, it is specifically optimized for "sprinkling" small amount of interactions on an existing HTML page rendered by a server framework.
44

5-
- 5.5kb min+brotli w/ most non-component features
5+
- Only 5.5kb
66
- DOM-based, mutates in place
77
- Driven by `@vue/reactivity`
88

99
## Usage
1010

11-
`petite-vue` has one special directive: `v-scope` that is not present in standard Vue. Use it to mark regions on the page that should be controlled by `petite-vue`:
12-
1311
```html
1412
<script src="https://unpkg.com/petite-vue" defer init></script>
1513

@@ -20,7 +18,9 @@
2018
</div>
2119
```
2220

23-
The `defer` attribute makes the script execute after HTML content is parsed, and `init` tells `petite-vue` to automatically query and initialize all elements that have `v-scope` on the page.
21+
- Use `v-scope` to mark regions on the page that should be controlled by `petite-vue`.
22+
- The `defer` attribute makes the script execute after HTML content is parsed.
23+
- The `init` attribute tells `petite-vue` to automatically query and initialize all elements that have `v-scope` on the page.
2424

2525
### Manual Init
2626

@@ -42,6 +42,17 @@ Or, use the ES modules build:
4242
<script>
4343
```
4444
45+
### `v-effect`
46+
47+
Use `v-effect` to execute inline reactive statements:
48+
49+
```html
50+
<div v-scope="{ count: 0 }">
51+
<div v-effect="$el.textContent = count"></div>
52+
<button @click="count++">++</button>
53+
</div>
54+
```
55+
4556
### Global Data
4657
4758
The `createApp` function accepts a data object that serves as the root scope for all expressions. This can be used for simple global state management:
@@ -145,7 +156,19 @@ const html = ({ el, get, effect }) => {
145156
}
146157
```
147158

148-
## Supported Features
159+
## Features
160+
161+
### `petite-vue` only
162+
163+
- `v-scope`
164+
- `v-effect`
165+
166+
### Has Different Behavior
167+
168+
- `createApp()` (accepts global state instead of root component)
169+
- Custom directives
170+
171+
### Vue Compatible
149172

150173
- `{{ }}` text bindings
151174
- `v-bind` (including `:` shorthand and class/style special handling)
@@ -159,9 +182,9 @@ const html = ({ el, get, effect }) => {
159182
- `v-pre`
160183
- `v-cloak`
161184
- `reactive()`
162-
- Custom directives (see above).
185+
- `nextTick()`
163186

164-
## Not Supported
187+
### Not Supported
165188

166189
Some features are dropped because they have a relatively low size/utility ratio in the context of progressive enhancement. If you need these features, you should probably just use standard Vue.
167190

@@ -176,3 +199,10 @@ Some features are dropped because they have a relatively low size/utility ratio
176199
- `v-once`
177200
- `v-is` & `<component :is="xxx">`
178201
- `v-bind:style` auto-prefixing
202+
203+
## Relationship with Alpine
204+
205+
- This is indeed addressing a similar scope to Alpine, but aims to be even more minimal.
206+
- `petite-vue` is less than half the size of Alpine.
207+
- `petite-vue` has no transition system (maybe this can be an opt-in plugin).
208+
- Alpine is developing its own ecosystem and likely will diverge more from Vue in the future. `petite-vue` aligns with standard Vue behavior whenever possible, so it's less friction moving to standard Vue if needed. It's intended to cover the progressive enhancement use case where standard Vue is less optimized for nowadays.

0 commit comments

Comments
 (0)