lego-dom 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy-docs.yml +56 -0
- package/LICENSE +21 -0
- package/README.md +298 -355
- package/docs/.vitepress/config.js +107 -0
- package/docs/.vitepress/dist/404.html +22 -0
- package/docs/.vitepress/dist/api/define.html +35 -0
- package/docs/.vitepress/dist/api/directives.html +32 -0
- package/docs/.vitepress/dist/api/globals.html +27 -0
- package/docs/.vitepress/dist/api/index.html +25 -0
- package/docs/.vitepress/dist/api/lifecycle.html +38 -0
- package/docs/.vitepress/dist/api/route.html +34 -0
- package/docs/.vitepress/dist/api/vite-plugin.html +37 -0
- package/docs/.vitepress/dist/assets/api_define.md.UA-ygUnQ.js +11 -0
- package/docs/.vitepress/dist/assets/api_define.md.UA-ygUnQ.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_directives.md.BV-D251p.js +8 -0
- package/docs/.vitepress/dist/assets/api_directives.md.BV-D251p.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_globals.md.DOjt7AV0.js +3 -0
- package/docs/.vitepress/dist/assets/api_globals.md.DOjt7AV0.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_index.md.OS6h01ct.js +1 -0
- package/docs/.vitepress/dist/assets/api_index.md.OS6h01ct.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_lifecycle.md.Ccm5xw6-.js +14 -0
- package/docs/.vitepress/dist/assets/api_lifecycle.md.Ccm5xw6-.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_route.md.CAHf_KNp.js +10 -0
- package/docs/.vitepress/dist/assets/api_route.md.CAHf_KNp.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_vite-plugin.md.DNn9VhL5.js +13 -0
- package/docs/.vitepress/dist/assets/api_vite-plugin.md.DNn9VhL5.lean.js +1 -0
- package/docs/.vitepress/dist/assets/app.BG5s3B0P.js +1 -0
- package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.DQmuWC2Z.js +1 -0
- package/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.BO-PSxt1.js +9 -0
- package/docs/.vitepress/dist/assets/chunks/framework.B7OFBR9X.js +19 -0
- package/docs/.vitepress/dist/assets/chunks/theme.DA-iSa9B.js +2 -0
- package/docs/.vitepress/dist/assets/examples_form.md.B3stGKbu.js +34 -0
- package/docs/.vitepress/dist/assets/examples_form.md.B3stGKbu.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_index.md.BDEG_D4J.js +30 -0
- package/docs/.vitepress/dist/assets/examples_index.md.BDEG_D4J.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_routing.md.bqZ9DjDK.js +338 -0
- package/docs/.vitepress/dist/assets/examples_routing.md.bqZ9DjDK.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_sfc-showcase.md.DLXaUiop.js +13 -0
- package/docs/.vitepress/dist/assets/examples_sfc-showcase.md.DLXaUiop.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_todo-app.md.D5RhZoo5.js +297 -0
- package/docs/.vitepress/dist/assets/examples_todo-app.md.D5RhZoo5.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_cdn-usage.md.CAjf03Lr.js +182 -0
- package/docs/.vitepress/dist/assets/guide_cdn-usage.md.CAjf03Lr.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_components.md.BIFWF1Hc.js +174 -0
- package/docs/.vitepress/dist/assets/guide_components.md.BIFWF1Hc.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_contributing.md.BgbUN-Mr.js +1 -0
- package/docs/.vitepress/dist/assets/guide_contributing.md.BgbUN-Mr.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_directives.md.Bi3ynu1d.js +140 -0
- package/docs/.vitepress/dist/assets/guide_directives.md.Bi3ynu1d.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_getting-started.md.2Nr1lp2z.js +107 -0
- package/docs/.vitepress/dist/assets/guide_getting-started.md.2Nr1lp2z.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_index.md.GvZq_Yf2.js +2 -0
- package/docs/.vitepress/dist/assets/guide_index.md.GvZq_Yf2.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_lifecycle.md.B28j1OzS.js +304 -0
- package/docs/.vitepress/dist/assets/guide_lifecycle.md.B28j1OzS.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_quick-start.md.CNk3VGTF.js +33 -0
- package/docs/.vitepress/dist/assets/guide_quick-start.md.CNk3VGTF.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_reactivity.md.CVsaMaPv.js +135 -0
- package/docs/.vitepress/dist/assets/guide_reactivity.md.CVsaMaPv.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_routing.md.DSpDP25o.js +193 -0
- package/docs/.vitepress/dist/assets/guide_routing.md.DSpDP25o.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_sfc.md.CVUP66tS.js +187 -0
- package/docs/.vitepress/dist/assets/guide_sfc.md.CVUP66tS.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_templating.md.BgCGe4aa.js +119 -0
- package/docs/.vitepress/dist/assets/guide_templating.md.BgCGe4aa.lean.js +1 -0
- package/docs/.vitepress/dist/assets/index.md.xV1taCED.js +23 -0
- package/docs/.vitepress/dist/assets/index.md.xV1taCED.lean.js +1 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/docs/.vitepress/dist/assets/style.eycE2Jhw.css +1 -0
- package/docs/.vitepress/dist/examples/form.html +58 -0
- package/docs/.vitepress/dist/examples/index.html +368 -0
- package/docs/.vitepress/dist/examples/routing.html +362 -0
- package/docs/.vitepress/dist/examples/sfc-showcase.html +37 -0
- package/docs/.vitepress/dist/examples/todo-app.html +321 -0
- package/docs/.vitepress/dist/guide/cdn-usage.html +206 -0
- package/docs/.vitepress/dist/guide/components.html +198 -0
- package/docs/.vitepress/dist/guide/contributing.html +25 -0
- package/docs/.vitepress/dist/guide/directives.html +164 -0
- package/docs/.vitepress/dist/guide/getting-started.html +131 -0
- package/docs/.vitepress/dist/guide/index.html +26 -0
- package/docs/.vitepress/dist/guide/lifecycle.html +328 -0
- package/docs/.vitepress/dist/guide/quick-start.html +57 -0
- package/docs/.vitepress/dist/guide/reactivity.html +159 -0
- package/docs/.vitepress/dist/guide/routing.html +217 -0
- package/docs/.vitepress/dist/guide/sfc.html +211 -0
- package/docs/.vitepress/dist/guide/templating.html +143 -0
- package/docs/.vitepress/dist/hashmap.json +1 -0
- package/docs/.vitepress/dist/index.html +47 -0
- package/docs/.vitepress/dist/logo.svg +38 -0
- package/docs/.vitepress/dist/vp-icons.css +1 -0
- package/docs/api/define.md +31 -0
- package/docs/api/directives.md +42 -0
- package/docs/api/globals.md +29 -0
- package/docs/api/index.md +29 -0
- package/docs/api/lifecycle.md +40 -0
- package/docs/api/route.md +37 -0
- package/docs/api/vite-plugin.md +58 -0
- package/docs/examples/form.md +42 -0
- package/docs/examples/index.md +104 -0
- package/docs/examples/routing.md +409 -0
- package/docs/examples/sfc-showcase.md +34 -0
- package/docs/examples/todo-app.md +383 -0
- package/docs/guide/cdn-usage.md +320 -0
- package/docs/guide/components.md +394 -0
- package/docs/guide/contributing.md +32 -0
- package/docs/guide/directives.md +430 -0
- package/docs/guide/getting-started.md +233 -0
- package/docs/guide/index.md +88 -0
- package/docs/guide/lifecycle.md +493 -0
- package/docs/guide/quick-start.md +46 -0
- package/docs/guide/reactivity.md +394 -0
- package/docs/guide/routing.md +373 -0
- package/docs/guide/sfc.md +381 -0
- package/docs/guide/templating.md +383 -0
- package/docs/index.md +126 -0
- package/docs/public/logo.svg +38 -0
- package/examples/vite-app/README.md +71 -0
- package/examples/vite-app/index.html +45 -0
- package/examples/vite-app/package.json +16 -0
- package/examples/vite-app/src/components/greeting-card.lego +41 -0
- package/examples/vite-app/src/components/sample-component.lego +75 -0
- package/examples/vite-app/src/main.js +11 -0
- package/examples/vite-app/vite.config.js +16 -0
- package/examples.js +99 -0
- package/package.json +34 -7
- package/parse-lego.js +119 -0
- package/parse-lego.test.js +107 -0
- package/vite-plugin.js +133 -0
- package/.ignore/auto.html +0 -135
- package/.ignore/test.html +0 -73
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Directives
|
|
2
|
+
|
|
3
|
+
Special attributes that control DOM behavior.
|
|
4
|
+
|
|
5
|
+
## b-if
|
|
6
|
+
|
|
7
|
+
Conditionally render an element.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<div b-if="loading">Loading...</div>
|
|
11
|
+
<div b-if="!loading">Content loaded!</div>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## b-for
|
|
15
|
+
|
|
16
|
+
Render a list of items.
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<ul>
|
|
20
|
+
<li b-for="user in users">
|
|
21
|
+
{{ user.name }}
|
|
22
|
+
</li>
|
|
23
|
+
</ul>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## b-sync
|
|
27
|
+
|
|
28
|
+
Two-way data binding for form inputs.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<input b-sync="username" placeholder="Enter username">
|
|
32
|
+
<p>You typed: {{ username }}</p>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## @event
|
|
36
|
+
|
|
37
|
+
Event listeners.
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<button @click="save()">Save</button>
|
|
41
|
+
<input @input="validate($event)">
|
|
42
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Global Helpers
|
|
2
|
+
|
|
3
|
+
LegoJS exposes a global `Lego` object when loaded via CDN, or as exports when using modules.
|
|
4
|
+
|
|
5
|
+
## Lego.page
|
|
6
|
+
|
|
7
|
+
Access to the router's current state.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
console.log(Lego.page.params); // URL parameters
|
|
11
|
+
console.log(Lego.page.query); // Query string parameters
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Lego.create()
|
|
15
|
+
|
|
16
|
+
Manually create a reactive object (stud) detached from a component.
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
const store = Lego.create({ count: 0 });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Event Bus
|
|
23
|
+
|
|
24
|
+
Simple global event bus.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
Lego.on('user-login', (user) => { ... });
|
|
28
|
+
Lego.emit('user-login', { name: 'Alice' });
|
|
29
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Welcome to the LegoJS API documentation.
|
|
4
|
+
|
|
5
|
+
## Core
|
|
6
|
+
|
|
7
|
+
- [Lego.define()](/api/define) - Defining components
|
|
8
|
+
- [Lego.route()](/api/route) - Client-side routing
|
|
9
|
+
- [Lego.globals](/api/globals) - Global state
|
|
10
|
+
- [Lifecycle Hooks](/api/lifecycle) - Component lifecycle methods
|
|
11
|
+
|
|
12
|
+
## Templates & Binding
|
|
13
|
+
|
|
14
|
+
- [Directives](/api/directives) - `b-if`, `b-for`, `b-sync`
|
|
15
|
+
|
|
16
|
+
## Browser Support
|
|
17
|
+
|
|
18
|
+
LegoJS requires:
|
|
19
|
+
- Web Components (Custom Elements v1)
|
|
20
|
+
- Shadow DOM v1
|
|
21
|
+
- ES6 Proxy
|
|
22
|
+
- Template Literals
|
|
23
|
+
- MutationObserver
|
|
24
|
+
|
|
25
|
+
Supported browsers:
|
|
26
|
+
- Chrome 63+
|
|
27
|
+
- Firefox 63+
|
|
28
|
+
- Safari 11.1+
|
|
29
|
+
- Edge 79+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Lifecycle Hooks
|
|
2
|
+
|
|
3
|
+
Methods that are automatically called during a component's lifecycle.
|
|
4
|
+
|
|
5
|
+
## init()
|
|
6
|
+
|
|
7
|
+
Called when the component is initialized and state is reactive, but before rendering.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
{
|
|
11
|
+
init() {
|
|
12
|
+
this.fetchData();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## render()
|
|
18
|
+
|
|
19
|
+
Called after the DOM has been updated.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
{
|
|
23
|
+
render() {
|
|
24
|
+
console.log('Component rendered');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## destroy()
|
|
30
|
+
|
|
31
|
+
Called when the component is removed from the DOM.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
destroy() {
|
|
36
|
+
// Cleanup timers or listeners
|
|
37
|
+
clearInterval(this.timer);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Lego.route()
|
|
2
|
+
|
|
3
|
+
Client-side routing.
|
|
4
|
+
|
|
5
|
+
## Type Signature
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
Lego.route(path: string, componentOrHtml: string | HTMLElement)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Arguments
|
|
12
|
+
|
|
13
|
+
- **path**: The URL path pattern (e.g., `/users/:id`).
|
|
14
|
+
- **componentOrHtml**: The tag name of the component to render, or raw HTML.
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
// Route to a component
|
|
20
|
+
Lego.route('/', 'home-page');
|
|
21
|
+
Lego.route('/about', 'about-page');
|
|
22
|
+
|
|
23
|
+
// Route with params
|
|
24
|
+
Lego.route('/user/:id', 'user-profile');
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Router Outlet
|
|
28
|
+
|
|
29
|
+
You must have a `<router-outlet>` in your DOM where the routed content will appear.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<nav>
|
|
33
|
+
<a href="/">Home</a>
|
|
34
|
+
<a href="/about">About</a>
|
|
35
|
+
</nav>
|
|
36
|
+
<router-outlet></router-outlet>
|
|
37
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Vite Plugin API
|
|
2
|
+
|
|
3
|
+
LegoJS includes a Vite plugin for processing `.lego` Single File Components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install vite lego-dom
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
// vite.config.js
|
|
15
|
+
import { defineConfig } from 'vite';
|
|
16
|
+
import legoPlugin from 'lego-dom/vite-plugin';
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
plugins: [
|
|
20
|
+
legoPlugin({
|
|
21
|
+
// Options
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
### `componentsDir`
|
|
30
|
+
|
|
31
|
+
- **Type**: `string`
|
|
32
|
+
- **Default**: `'src/components'`
|
|
33
|
+
|
|
34
|
+
Directory to search for `.lego` files.
|
|
35
|
+
|
|
36
|
+
### `include`
|
|
37
|
+
|
|
38
|
+
- **Type**: `string | string[]`
|
|
39
|
+
- **Default**: `'**/*.lego'`
|
|
40
|
+
|
|
41
|
+
Glob pattern(s) to match files.
|
|
42
|
+
|
|
43
|
+
### `exclude`
|
|
44
|
+
|
|
45
|
+
- **Type**: `string | string[]`
|
|
46
|
+
- **Default**: `null`
|
|
47
|
+
|
|
48
|
+
Glob pattern(s) to exclude files.
|
|
49
|
+
|
|
50
|
+
## Virtual Module
|
|
51
|
+
|
|
52
|
+
The plugin exposes a virtual module to register all components:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import registerComponents from 'virtual:lego-components';
|
|
56
|
+
|
|
57
|
+
registerComponents();
|
|
58
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Form Example
|
|
2
|
+
|
|
3
|
+
Handling forms in LegoJS.
|
|
4
|
+
|
|
5
|
+
## Live Demo
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<template b-id="login-form">
|
|
9
|
+
<form @submit.prevent="login()">
|
|
10
|
+
<div>
|
|
11
|
+
<label>Email:</label>
|
|
12
|
+
<input type="email" b-sync="email">
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div>
|
|
16
|
+
<label>Password:</label>
|
|
17
|
+
<input type="password" b-sync="password">
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<p b-if="error" style="color: red">{{ error }}</p>
|
|
21
|
+
|
|
22
|
+
<button type="submit">Login</button>
|
|
23
|
+
</form>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
Lego.define('login-form', {
|
|
28
|
+
email: '',
|
|
29
|
+
password: '',
|
|
30
|
+
error: '',
|
|
31
|
+
|
|
32
|
+
login() {
|
|
33
|
+
if (!this.email || !this.password) {
|
|
34
|
+
this.error = 'Please fill in all fields';
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
alert(`Logging in as ${this.email}`);
|
|
38
|
+
this.error = '';
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
Explore these hands-on examples to learn LegoJS patterns and best practices.
|
|
4
|
+
|
|
5
|
+
## Quick Examples
|
|
6
|
+
|
|
7
|
+
### Counter
|
|
8
|
+
|
|
9
|
+
A simple reactive counter demonstrating basic state and events.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<template b-id="click-counter">
|
|
13
|
+
<style>
|
|
14
|
+
button { font-size: 1.2rem; padding: 0.5rem 1rem; }
|
|
15
|
+
</style>
|
|
16
|
+
<p>Count: {{ count }}</p>
|
|
17
|
+
<button @click="count++">Increment</button>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<click-counter b-data="{ count: 0 }"></click-counter>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Input Binding
|
|
24
|
+
|
|
25
|
+
Two-way data binding with `b-sync`.
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<template b-id="name-input">
|
|
29
|
+
<input b-sync="name" placeholder="Enter your name">
|
|
30
|
+
<p b-if="name">Hello, {{ name }}!</p>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<name-input b-data="{ name: '' }"></name-input>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Todo List
|
|
37
|
+
|
|
38
|
+
Lists with `b-for`.
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<template b-id="todo-list">
|
|
42
|
+
<ul>
|
|
43
|
+
<li b-for="todo in todos">
|
|
44
|
+
<input type="checkbox" b-sync="todo.done">
|
|
45
|
+
<span class="{{ todo.done ? 'done' : '' }}">{{ todo.text }}</span>
|
|
46
|
+
</li>
|
|
47
|
+
</ul>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<todo-list b-data="{
|
|
51
|
+
todos: [
|
|
52
|
+
{ text: 'Learn LegoJS', done: true },
|
|
53
|
+
{ text: 'Build an app', done: false }
|
|
54
|
+
]
|
|
55
|
+
}"></todo-list>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Full Applications
|
|
59
|
+
|
|
60
|
+
### [Todo App](/examples/todo-app)
|
|
61
|
+
|
|
62
|
+
A complete todo application with:
|
|
63
|
+
- Add/remove todos
|
|
64
|
+
- Mark as complete
|
|
65
|
+
- Filter by status
|
|
66
|
+
- Local storage persistence
|
|
67
|
+
|
|
68
|
+
### [Routing Demo](/examples/routing)
|
|
69
|
+
|
|
70
|
+
Single-page application with:
|
|
71
|
+
- Multiple pages
|
|
72
|
+
- Dynamic routes
|
|
73
|
+
- Navigation
|
|
74
|
+
- Route parameters
|
|
75
|
+
|
|
76
|
+
### [SFC Showcase](/examples/sfc-showcase)
|
|
77
|
+
|
|
78
|
+
Using Single File Components:
|
|
79
|
+
- User cards
|
|
80
|
+
- Product grid
|
|
81
|
+
- Modal dialogs
|
|
82
|
+
- Form validation
|
|
83
|
+
|
|
84
|
+
### [Form Validation](/examples/form)
|
|
85
|
+
|
|
86
|
+
Advanced form handling:
|
|
87
|
+
- Input validation
|
|
88
|
+
- Error messages
|
|
89
|
+
- Submit handling
|
|
90
|
+
- Reset functionality
|
|
91
|
+
|
|
92
|
+
## CodePen Examples
|
|
93
|
+
|
|
94
|
+
Try these examples directly in your browser:
|
|
95
|
+
|
|
96
|
+
- [Simple Counter](https://codepen.io/ortserga/pen/XJKdMJm)
|
|
97
|
+
- [Todo App](https://codepen.io/ortserga/pen/todo)
|
|
98
|
+
- [Dynamic Form](https://codepen.io/ortserga/pen/form)
|
|
99
|
+
|
|
100
|
+
## Next Steps
|
|
101
|
+
|
|
102
|
+
- Check the [API Reference](/api/)
|
|
103
|
+
- Read the [Guide](/guide/)
|
|
104
|
+
- View the [source code](https://github.com/rayattack/LegoJS)
|