lego-dom 0.0.8 → 0.0.9

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.
Files changed (119) hide show
  1. package/README.md +48 -432
  2. package/docs/.vitepress/config.js +4 -4
  3. package/docs/.vitepress/dist/404.html +3 -3
  4. package/docs/.vitepress/dist/api/define.html +6 -6
  5. package/docs/.vitepress/dist/api/directives.html +6 -6
  6. package/docs/.vitepress/dist/api/globals.html +7 -7
  7. package/docs/.vitepress/dist/api/index.html +7 -7
  8. package/docs/.vitepress/dist/api/lifecycle.html +6 -6
  9. package/docs/.vitepress/dist/api/route.html +6 -6
  10. package/docs/.vitepress/dist/api/vite-plugin.html +7 -7
  11. package/docs/.vitepress/dist/assets/{api_globals.md.DOjt7AV0.js → api_globals.md.CEznyRAY.js} +1 -1
  12. package/docs/.vitepress/dist/assets/api_index.md.IEYUxUIr.js +1 -0
  13. package/docs/.vitepress/dist/assets/{api_vite-plugin.md.DNn9VhL5.js → api_vite-plugin.md.DC8Li09k.js} +1 -1
  14. package/docs/.vitepress/dist/assets/{app.BG5s3B0P.js → app.BfblNDJy.js} +1 -1
  15. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.Crdp7-Zp.js +1 -0
  16. package/docs/.vitepress/dist/assets/chunks/{VPLocalSearchBox.BO-PSxt1.js → VPLocalSearchBox.C18E44rY.js} +1 -1
  17. package/docs/.vitepress/dist/assets/chunks/{theme.DA-iSa9B.js → theme.VX3itTW6.js} +2 -2
  18. package/docs/.vitepress/dist/assets/{examples_form.md.B3stGKbu.js → examples_form.md.DQoAgbLR.js} +1 -1
  19. package/docs/.vitepress/dist/assets/{examples_index.md.BDEG_D4J.js → examples_index.md.CVJJjXXE.js} +3 -5
  20. package/docs/.vitepress/dist/assets/{examples_routing.md.bqZ9DjDK.js → examples_routing.md.sRnA5RXw.js} +4 -4
  21. package/docs/.vitepress/dist/assets/{examples_sfc-showcase.md.DLXaUiop.js → examples_sfc-showcase.md.DPf9Wm99.js} +4 -4
  22. package/docs/.vitepress/dist/assets/{examples_todo-app.md.D5RhZoo5.js → examples_todo-app.md.CqF4JaWn.js} +2 -2
  23. package/docs/.vitepress/dist/assets/{guide_cdn-usage.md.CAjf03Lr.js → guide_cdn-usage.md.CjIjusre.js} +8 -8
  24. package/docs/.vitepress/dist/assets/{guide_components.md.BIFWF1Hc.js → guide_components.md.CMU3iM6R.js} +1 -1
  25. package/docs/.vitepress/dist/assets/guide_contributing.md.Crrv3T_0.js +1 -0
  26. package/docs/.vitepress/dist/assets/{guide_directives.md.Bi3ynu1d.js → guide_directives.md.DFwqvqOv.js} +1 -1
  27. package/docs/.vitepress/dist/assets/{guide_getting-started.md.2Nr1lp2z.js → guide_getting-started.md.DtaJPe0i.js} +5 -5
  28. package/docs/.vitepress/dist/assets/guide_index.md.DtJVpLI9.js +2 -0
  29. package/docs/.vitepress/dist/assets/guide_index.md.DtJVpLI9.lean.js +1 -0
  30. package/docs/.vitepress/dist/assets/{guide_lifecycle.md.B28j1OzS.js → guide_lifecycle.md.CfY3jlU1.js} +1 -1
  31. package/docs/.vitepress/dist/assets/{guide_quick-start.md.CNk3VGTF.js → guide_quick-start.md.CwdNNA21.js} +4 -4
  32. package/docs/.vitepress/dist/assets/{guide_reactivity.md.CVsaMaPv.js → guide_reactivity.md.DgTH0MTn.js} +8 -8
  33. package/docs/.vitepress/dist/assets/{guide_routing.md.DSpDP25o.js → guide_routing.md.nMB0QOBR.js} +3 -3
  34. package/docs/.vitepress/dist/assets/{guide_sfc.md.CVUP66tS.js → guide_sfc.md.BUkWma1z.js} +39 -39
  35. package/docs/.vitepress/dist/assets/{guide_templating.md.BgCGe4aa.js → guide_templating.md.XI3uUlYI.js} +2 -2
  36. package/docs/.vitepress/dist/assets/guide_templating.md.XI3uUlYI.lean.js +1 -0
  37. package/docs/.vitepress/dist/assets/{index.md.xV1taCED.js → index.md.M4_o26kF.js} +2 -2
  38. package/docs/.vitepress/dist/assets/index.md.M4_o26kF.lean.js +1 -0
  39. package/docs/.vitepress/dist/examples/form.html +7 -7
  40. package/docs/.vitepress/dist/examples/index.html +26 -342
  41. package/docs/.vitepress/dist/examples/routing.html +11 -11
  42. package/docs/.vitepress/dist/examples/sfc-showcase.html +11 -11
  43. package/docs/.vitepress/dist/examples/todo-app.html +8 -8
  44. package/docs/.vitepress/dist/guide/cdn-usage.html +14 -14
  45. package/docs/.vitepress/dist/guide/components.html +7 -7
  46. package/docs/.vitepress/dist/guide/contributing.html +7 -7
  47. package/docs/.vitepress/dist/guide/directives.html +8 -8
  48. package/docs/.vitepress/dist/guide/getting-started.html +11 -11
  49. package/docs/.vitepress/dist/guide/index.html +8 -8
  50. package/docs/.vitepress/dist/guide/lifecycle.html +7 -7
  51. package/docs/.vitepress/dist/guide/quick-start.html +10 -10
  52. package/docs/.vitepress/dist/guide/reactivity.html +14 -14
  53. package/docs/.vitepress/dist/guide/routing.html +9 -9
  54. package/docs/.vitepress/dist/guide/sfc.html +46 -46
  55. package/docs/.vitepress/dist/guide/templating.html +8 -8
  56. package/docs/.vitepress/dist/hashmap.json +1 -1
  57. package/docs/.vitepress/dist/index.html +8 -8
  58. package/docs/.vitepress/dist/logo.svg +1 -1
  59. package/docs/api/globals.md +1 -1
  60. package/docs/api/index.md +2 -2
  61. package/docs/api/vite-plugin.md +1 -1
  62. package/docs/examples/form.md +1 -1
  63. package/docs/examples/index.md +3 -3
  64. package/docs/examples/routing.md +4 -4
  65. package/docs/examples/sfc-showcase.md +4 -4
  66. package/docs/examples/todo-app.md +2 -2
  67. package/docs/guide/cdn-usage.md +8 -8
  68. package/docs/guide/components.md +1 -1
  69. package/docs/guide/contributing.md +2 -2
  70. package/docs/guide/directives.md +1 -1
  71. package/docs/guide/getting-started.md +6 -6
  72. package/docs/guide/index.md +9 -9
  73. package/docs/guide/lifecycle.md +1 -1
  74. package/docs/guide/quick-start.md +4 -4
  75. package/docs/guide/reactivity.md +8 -8
  76. package/docs/guide/routing.md +3 -3
  77. package/docs/guide/sfc.md +39 -39
  78. package/docs/guide/templating.md +2 -2
  79. package/docs/index.md +10 -10
  80. package/docs/public/logo.svg +17 -38
  81. package/examples/vite-app/README.md +2 -2
  82. package/examples/vite-app/index.html +8 -4
  83. package/examples/vite-app/src/components/greeting-card.lego +25 -25
  84. package/examples/vite-app/src/components/sample-component.lego +44 -44
  85. package/examples/vite-app/src/components/todo-list.lego +242 -0
  86. package/examples/vite-app/src/main.js +3 -3
  87. package/examples/vite-app/vite.config.js +2 -1
  88. package/examples.js +3 -3
  89. package/go.html +117 -0
  90. package/lego.js +2 -0
  91. package/main.js +41 -35
  92. package/package.json +8 -3
  93. package/parse-lego.test.js +1 -1
  94. package/vite-plugin.js +2 -2
  95. package/docs/.vitepress/dist/assets/api_index.md.OS6h01ct.js +0 -1
  96. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.DQmuWC2Z.js +0 -1
  97. package/docs/.vitepress/dist/assets/guide_contributing.md.BgbUN-Mr.js +0 -1
  98. package/docs/.vitepress/dist/assets/guide_index.md.GvZq_Yf2.js +0 -2
  99. package/docs/.vitepress/dist/assets/guide_index.md.GvZq_Yf2.lean.js +0 -1
  100. package/docs/.vitepress/dist/assets/guide_templating.md.BgCGe4aa.lean.js +0 -1
  101. package/docs/.vitepress/dist/assets/index.md.xV1taCED.lean.js +0 -1
  102. /package/docs/.vitepress/dist/assets/{api_globals.md.DOjt7AV0.lean.js → api_globals.md.CEznyRAY.lean.js} +0 -0
  103. /package/docs/.vitepress/dist/assets/{api_index.md.OS6h01ct.lean.js → api_index.md.IEYUxUIr.lean.js} +0 -0
  104. /package/docs/.vitepress/dist/assets/{api_vite-plugin.md.DNn9VhL5.lean.js → api_vite-plugin.md.DC8Li09k.lean.js} +0 -0
  105. /package/docs/.vitepress/dist/assets/{examples_form.md.B3stGKbu.lean.js → examples_form.md.DQoAgbLR.lean.js} +0 -0
  106. /package/docs/.vitepress/dist/assets/{examples_index.md.BDEG_D4J.lean.js → examples_index.md.CVJJjXXE.lean.js} +0 -0
  107. /package/docs/.vitepress/dist/assets/{examples_routing.md.bqZ9DjDK.lean.js → examples_routing.md.sRnA5RXw.lean.js} +0 -0
  108. /package/docs/.vitepress/dist/assets/{examples_sfc-showcase.md.DLXaUiop.lean.js → examples_sfc-showcase.md.DPf9Wm99.lean.js} +0 -0
  109. /package/docs/.vitepress/dist/assets/{examples_todo-app.md.D5RhZoo5.lean.js → examples_todo-app.md.CqF4JaWn.lean.js} +0 -0
  110. /package/docs/.vitepress/dist/assets/{guide_cdn-usage.md.CAjf03Lr.lean.js → guide_cdn-usage.md.CjIjusre.lean.js} +0 -0
  111. /package/docs/.vitepress/dist/assets/{guide_components.md.BIFWF1Hc.lean.js → guide_components.md.CMU3iM6R.lean.js} +0 -0
  112. /package/docs/.vitepress/dist/assets/{guide_contributing.md.BgbUN-Mr.lean.js → guide_contributing.md.Crrv3T_0.lean.js} +0 -0
  113. /package/docs/.vitepress/dist/assets/{guide_directives.md.Bi3ynu1d.lean.js → guide_directives.md.DFwqvqOv.lean.js} +0 -0
  114. /package/docs/.vitepress/dist/assets/{guide_getting-started.md.2Nr1lp2z.lean.js → guide_getting-started.md.DtaJPe0i.lean.js} +0 -0
  115. /package/docs/.vitepress/dist/assets/{guide_lifecycle.md.B28j1OzS.lean.js → guide_lifecycle.md.CfY3jlU1.lean.js} +0 -0
  116. /package/docs/.vitepress/dist/assets/{guide_quick-start.md.CNk3VGTF.lean.js → guide_quick-start.md.CwdNNA21.lean.js} +0 -0
  117. /package/docs/.vitepress/dist/assets/{guide_reactivity.md.CVsaMaPv.lean.js → guide_reactivity.md.DgTH0MTn.lean.js} +0 -0
  118. /package/docs/.vitepress/dist/assets/{guide_routing.md.DSpDP25o.lean.js → guide_routing.md.nMB0QOBR.lean.js} +0 -0
  119. /package/docs/.vitepress/dist/assets/{guide_sfc.md.CVUP66tS.lean.js → guide_sfc.md.BUkWma1z.lean.js} +0 -0
package/README.md CHANGED
@@ -1,466 +1,82 @@
1
- # LegoJS
1
+ # Lego 🧱
2
2
 
3
- LegoJS is a tiny, zero-dependency JavaScript library for building reactive Web Components directly in the browser.
3
+ **The tiny, zero-dependency library for building reactive Web Components.**
4
4
 
5
- The goal of LegoJS is **mental model simplicity**:
5
+ Lego embraces the web platform. It turns standard HTML `<template>` tags into reactive, encapsulated custom elements with zero build steps required.
6
6
 
7
- * No virtual DOM
8
- * No compilation step required
9
- * No JSX
10
- * No framework-specific syntax to learn
11
-
12
- You write **HTML**, add a few **directives**, and LegoJS takes care of reactivity and updates.
13
-
14
- This README is intentionally designed so that a developer can understand **everything they need** about LegoJS by reading this file alone.
15
-
16
- ---
17
-
18
- ## Installation
19
-
20
- The package name on npm is **`lego-dom`** (the name `legojs` was already taken).
21
-
22
- ```bash
23
- npm install lego-dom
24
- ```
25
-
26
- Or include it directly in the browser:
27
-
28
- ```html
29
- <script src="node_modules/lego-dom/main.js"></script>
30
- ```
31
-
32
- Once loaded, `Lego` is available globally.
33
-
34
- ---
35
-
36
- ## The Mental Model
37
-
38
- Think of LegoJS like real Lego blocks:
39
-
40
- * **Templates** define how a block looks
41
- * **Studs** define the data attached to a block
42
- * **Directives** snap data to the DOM
43
- * **Changes to data automatically update the DOM**
44
-
45
- There is no mounting, diffing, or reconciliation engine.
46
-
47
- You change JavaScript objects → LegoJS updates the DOM.
48
-
49
- ---
50
-
51
- ## Defining a Component (Block)
52
-
53
- A component is defined using a standard HTML `<template>` with a `b-id`.
54
-
55
- ```html
56
- <template b-id="hello-card">
57
- <style>
58
- self {
59
- display: block;
60
- padding: 1rem;
61
- border: 1px solid #ccc;
62
- }
63
- </style>
64
-
65
- <h2>Hello {{ name }}</h2>
66
- <button @click="count++">Clicked {{ count }} times</button>
67
- </template>
68
- ```
69
-
70
- Use the component in HTML:
71
-
72
- ```html
73
- <hello-card b-data="{ name: 'Ahmed', count: 0 }"></hello-card>
74
- ```
75
-
76
- ---
77
-
78
- ## Reactive State (`studs`)
79
-
80
- Each component has a reactive state object internally called **studs**.
81
-
82
- * Defined via `b-data` or component logic
83
- * Implemented using JavaScript `Proxy`
84
- * Any mutation automatically schedules a re-render
85
-
86
- ```html
87
- <button @click="count++"></button>
88
- ```
89
-
90
- No setters. No actions. No reducers.
91
-
92
- Just mutate data.
93
-
94
- ---
95
-
96
- ## Templating (`{{ }}`)
97
-
98
- Text interpolation works in:
99
-
100
- * Text nodes
101
- * Attributes
102
- * Class names
103
-
104
- ```html
105
- <p>Hello {{ user.name }}</p>
106
- <img src="/avatars/{{ user.id }}.png">
107
- ```
108
-
109
- Expressions are plain JavaScript.
110
-
111
- ---
112
-
113
- ## Event Handling (`@event`)
114
-
115
- Use `@` followed by any DOM event.
116
-
117
- ```html
118
- <button @click="submit()">Submit</button>
119
- ```
120
-
121
- The expression runs in the component’s state scope.
122
-
123
- You also have access to:
124
-
125
- * `event` – the native DOM event
126
- * `$emit(name, detail)` – dispatch custom events
127
- * `$element` – the host custom element
128
-
129
- ---
130
-
131
- ## Conditional Rendering (`b-if`)
132
-
133
- ```html
134
- <p b-if="isLoggedIn">Welcome back</p>
135
- ```
136
-
137
- When the expression is falsy, the element is hidden via `display: none`.
138
-
139
- ---
140
-
141
- ## Lists (`b-for`)
142
-
143
- Render lists using `b-for`:
144
-
145
- ```html
146
- <ul>
147
- <li b-for="todo in todos">
148
- <input type="checkbox" b-sync="todo.done">
149
- <span class="{{ todo.done ? 'done' : '' }}">{{ todo.text }}</span>
150
- </li>
151
- </ul>
152
- ```
153
-
154
- * DOM nodes are reused
155
- * Items are tracked internally
156
- * Updates are efficient without a virtual DOM
157
-
158
- ---
159
-
160
- ## Two-Way Binding (`b-sync`)
161
-
162
- `b-sync` keeps inputs and state in sync.
163
-
164
- ```html
165
- <input b-sync="username">
166
- <input type="checkbox" b-sync="settings.enabled">
167
- ```
168
-
169
- Works with:
170
-
171
- * text inputs
172
- * checkboxes
173
- * nested objects
174
- * items inside `b-for`
175
-
176
- ---
177
-
178
- ## Styling and Shadow DOM
179
-
180
- Every component uses **Shadow DOM** automatically.
181
-
182
- Inside `<style>` blocks:
183
-
184
- * Use `self` to target the component root
185
- * `self` is converted to `:host`
186
-
187
- ```css
188
- self {
189
- display: block;
190
- }
191
- ```
192
-
193
- Styles never leak in or out.
194
-
195
- ---
196
-
197
- ## Lifecycle Hooks
198
-
199
- Define lifecycle methods directly on the component state:
200
-
201
- ```js
202
- {
203
- mounted() {
204
- console.log('Component attached');
205
- },
206
- updated() {
207
- console.log('State changed');
208
- },
209
- unmounted() {
210
- console.log('Component removed');
211
- }
212
- }
213
- ```
7
+ [**Explore the Docs**](https://rayattack.github.io/legodom/) | [**Examples**](https://rayattack.github.io/legodom/examples/) | [**GitHub**](https://github.com/rayattack/legodom)
214
8
 
215
9
  ---
216
10
 
217
- ## Custom Events (`$emit`)
218
-
219
- Child components communicate upward using events.
11
+ ## Why Lego?
220
12
 
221
- ```html
222
- <button @click="$emit('save', data)">Save</button>
223
- ```
224
-
225
- Events:
226
-
227
- * bubble
228
- * cross Shadow DOM boundaries
229
- * are standard `CustomEvent`s
13
+ - ⚡ **Extremely Fast** – No virtual DOM. No reconciliation. Direct DOM updates.
14
+ - 📦 **Zero Dependencies** – Weighs less than 4kb gzipped.
15
+ - 🛠️ **No Build Step** – Works directly in the browser with standard `<script>` tags.
16
+ - 🧩 **Native Web Components** – Real Custom Elements, real Shadow DOM.
17
+ - 📝 **Familiar Mentals** – Plain JavaScript objects for state, plain HTML for templates.
230
18
 
231
19
  ---
232
20
 
233
- ## Accessing Ancestors (`$ancestors`)
234
-
235
- Read state from the nearest ancestor component:
236
-
237
- ```html
238
- <p>{{ $ancestors('app-shell').user.name }}</p>
239
- ```
240
-
241
- This is intended for **reading**, not mutation.
242
-
243
- ---
244
-
245
- ## Shared State (`$registry`)
246
-
247
- Components defined via `Lego.define` get a shared singleton state.
248
-
249
- ```js
250
- $registry('settings').theme
251
- ```
252
-
253
- Useful for global configuration or app-wide state.
254
-
255
- ---
256
-
257
- ## Router
258
-
259
- LegoJS includes a minimal client-side router.
260
-
261
- Add a router outlet:
262
-
263
- ```html
264
- <lego-router></lego-router>
265
- ```
266
-
267
- Define routes:
268
-
269
- ```js
270
- Lego.route('/', 'home-page');
271
- Lego.route('/user/:id', 'user-page');
272
- ```
273
-
274
- Access route params:
21
+ ## Quick Start (No Build Required)
275
22
 
276
23
  ```html
277
- <p>User ID: {{ global.params.id }}</p>
278
- ```
24
+ <!DOCTYPE html>
25
+ <html>
26
+ <body>
27
+ <hello-world></hello-world>
279
28
 
280
- Navigation:
29
+ <template b-id="hello-world">
30
+ <style>
31
+ h1 { color: #ffca28; font-family: sans-serif; }
32
+ </style>
33
+ <h1>Hello, {{ name }}!</h1>
34
+ <button @click="toggle()">Toggle Name</button>
35
+ </template>
281
36
 
282
- ```html
283
- <a href="/dashboard" b-link>Dashboard</a>
37
+ <script src="https://unpkg.com/lego-dom/main.js"></script>
38
+ <script>
39
+ document.querySelector('hello-world').state = {
40
+ name: 'World',
41
+ toggle() {
42
+ this.name = this.name === 'World' ? 'Lego' : 'World';
43
+ }
44
+ };
45
+ </script>
46
+ </body>
47
+ </html>
284
48
  ```
285
49
 
286
50
  ---
287
51
 
288
- ## Programmatic Navigation
289
-
290
- ```js
291
- history.pushState({}, '', '/success');
292
- window.dispatchEvent(new PopStateEvent('popstate'));
293
- ```
294
-
295
- ---
296
-
297
- ## Defining Components in JavaScript
298
-
299
- You can also define components programmatically:
300
-
301
- ```js
302
- Lego.define(
303
- 'counter-box',
304
- `
305
- <style>self { display:block }</style>
306
- <button @click="count++">{{ count }}</button>
307
- `,
308
- { count: 0 }
309
- );
310
- ```
311
-
312
- ---
313
-
314
- ## Initialization
315
-
316
- LegoJS initializes automatically on `DOMContentLoaded`.
317
-
318
- You usually do **not** need to call anything manually.
319
-
320
- ---
321
-
322
- ## Design Philosophy
323
-
324
- LegoJS is intentionally small and opinionated:
325
-
326
- * The DOM is the source of truth
327
- * JavaScript objects are the state
328
- * HTML stays HTML
329
- * Complexity is avoided unless absolutely necessary
330
-
331
- If you can explain your UI with plain objects and markup, LegoJS will feel natural.
332
-
333
- ---
334
-
335
- ## Single File Components (SFC)
52
+ ## Also Supports Modern Toolchains
336
53
 
337
- LegoJS supports **Single File Components** using `.lego` files when using a build tool like Vite.
338
-
339
- ### .lego File Format
340
-
341
- A `.lego` file contains three optional sections:
54
+ Lego includes a **Vite plugin** for developers who prefer **Single File Components (.lego)**:
342
55
 
343
56
  ```html
57
+ <!-- user-card.lego -->
344
58
  <template>
345
- <!-- Your HTML markup with directives -->
346
- <h1>{{ title }}</h1>
347
- <button @click="count++">{{ count }}</button>
59
+ <h1>{{ name }}</h1>
348
60
  </template>
349
61
 
350
- <script>
351
- export default {
352
- // Your component logic/state
353
- title: 'Hello',
354
- count: 0
355
- }
356
- </script>
357
-
358
62
  <style>
359
- /* Scoped CSS using self keyword */
360
- self {
361
- display: block;
362
- padding: 1rem;
363
- }
63
+ self { display: block; padding: 20px; }
364
64
  </style>
365
- ```
366
-
367
- The component name is automatically derived from the filename (e.g., `sample-component.lego` → `<sample-component>`).
368
-
369
- ---
370
-
371
- ## Vite Plugin Setup
372
-
373
- ### Installation
374
-
375
- ```bash
376
- npm install lego-dom vite
377
- ```
378
-
379
- ### Configuration
380
-
381
- Create `vite.config.js`:
382
-
383
- ```js
384
- import { defineConfig } from 'vite';
385
- import legoPlugin from 'lego-dom/vite-plugin';
386
-
387
- export default defineConfig({
388
- plugins: [
389
- legoPlugin({
390
- componentsDir: './src/components', // Where to look for .lego files
391
- include: ['**/*.lego'] // Glob patterns to match
392
- })
393
- ]
394
- });
395
- ```
396
-
397
- ### Usage
398
-
399
- Create your components in `.lego` files:
400
-
401
- ```
402
- src/
403
- components/
404
- my-button.lego
405
- user-card.lego
406
- main.js
407
- index.html
408
- ```
409
-
410
- In your `main.js`:
411
-
412
- ```js
413
- import { Lego } from 'lego-dom/main.js';
414
- import registerComponents from 'virtual:lego-components';
415
-
416
- registerComponents();
417
- ```
418
-
419
- In your HTML:
420
65
 
421
- ```html
422
- <my-button></my-button>
423
- <user-card></user-card>
66
+ <script>
67
+ export default { name: 'John Doe' }
68
+ </script>
424
69
  ```
425
70
 
426
- **Auto-discovery**: The Vite plugin automatically finds all `.lego` files and registers them with LegoJS!
427
-
428
71
  ---
429
72
 
430
- ## Two Usage Modes
431
-
432
- LegoJS works in **two modes**:
433
-
434
- ### 1. Without Build Tooling
435
-
436
- Include `main.js` directly and use `<template b-id>` or `Lego.define()`:
437
-
438
- ```html
439
- <script src="node_modules/lego-dom/main.js"></script>
440
- <template b-id="my-component">
441
- <h1>Hello</h1>
442
- </template>
443
- ```
444
-
445
- ### 2. With Vite (SFC)
446
-
447
- Use `.lego` files that are auto-discovered and compiled:
448
-
449
- ```bash
450
- npm run dev
451
- ```
452
-
453
- Both modes use the same LegoJS runtime and support all the same features!
454
-
455
- ---
73
+ ## 🔗 Links
456
74
 
457
- ## Summary
75
+ - 📖 [Full Documentation](https://rayattack.github.io/legodom/)
76
+ - 🚀 [Quick Start Guide](https://rayattack.github.io/legodom/guide/quick-start)
77
+ - 🔌 [Vite Plugin Setup](https://rayattack.github.io/legodom/api/vite-plugin)
78
+ - 🧪 [Example Showcase](https://rayattack.github.io/legodom/examples/)
458
79
 
459
- * Install with `npm install lego-dom`
460
- * Define components with `<template b-id>`
461
- * Use `b-data` for state
462
- * Use `{{ }}` for binding
463
- * Use `@event` for logic
464
- * Use `b-if`, `b-for`, and `b-sync` for structure
80
+ ## License
465
81
 
466
- That’s it.
82
+ MIT © [Tersoo Ortserga](https://github.com/rayattack)
@@ -1,9 +1,9 @@
1
1
  import { defineConfig } from 'vitepress';
2
2
 
3
3
  export default defineConfig({
4
- title: 'LegoJS',
5
- description: 'A tiny, zero-dependency JavaScript library for building reactive Web Components',
6
- base: '/LegoJS/',
4
+ title: 'Lego',
5
+ description: 'A feature-rich web components + SFC frontend framework',
6
+ base: '/legodom/',
7
7
 
8
8
  themeConfig: {
9
9
  logo: '/logo.svg',
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
  {
27
27
  text: 'Introduction',
28
28
  items: [
29
- { text: 'What is LegoJS?', link: '/guide/' },
29
+ { text: 'What is Lego?', link: '/guide/' },
30
30
  { text: 'Getting Started', link: '/guide/getting-started' },
31
31
  { text: 'Quick Start', link: '/guide/quick-start' },
32
32
  { text: 'Contributing', link: '/guide/contributing' }
@@ -3,20 +3,20 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <title>404 | LegoJS</title>
6
+ <title>404 | Lego</title>
7
7
  <meta name="description" content="Not Found">
8
8
  <meta name="generator" content="VitePress v1.6.4">
9
9
  <link rel="preload stylesheet" href="/LegoJS/assets/style.eycE2Jhw.css" as="style">
10
10
  <link rel="preload stylesheet" href="/LegoJS/vp-icons.css" as="style">
11
11
 
12
- <script type="module" src="/LegoJS/assets/app.BG5s3B0P.js"></script>
12
+ <script type="module" src="/LegoJS/assets/app.BfblNDJy.js"></script>
13
13
  <link rel="preload" href="/LegoJS/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
14
14
  <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
15
15
  <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
16
16
  </head>
17
17
  <body>
18
18
  <div id="app"></div>
19
- <script>window.__VP_HASH_MAP__=JSON.parse("{\"api_define.md\":\"UA-ygUnQ\",\"api_directives.md\":\"BV-D251p\",\"api_globals.md\":\"DOjt7AV0\",\"api_index.md\":\"OS6h01ct\",\"api_lifecycle.md\":\"Ccm5xw6-\",\"api_route.md\":\"CAHf_KNp\",\"api_vite-plugin.md\":\"DNn9VhL5\",\"examples_form.md\":\"B3stGKbu\",\"examples_index.md\":\"BDEG_D4J\",\"examples_routing.md\":\"bqZ9DjDK\",\"examples_sfc-showcase.md\":\"DLXaUiop\",\"examples_todo-app.md\":\"D5RhZoo5\",\"guide_cdn-usage.md\":\"CAjf03Lr\",\"guide_components.md\":\"BIFWF1Hc\",\"guide_contributing.md\":\"BgbUN-Mr\",\"guide_directives.md\":\"Bi3ynu1d\",\"guide_getting-started.md\":\"2Nr1lp2z\",\"guide_index.md\":\"GvZq_Yf2\",\"guide_lifecycle.md\":\"B28j1OzS\",\"guide_quick-start.md\":\"CNk3VGTF\",\"guide_reactivity.md\":\"CVsaMaPv\",\"guide_routing.md\":\"DSpDP25o\",\"guide_sfc.md\":\"CVUP66tS\",\"guide_templating.md\":\"BgCGe4aa\",\"index.md\":\"xV1taCED\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"LegoJS\",\"description\":\"A tiny, zero-dependency JavaScript library for building reactive Web Components\",\"base\":\"/LegoJS/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"/logo.svg\",\"nav\":[{\"text\":\"Guide\",\"link\":\"/guide/\"},{\"text\":\"API\",\"link\":\"/api/\"},{\"text\":\"Examples\",\"link\":\"/examples/\"},{\"text\":\"v0.0.7\",\"items\":[{\"text\":\"Changelog\",\"link\":\"https://github.com/rayattack/LegoJS/releases\"}]}],\"sidebar\":{\"/guide/\":[{\"text\":\"Introduction\",\"items\":[{\"text\":\"What is LegoJS?\",\"link\":\"/guide/\"},{\"text\":\"Getting Started\",\"link\":\"/guide/getting-started\"},{\"text\":\"Quick Start\",\"link\":\"/guide/quick-start\"},{\"text\":\"Contributing\",\"link\":\"/guide/contributing\"}]},{\"text\":\"Core Concepts\",\"items\":[{\"text\":\"Components\",\"link\":\"/guide/components\"},{\"text\":\"Templating\",\"link\":\"/guide/templating\"},{\"text\":\"Reactivity\",\"link\":\"/guide/reactivity\"},{\"text\":\"Directives\",\"link\":\"/guide/directives\"}]},{\"text\":\"Advanced\",\"items\":[{\"text\":\"Single File Components\",\"link\":\"/guide/sfc\"},{\"text\":\"Routing\",\"link\":\"/guide/routing\"},{\"text\":\"CDN Usage\",\"link\":\"/guide/cdn-usage\"},{\"text\":\"Lifecycle Hooks\",\"link\":\"/guide/lifecycle\"}]}],\"/api/\":[{\"text\":\"API Reference\",\"items\":[{\"text\":\"Overview\",\"link\":\"/api/\"},{\"text\":\"Lego.define()\",\"link\":\"/api/define\"},{\"text\":\"Lego.route()\",\"link\":\"/api/route\"},{\"text\":\"Lego.globals\",\"link\":\"/api/globals\"},{\"text\":\"Directives\",\"link\":\"/api/directives\"},{\"text\":\"Directives\",\"link\":\"/api/directives\"},{\"text\":\"Lifecycle Hooks\",\"link\":\"/api/lifecycle\"},{\"text\":\"Vite Plugin\",\"link\":\"/api/vite-plugin\"}]}],\"/examples/\":[{\"text\":\"Examples\",\"items\":[{\"text\":\"Overview\",\"link\":\"/examples/\"},{\"text\":\"Todo App\",\"link\":\"/examples/todo-app\"},{\"text\":\"Routing Demo\",\"link\":\"/examples/routing\"},{\"text\":\"SFC Showcase\",\"link\":\"/examples/sfc-showcase\"},{\"text\":\"Form Validation\",\"link\":\"/examples/form\"}]}]},\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/rayattack/LegoJS\"}],\"footer\":{\"message\":\"Released under the MIT License.\",\"copyright\":\"Copyright © 2024-present\"},\"search\":{\"provider\":\"local\"},\"editLink\":{\"pattern\":\"https://github.com/rayattack/LegoJS/edit/main/docs/:path\",\"text\":\"Edit this page on GitHub\"}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
19
+ <script>window.__VP_HASH_MAP__=JSON.parse("{\"api_define.md\":\"UA-ygUnQ\",\"api_directives.md\":\"BV-D251p\",\"api_globals.md\":\"CEznyRAY\",\"api_index.md\":\"IEYUxUIr\",\"api_lifecycle.md\":\"Ccm5xw6-\",\"api_route.md\":\"CAHf_KNp\",\"api_vite-plugin.md\":\"DC8Li09k\",\"examples_form.md\":\"DQoAgbLR\",\"examples_index.md\":\"CVJJjXXE\",\"examples_routing.md\":\"sRnA5RXw\",\"examples_sfc-showcase.md\":\"DPf9Wm99\",\"examples_todo-app.md\":\"CqF4JaWn\",\"guide_cdn-usage.md\":\"CjIjusre\",\"guide_components.md\":\"CMU3iM6R\",\"guide_contributing.md\":\"Crrv3T_0\",\"guide_directives.md\":\"DFwqvqOv\",\"guide_getting-started.md\":\"DtaJPe0i\",\"guide_index.md\":\"DtJVpLI9\",\"guide_lifecycle.md\":\"CfY3jlU1\",\"guide_quick-start.md\":\"CwdNNA21\",\"guide_reactivity.md\":\"DgTH0MTn\",\"guide_routing.md\":\"nMB0QOBR\",\"guide_sfc.md\":\"BUkWma1z\",\"guide_templating.md\":\"XI3uUlYI\",\"index.md\":\"M4_o26kF\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"Lego\",\"description\":\"A feature-rich web components + SFC frontend framework\",\"base\":\"/LegoJS/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"/logo.svg\",\"nav\":[{\"text\":\"Guide\",\"link\":\"/guide/\"},{\"text\":\"API\",\"link\":\"/api/\"},{\"text\":\"Examples\",\"link\":\"/examples/\"},{\"text\":\"v0.0.7\",\"items\":[{\"text\":\"Changelog\",\"link\":\"https://github.com/rayattack/LegoJS/releases\"}]}],\"sidebar\":{\"/guide/\":[{\"text\":\"Introduction\",\"items\":[{\"text\":\"What is Lego?\",\"link\":\"/guide/\"},{\"text\":\"Getting Started\",\"link\":\"/guide/getting-started\"},{\"text\":\"Quick Start\",\"link\":\"/guide/quick-start\"},{\"text\":\"Contributing\",\"link\":\"/guide/contributing\"}]},{\"text\":\"Core Concepts\",\"items\":[{\"text\":\"Components\",\"link\":\"/guide/components\"},{\"text\":\"Templating\",\"link\":\"/guide/templating\"},{\"text\":\"Reactivity\",\"link\":\"/guide/reactivity\"},{\"text\":\"Directives\",\"link\":\"/guide/directives\"}]},{\"text\":\"Advanced\",\"items\":[{\"text\":\"Single File Components\",\"link\":\"/guide/sfc\"},{\"text\":\"Routing\",\"link\":\"/guide/routing\"},{\"text\":\"CDN Usage\",\"link\":\"/guide/cdn-usage\"},{\"text\":\"Lifecycle Hooks\",\"link\":\"/guide/lifecycle\"}]}],\"/api/\":[{\"text\":\"API Reference\",\"items\":[{\"text\":\"Overview\",\"link\":\"/api/\"},{\"text\":\"Lego.define()\",\"link\":\"/api/define\"},{\"text\":\"Lego.route()\",\"link\":\"/api/route\"},{\"text\":\"Lego.globals\",\"link\":\"/api/globals\"},{\"text\":\"Directives\",\"link\":\"/api/directives\"},{\"text\":\"Lifecycle Hooks\",\"link\":\"/api/lifecycle\"},{\"text\":\"Vite Plugin\",\"link\":\"/api/vite-plugin\"}]}],\"/examples/\":[{\"text\":\"Examples\",\"items\":[{\"text\":\"Overview\",\"link\":\"/examples/\"},{\"text\":\"Todo App\",\"link\":\"/examples/todo-app\"},{\"text\":\"Routing Demo\",\"link\":\"/examples/routing\"},{\"text\":\"SFC Showcase\",\"link\":\"/examples/sfc-showcase\"},{\"text\":\"Form Validation\",\"link\":\"/examples/form\"}]}]},\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/rayattack/LegoJS\"}],\"footer\":{\"message\":\"Released under the MIT License.\",\"copyright\":\"Copyright © 2024-present\"},\"search\":{\"provider\":\"local\"},\"editLink\":{\"pattern\":\"https://github.com/rayattack/LegoJS/edit/main/docs/:path\",\"text\":\"Edit this page on GitHub\"}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
20
20
 
21
21
  </body>
22
22
  </html>