lego-dom 0.0.7 → 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 (147) hide show
  1. package/.github/workflows/deploy-docs.yml +56 -0
  2. package/LICENSE +21 -0
  3. package/README.md +52 -314
  4. package/docs/.vitepress/config.js +107 -0
  5. package/docs/.vitepress/dist/404.html +22 -0
  6. package/docs/.vitepress/dist/api/define.html +35 -0
  7. package/docs/.vitepress/dist/api/directives.html +32 -0
  8. package/docs/.vitepress/dist/api/globals.html +27 -0
  9. package/docs/.vitepress/dist/api/index.html +25 -0
  10. package/docs/.vitepress/dist/api/lifecycle.html +38 -0
  11. package/docs/.vitepress/dist/api/route.html +34 -0
  12. package/docs/.vitepress/dist/api/vite-plugin.html +37 -0
  13. package/docs/.vitepress/dist/assets/api_define.md.UA-ygUnQ.js +11 -0
  14. package/docs/.vitepress/dist/assets/api_define.md.UA-ygUnQ.lean.js +1 -0
  15. package/docs/.vitepress/dist/assets/api_directives.md.BV-D251p.js +8 -0
  16. package/docs/.vitepress/dist/assets/api_directives.md.BV-D251p.lean.js +1 -0
  17. package/docs/.vitepress/dist/assets/api_globals.md.CEznyRAY.js +3 -0
  18. package/docs/.vitepress/dist/assets/api_globals.md.CEznyRAY.lean.js +1 -0
  19. package/docs/.vitepress/dist/assets/api_index.md.IEYUxUIr.js +1 -0
  20. package/docs/.vitepress/dist/assets/api_index.md.IEYUxUIr.lean.js +1 -0
  21. package/docs/.vitepress/dist/assets/api_lifecycle.md.Ccm5xw6-.js +14 -0
  22. package/docs/.vitepress/dist/assets/api_lifecycle.md.Ccm5xw6-.lean.js +1 -0
  23. package/docs/.vitepress/dist/assets/api_route.md.CAHf_KNp.js +10 -0
  24. package/docs/.vitepress/dist/assets/api_route.md.CAHf_KNp.lean.js +1 -0
  25. package/docs/.vitepress/dist/assets/api_vite-plugin.md.DC8Li09k.js +13 -0
  26. package/docs/.vitepress/dist/assets/api_vite-plugin.md.DC8Li09k.lean.js +1 -0
  27. package/docs/.vitepress/dist/assets/app.BfblNDJy.js +1 -0
  28. package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.Crdp7-Zp.js +1 -0
  29. package/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.C18E44rY.js +9 -0
  30. package/docs/.vitepress/dist/assets/chunks/framework.B7OFBR9X.js +19 -0
  31. package/docs/.vitepress/dist/assets/chunks/theme.VX3itTW6.js +2 -0
  32. package/docs/.vitepress/dist/assets/examples_form.md.DQoAgbLR.js +34 -0
  33. package/docs/.vitepress/dist/assets/examples_form.md.DQoAgbLR.lean.js +1 -0
  34. package/docs/.vitepress/dist/assets/examples_index.md.CVJJjXXE.js +28 -0
  35. package/docs/.vitepress/dist/assets/examples_index.md.CVJJjXXE.lean.js +1 -0
  36. package/docs/.vitepress/dist/assets/examples_routing.md.sRnA5RXw.js +338 -0
  37. package/docs/.vitepress/dist/assets/examples_routing.md.sRnA5RXw.lean.js +1 -0
  38. package/docs/.vitepress/dist/assets/examples_sfc-showcase.md.DPf9Wm99.js +13 -0
  39. package/docs/.vitepress/dist/assets/examples_sfc-showcase.md.DPf9Wm99.lean.js +1 -0
  40. package/docs/.vitepress/dist/assets/examples_todo-app.md.CqF4JaWn.js +297 -0
  41. package/docs/.vitepress/dist/assets/examples_todo-app.md.CqF4JaWn.lean.js +1 -0
  42. package/docs/.vitepress/dist/assets/guide_cdn-usage.md.CjIjusre.js +182 -0
  43. package/docs/.vitepress/dist/assets/guide_cdn-usage.md.CjIjusre.lean.js +1 -0
  44. package/docs/.vitepress/dist/assets/guide_components.md.CMU3iM6R.js +174 -0
  45. package/docs/.vitepress/dist/assets/guide_components.md.CMU3iM6R.lean.js +1 -0
  46. package/docs/.vitepress/dist/assets/guide_contributing.md.Crrv3T_0.js +1 -0
  47. package/docs/.vitepress/dist/assets/guide_contributing.md.Crrv3T_0.lean.js +1 -0
  48. package/docs/.vitepress/dist/assets/guide_directives.md.DFwqvqOv.js +140 -0
  49. package/docs/.vitepress/dist/assets/guide_directives.md.DFwqvqOv.lean.js +1 -0
  50. package/docs/.vitepress/dist/assets/guide_getting-started.md.DtaJPe0i.js +107 -0
  51. package/docs/.vitepress/dist/assets/guide_getting-started.md.DtaJPe0i.lean.js +1 -0
  52. package/docs/.vitepress/dist/assets/guide_index.md.DtJVpLI9.js +2 -0
  53. package/docs/.vitepress/dist/assets/guide_index.md.DtJVpLI9.lean.js +1 -0
  54. package/docs/.vitepress/dist/assets/guide_lifecycle.md.CfY3jlU1.js +304 -0
  55. package/docs/.vitepress/dist/assets/guide_lifecycle.md.CfY3jlU1.lean.js +1 -0
  56. package/docs/.vitepress/dist/assets/guide_quick-start.md.CwdNNA21.js +33 -0
  57. package/docs/.vitepress/dist/assets/guide_quick-start.md.CwdNNA21.lean.js +1 -0
  58. package/docs/.vitepress/dist/assets/guide_reactivity.md.DgTH0MTn.js +135 -0
  59. package/docs/.vitepress/dist/assets/guide_reactivity.md.DgTH0MTn.lean.js +1 -0
  60. package/docs/.vitepress/dist/assets/guide_routing.md.nMB0QOBR.js +193 -0
  61. package/docs/.vitepress/dist/assets/guide_routing.md.nMB0QOBR.lean.js +1 -0
  62. package/docs/.vitepress/dist/assets/guide_sfc.md.BUkWma1z.js +187 -0
  63. package/docs/.vitepress/dist/assets/guide_sfc.md.BUkWma1z.lean.js +1 -0
  64. package/docs/.vitepress/dist/assets/guide_templating.md.XI3uUlYI.js +119 -0
  65. package/docs/.vitepress/dist/assets/guide_templating.md.XI3uUlYI.lean.js +1 -0
  66. package/docs/.vitepress/dist/assets/index.md.M4_o26kF.js +23 -0
  67. package/docs/.vitepress/dist/assets/index.md.M4_o26kF.lean.js +1 -0
  68. package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  69. package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  70. package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  71. package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  72. package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  73. package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  74. package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  75. package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  76. package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  77. package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  78. package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  79. package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  80. package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  81. package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  82. package/docs/.vitepress/dist/assets/style.eycE2Jhw.css +1 -0
  83. package/docs/.vitepress/dist/examples/form.html +58 -0
  84. package/docs/.vitepress/dist/examples/index.html +52 -0
  85. package/docs/.vitepress/dist/examples/routing.html +362 -0
  86. package/docs/.vitepress/dist/examples/sfc-showcase.html +37 -0
  87. package/docs/.vitepress/dist/examples/todo-app.html +321 -0
  88. package/docs/.vitepress/dist/guide/cdn-usage.html +206 -0
  89. package/docs/.vitepress/dist/guide/components.html +198 -0
  90. package/docs/.vitepress/dist/guide/contributing.html +25 -0
  91. package/docs/.vitepress/dist/guide/directives.html +164 -0
  92. package/docs/.vitepress/dist/guide/getting-started.html +131 -0
  93. package/docs/.vitepress/dist/guide/index.html +26 -0
  94. package/docs/.vitepress/dist/guide/lifecycle.html +328 -0
  95. package/docs/.vitepress/dist/guide/quick-start.html +57 -0
  96. package/docs/.vitepress/dist/guide/reactivity.html +159 -0
  97. package/docs/.vitepress/dist/guide/routing.html +217 -0
  98. package/docs/.vitepress/dist/guide/sfc.html +211 -0
  99. package/docs/.vitepress/dist/guide/templating.html +143 -0
  100. package/docs/.vitepress/dist/hashmap.json +1 -0
  101. package/docs/.vitepress/dist/index.html +47 -0
  102. package/docs/.vitepress/dist/logo.svg +38 -0
  103. package/docs/.vitepress/dist/vp-icons.css +1 -0
  104. package/docs/api/define.md +31 -0
  105. package/docs/api/directives.md +42 -0
  106. package/docs/api/globals.md +29 -0
  107. package/docs/api/index.md +29 -0
  108. package/docs/api/lifecycle.md +40 -0
  109. package/docs/api/route.md +37 -0
  110. package/docs/api/vite-plugin.md +58 -0
  111. package/docs/examples/form.md +42 -0
  112. package/docs/examples/index.md +104 -0
  113. package/docs/examples/routing.md +409 -0
  114. package/docs/examples/sfc-showcase.md +34 -0
  115. package/docs/examples/todo-app.md +383 -0
  116. package/docs/guide/cdn-usage.md +320 -0
  117. package/docs/guide/components.md +394 -0
  118. package/docs/guide/contributing.md +32 -0
  119. package/docs/guide/directives.md +430 -0
  120. package/docs/guide/getting-started.md +233 -0
  121. package/docs/guide/index.md +88 -0
  122. package/docs/guide/lifecycle.md +493 -0
  123. package/docs/guide/quick-start.md +46 -0
  124. package/docs/guide/reactivity.md +394 -0
  125. package/docs/guide/routing.md +373 -0
  126. package/docs/guide/sfc.md +381 -0
  127. package/docs/guide/templating.md +383 -0
  128. package/docs/index.md +126 -0
  129. package/docs/public/logo.svg +17 -0
  130. package/examples/vite-app/README.md +71 -0
  131. package/examples/vite-app/index.html +49 -0
  132. package/examples/vite-app/package.json +16 -0
  133. package/examples/vite-app/src/components/greeting-card.lego +41 -0
  134. package/examples/vite-app/src/components/sample-component.lego +75 -0
  135. package/examples/vite-app/src/components/todo-list.lego +242 -0
  136. package/examples/vite-app/src/main.js +11 -0
  137. package/examples/vite-app/vite.config.js +17 -0
  138. package/examples.js +99 -0
  139. package/go.html +117 -0
  140. package/lego.js +2 -0
  141. package/main.js +41 -35
  142. package/package.json +39 -6
  143. package/parse-lego.js +119 -0
  144. package/parse-lego.test.js +107 -0
  145. package/vite-plugin.js +133 -0
  146. package/.ignore/auto.html +0 -135
  147. package/.ignore/test.html +0 -73
@@ -0,0 +1,56 @@
1
+ name: Deploy Documentation
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ concurrency:
14
+ group: pages
15
+ cancel-in-progress: false
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout
22
+ uses: actions/checkout@v4
23
+ with:
24
+ fetch-depth: 0
25
+
26
+ - name: Setup Node
27
+ uses: actions/setup-node@v4
28
+ with:
29
+ node-version: 20
30
+ cache: npm
31
+
32
+ - name: Setup Pages
33
+ uses: actions/configure-pages@v4
34
+
35
+ - name: Install dependencies
36
+ run: npm ci
37
+
38
+ - name: Build with VitePress
39
+ run: npm run docs:build
40
+
41
+ - name: Upload artifact
42
+ uses: actions/upload-pages-artifact@v3
43
+ with:
44
+ path: docs/.vitepress/dist
45
+
46
+ deploy:
47
+ environment:
48
+ name: github-pages
49
+ url: ${{ steps.deployment.outputs.page_url }}
50
+ needs: build
51
+ runs-on: ubuntu-latest
52
+ name: Deploy
53
+ steps:
54
+ - name: Deploy to GitHub Pages
55
+ id: deployment
56
+ uses: actions/deploy-pages@v4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tersoo Ortserga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,344 +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.
7
+ [**Explore the Docs**](https://rayattack.github.io/legodom/) | [**Examples**](https://rayattack.github.io/legodom/examples/) | [**GitHub**](https://github.com/rayattack/legodom)
15
8
 
16
9
  ---
17
10
 
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:
11
+ ## Why Lego?
27
12
 
28
- ```html
29
- <script src="node_modules/lego-dom/main.js"></script>
30
- ```
31
-
32
- Once loaded, `Lego` is available globally.
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.
33
18
 
34
19
  ---
35
20
 
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`.
21
+ ## Quick Start (No Build Required)
54
22
 
55
23
  ```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>
24
+ <!DOCTYPE html>
25
+ <html>
26
+ <body>
27
+ <hello-world></hello-world>
64
28
 
65
- <h2>Hello {{ name }}</h2>
66
- <button @click="count++">Clicked {{ count }} times</button>
67
- </template>
68
- ```
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>
69
36
 
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>
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>
88
48
  ```
89
49
 
90
- No setters. No actions. No reducers.
91
-
92
- Just mutate data.
93
-
94
50
  ---
95
51
 
96
- ## Templating (`{{ }}`)
52
+ ## Also Supports Modern Toolchains
97
53
 
98
- Text interpolation works in:
99
-
100
- * Text nodes
101
- * Attributes
102
- * Class names
54
+ Lego includes a **Vite plugin** for developers who prefer **Single File Components (.lego)**:
103
55
 
104
56
  ```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
- ```
214
-
215
- ---
216
-
217
- ## Custom Events (`$emit`)
218
-
219
- Child components communicate upward using events.
220
-
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
230
-
231
- ---
232
-
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:
275
-
276
- ```html
277
- <p>User ID: {{ global.params.id }}</p>
278
- ```
279
-
280
- Navigation:
281
-
282
- ```html
283
- <a href="/dashboard" b-link>Dashboard</a>
284
- ```
285
-
286
- ---
287
-
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
57
+ <!-- user-card.lego -->
58
+ <template>
59
+ <h1>{{ name }}</h1>
60
+ </template>
298
61
 
299
- You can also define components programmatically:
62
+ <style>
63
+ self { display: block; padding: 20px; }
64
+ </style>
300
65
 
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
- );
66
+ <script>
67
+ export default { name: 'John Doe' }
68
+ </script>
310
69
  ```
311
70
 
312
71
  ---
313
72
 
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
- ---
73
+ ## 🔗 Links
334
74
 
335
- ## 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/)
336
79
 
337
- * Install with `npm install lego-dom`
338
- * Define components with `<template b-id>`
339
- * Use `b-data` for state
340
- * Use `{{ }}` for binding
341
- * Use `@event` for logic
342
- * Use `b-if`, `b-for`, and `b-sync` for structure
80
+ ## License
343
81
 
344
- That’s it.
82
+ MIT © [Tersoo Ortserga](https://github.com/rayattack)
@@ -0,0 +1,107 @@
1
+ import { defineConfig } from 'vitepress';
2
+
3
+ export default defineConfig({
4
+ title: 'Lego',
5
+ description: 'A feature-rich web components + SFC frontend framework',
6
+ base: '/legodom/',
7
+
8
+ themeConfig: {
9
+ logo: '/logo.svg',
10
+
11
+ nav: [
12
+ { text: 'Guide', link: '/guide/' },
13
+ { text: 'API', link: '/api/' },
14
+ { text: 'Examples', link: '/examples/' },
15
+ {
16
+ text: 'v0.0.7',
17
+ items: [
18
+ { text: 'Changelog', link: 'https://github.com/rayattack/LegoJS/releases' }
19
+
20
+ ]
21
+ }
22
+ ],
23
+
24
+ sidebar: {
25
+ '/guide/': [
26
+ {
27
+ text: 'Introduction',
28
+ items: [
29
+ { text: 'What is Lego?', link: '/guide/' },
30
+ { text: 'Getting Started', link: '/guide/getting-started' },
31
+ { text: 'Quick Start', link: '/guide/quick-start' },
32
+ { text: 'Contributing', link: '/guide/contributing' }
33
+ ]
34
+ },
35
+ {
36
+ text: 'Core Concepts',
37
+ items: [
38
+ { text: 'Components', link: '/guide/components' },
39
+ { text: 'Templating', link: '/guide/templating' },
40
+ { text: 'Reactivity', link: '/guide/reactivity' },
41
+ { text: 'Directives', link: '/guide/directives' }
42
+ ]
43
+ },
44
+ {
45
+ text: 'Advanced',
46
+ items: [
47
+ { text: 'Single File Components', link: '/guide/sfc' },
48
+ { text: 'Routing', link: '/guide/routing' },
49
+ { text: 'CDN Usage', link: '/guide/cdn-usage' },
50
+ { text: 'Lifecycle Hooks', link: '/guide/lifecycle' }
51
+ ]
52
+ }
53
+ ],
54
+ '/api/': [
55
+ {
56
+ text: 'API Reference',
57
+ items: [
58
+ { text: 'Overview', link: '/api/' },
59
+ { text: 'Lego.define()', link: '/api/define' },
60
+ { text: 'Lego.route()', link: '/api/route' },
61
+ { text: 'Lego.globals', link: '/api/globals' },
62
+ { text: 'Directives', link: '/api/directives' },
63
+ { text: 'Lifecycle Hooks', link: '/api/lifecycle' },
64
+ { text: 'Vite Plugin', link: '/api/vite-plugin' }
65
+ ]
66
+ }
67
+ ],
68
+ '/examples/': [
69
+ {
70
+ text: 'Examples',
71
+ items: [
72
+ { text: 'Overview', link: '/examples/' },
73
+ { text: 'Todo App', link: '/examples/todo-app' },
74
+ { text: 'Routing Demo', link: '/examples/routing' },
75
+ { text: 'SFC Showcase', link: '/examples/sfc-showcase' },
76
+ { text: 'Form Validation', link: '/examples/form' }
77
+ ]
78
+ }
79
+ ]
80
+ },
81
+
82
+ socialLinks: [
83
+ { icon: 'github', link: 'https://github.com/rayattack/LegoJS' }
84
+ ],
85
+
86
+ footer: {
87
+ message: 'Released under the MIT License.',
88
+ copyright: 'Copyright © 2024-present'
89
+ },
90
+
91
+ search: {
92
+ provider: 'local'
93
+ },
94
+
95
+ editLink: {
96
+ pattern: 'https://github.com/rayattack/LegoJS/edit/main/docs/:path',
97
+ text: 'Edit this page on GitHub'
98
+ }
99
+ },
100
+
101
+ markdown: {
102
+ theme: {
103
+ light: 'github-light',
104
+ dark: 'github-dark'
105
+ }
106
+ }
107
+ });
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-US" dir="ltr">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <title>404 | Lego</title>
7
+ <meta name="description" content="Not Found">
8
+ <meta name="generator" content="VitePress v1.6.4">
9
+ <link rel="preload stylesheet" href="/LegoJS/assets/style.eycE2Jhw.css" as="style">
10
+ <link rel="preload stylesheet" href="/LegoJS/vp-icons.css" as="style">
11
+
12
+ <script type="module" src="/LegoJS/assets/app.BfblNDJy.js"></script>
13
+ <link rel="preload" href="/LegoJS/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
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
+ <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
16
+ </head>
17
+ <body>
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\":\"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
+
21
+ </body>
22
+ </html>