lightview 1.8.2 → 2.0.0

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 (264) hide show
  1. package/.agent/workflows/daisyui-component-migration.md +155 -0
  2. package/.codacy/cli.sh +149 -0
  3. package/.codacy/codacy.yaml +15 -0
  4. package/.github/instructions/codacy.instructions.md +72 -0
  5. package/.wranglerignore +21 -0
  6. package/README.md +1330 -19
  7. package/_headers +4 -0
  8. package/build.js +70 -0
  9. package/components/actions/button.js +151 -0
  10. package/components/actions/dropdown.js +120 -0
  11. package/components/actions/modal.js +146 -0
  12. package/components/actions/swap.js +118 -0
  13. package/components/daisyui.js +288 -0
  14. package/components/data-display/accordion.js +128 -0
  15. package/components/data-display/alert.js +112 -0
  16. package/components/data-display/avatar.js +170 -0
  17. package/components/data-display/badge.js +82 -0
  18. package/components/data-display/card.js +151 -0
  19. package/components/data-display/carousel.js +94 -0
  20. package/components/data-display/chart.js +220 -0
  21. package/components/data-display/chat.js +128 -0
  22. package/components/data-display/collapse.js +103 -0
  23. package/components/data-display/countdown.js +69 -0
  24. package/components/data-display/diff.js +111 -0
  25. package/components/data-display/kbd.js +65 -0
  26. package/components/data-display/loading.js +75 -0
  27. package/components/data-display/progress.js +79 -0
  28. package/components/data-display/radial-progress.js +88 -0
  29. package/components/data-display/skeleton.js +66 -0
  30. package/components/data-display/stats.js +159 -0
  31. package/components/data-display/table.js +146 -0
  32. package/components/data-display/timeline.js +146 -0
  33. package/components/data-display/toast.js +72 -0
  34. package/components/data-display/tooltip.js +74 -0
  35. package/components/data-input/checkbox.js +253 -0
  36. package/components/data-input/file-input.js +224 -0
  37. package/components/data-input/input.js +264 -0
  38. package/components/data-input/radio.js +338 -0
  39. package/components/data-input/range.js +204 -0
  40. package/components/data-input/rating.js +219 -0
  41. package/components/data-input/select.js +287 -0
  42. package/components/data-input/textarea.js +287 -0
  43. package/components/data-input/toggle.js +201 -0
  44. package/components/index.js +137 -0
  45. package/components/layout/divider.js +72 -0
  46. package/components/layout/drawer.js +142 -0
  47. package/components/layout/footer.js +100 -0
  48. package/components/layout/hero.js +109 -0
  49. package/components/layout/indicator.js +90 -0
  50. package/components/layout/join.js +78 -0
  51. package/components/layout/navbar.js +110 -0
  52. package/components/navigation/breadcrumbs.js +91 -0
  53. package/components/navigation/dock.js +103 -0
  54. package/components/navigation/menu.js +126 -0
  55. package/components/navigation/pagination.js +105 -0
  56. package/components/navigation/steps.js +89 -0
  57. package/components/navigation/tabs.css +177 -0
  58. package/components/navigation/tabs.js +123 -0
  59. package/components/theme/theme-switch.css +65 -0
  60. package/components/theme/theme-switch.js +177 -0
  61. package/docs/about.html +164 -0
  62. package/docs/api/computed.html +184 -0
  63. package/docs/api/effects.html +173 -0
  64. package/docs/api/elements.html +180 -0
  65. package/docs/api/enhance.html +225 -0
  66. package/docs/api/hypermedia.html +165 -0
  67. package/docs/api/index.html +178 -0
  68. package/docs/api/nav.html +18 -0
  69. package/docs/api/signals.html +136 -0
  70. package/docs/api/state.html +217 -0
  71. package/docs/assets/images/logo-favicon.svg +42 -0
  72. package/docs/assets/images/logo-static.svg +40 -0
  73. package/docs/assets/images/logo.svg +66 -0
  74. package/docs/assets/js/examplify.js +395 -0
  75. package/docs/assets/styles/site.css +1102 -0
  76. package/docs/assets/styles/themes.css +236 -0
  77. package/docs/components/accordion.html +439 -0
  78. package/docs/components/alert.html +528 -0
  79. package/docs/components/avatar.html +586 -0
  80. package/docs/components/badge.html +531 -0
  81. package/docs/components/breadcrumbs.html +278 -0
  82. package/docs/components/button.html +579 -0
  83. package/docs/components/card.html +561 -0
  84. package/docs/components/carousel.html +286 -0
  85. package/docs/components/chart-area.html +702 -0
  86. package/docs/components/chart-bar.html +782 -0
  87. package/docs/components/chart-column.html +735 -0
  88. package/docs/components/chart-line.html +794 -0
  89. package/docs/components/chart-pie.html +823 -0
  90. package/docs/components/chart.html +610 -15
  91. package/docs/components/chat.html +547 -0
  92. package/docs/components/checkbox.html +641 -0
  93. package/docs/components/collapse.html +536 -0
  94. package/docs/components/component-nav.html +53 -0
  95. package/docs/components/countdown.html +470 -0
  96. package/docs/components/diff.html +245 -0
  97. package/docs/components/divider.html +240 -0
  98. package/docs/components/dock.html +277 -0
  99. package/docs/components/drawer.html +515 -0
  100. package/docs/components/dropdown.html +479 -0
  101. package/docs/components/file-input.html +591 -0
  102. package/docs/components/footer.html +301 -0
  103. package/docs/components/gallery.html +504 -0
  104. package/docs/components/hero.html +264 -0
  105. package/docs/components/index.css +840 -0
  106. package/docs/components/index.html +735 -0
  107. package/docs/components/indicator.html +342 -0
  108. package/docs/components/input.html +644 -0
  109. package/docs/components/join.html +285 -0
  110. package/docs/components/kbd.html +322 -0
  111. package/docs/components/loading.html +521 -0
  112. package/docs/components/menu.html +461 -0
  113. package/docs/components/modal.html +639 -0
  114. package/docs/components/navbar.html +321 -0
  115. package/docs/components/pagination.html +279 -0
  116. package/docs/components/progress.html +514 -0
  117. package/docs/components/radial-progress.html +434 -0
  118. package/docs/components/radio.html +655 -0
  119. package/docs/components/range.html +611 -0
  120. package/docs/components/rating.html +642 -0
  121. package/docs/components/select.html +696 -0
  122. package/docs/components/sidebar-setup.js +93 -0
  123. package/docs/components/skeleton.html +447 -0
  124. package/docs/components/spinner.html +68 -0
  125. package/docs/components/stats.html +486 -0
  126. package/docs/components/steps.html +356 -0
  127. package/docs/components/swap.html +517 -0
  128. package/docs/components/switch.html +68 -0
  129. package/docs/components/table.html +668 -0
  130. package/docs/components/tabs.html +506 -0
  131. package/docs/components/text-input.html +68 -0
  132. package/docs/components/textarea.html +603 -0
  133. package/docs/components/timeline.html +485 -42
  134. package/docs/components/toast.html +474 -0
  135. package/docs/components/toggle.html +564 -0
  136. package/docs/components/tooltip.html +423 -0
  137. package/docs/examples/getting-started-example.html +40 -0
  138. package/docs/examples/index.html +93 -0
  139. package/docs/getting-started/index.html +739 -0
  140. package/docs/getting-started/reviews.html +23 -0
  141. package/docs/getting-started/reviews.odom +108 -0
  142. package/docs/getting-started/reviews.vdom +84 -0
  143. package/docs/index.html +132 -42
  144. package/docs/playground.html +416 -0
  145. package/docs/router.html +285 -0
  146. package/docs/styles/index.html +190 -0
  147. package/functions/_middleware.js +32 -0
  148. package/index.html +309 -0
  149. package/lightview-router.js +364 -0
  150. package/lightview-x.js +1577 -0
  151. package/lightview.js +659 -1200
  152. package/lightview.js.backup +793 -0
  153. package/middleware/locale.js +25 -0
  154. package/middleware/markdown.js +44 -0
  155. package/middleware/notFound.js +37 -0
  156. package/package.json +27 -41
  157. package/watch.js +92 -0
  158. package/wrangler.toml +12 -0
  159. package/.idea/lightview.iml +0 -12
  160. package/.idea/modules.xml +0 -8
  161. package/.idea/vcs.xml +0 -6
  162. package/LICENSE +0 -21
  163. package/codepen-no-tabs-embed.css +0 -2
  164. package/docs/CNAME +0 -1
  165. package/docs/api.html +0 -674
  166. package/docs/blank.html +0 -10
  167. package/docs/comparedto.html +0 -89
  168. package/docs/components/chart-repl.html +0 -69
  169. package/docs/components/components.js +0 -113
  170. package/docs/components/contents.html +0 -17
  171. package/docs/components/gantt-repl.html +0 -61
  172. package/docs/components/gantt.html +0 -42
  173. package/docs/components/gauge-repl.html +0 -66
  174. package/docs/components/gauge.html +0 -20
  175. package/docs/components/orgchart-repl.html +0 -64
  176. package/docs/components/orgchart.html +0 -41
  177. package/docs/components/repl-as-src.html +0 -17
  178. package/docs/components/repl-repl.html +0 -95
  179. package/docs/components/repl.html +0 -527
  180. package/docs/components/timeline-repl.html +0 -72
  181. package/docs/components.html +0 -14
  182. package/docs/css/highlightjs.min.css +0 -9
  183. package/docs/css/tutorial.css +0 -35
  184. package/docs/examples/anchor.html +0 -11
  185. package/docs/examples/chart.html +0 -34
  186. package/docs/examples/counter.html +0 -26
  187. package/docs/examples/counter.test.mjs +0 -47
  188. package/docs/examples/counter2.html +0 -26
  189. package/docs/examples/directives.html +0 -79
  190. package/docs/examples/foreign.html +0 -50
  191. package/docs/examples/forgeinform.html +0 -98
  192. package/docs/examples/form.html +0 -61
  193. package/docs/examples/gauge.html +0 -18
  194. package/docs/examples/invalid-template-literals.html +0 -44
  195. package/docs/examples/medium/remote.html +0 -60
  196. package/docs/examples/message.html +0 -18
  197. package/docs/examples/nested.html +0 -11
  198. package/docs/examples/object-bound-form.html +0 -34
  199. package/docs/examples/remote-server.js +0 -51
  200. package/docs/examples/remote.html +0 -34
  201. package/docs/examples/remote.json +0 -1
  202. package/docs/examples/scratch.html +0 -69
  203. package/docs/examples/sensors/index.html +0 -44
  204. package/docs/examples/sensors/sensor-server.js +0 -30
  205. package/docs/examples/shared.html +0 -41
  206. package/docs/examples/template.html +0 -33
  207. package/docs/examples/timeline.html +0 -21
  208. package/docs/examples/todo.html +0 -40
  209. package/docs/examples/top.html +0 -10
  210. package/docs/examples/types.html +0 -94
  211. package/docs/examples/xor.html +0 -62
  212. package/docs/examples.html +0 -25
  213. package/docs/javascript/codejar.min.js +0 -8
  214. package/docs/javascript/highlightjs.min.js +0 -1173
  215. package/docs/javascript/isomorphic-git.js +0 -9
  216. package/docs/javascript/json5.min.js +0 -1
  217. package/docs/javascript/lightning-fs.js +0 -1
  218. package/docs/javascript/lightview.js +0 -1285
  219. package/docs/javascript/marked.min.js +0 -6
  220. package/docs/javascript/peerjs.min.js +0 -70
  221. package/docs/javascript/turndown.js +0 -973
  222. package/docs/javascript/types.js +0 -606
  223. package/docs/javascript/utils.js +0 -45
  224. package/docs/lightview.html +0 -63
  225. package/docs/old_index.html +0 -965
  226. package/docs/old_index.md +0 -1132
  227. package/docs/slidein.html +0 -51
  228. package/docs/tutorial/0-getting-started.html +0 -67
  229. package/docs/tutorial/1-intro-to-variables.html +0 -103
  230. package/docs/tutorial/10-template-components.html +0 -80
  231. package/docs/tutorial/11-linked-components.html +0 -76
  232. package/docs/tutorial/12-imported-components.html +0 -67
  233. package/docs/tutorial/13-input-binding.html +0 -94
  234. package/docs/tutorial/14-automatic-variable-creation.html +0 -74
  235. package/docs/tutorial/15-form-binding.html +0 -110
  236. package/docs/tutorial/16-if-directive.html +0 -60
  237. package/docs/tutorial/17-loop-directives.html +0 -83
  238. package/docs/tutorial/18-sanitizing-and-escaping-input.html +0 -79
  239. package/docs/tutorial/2-imported-and-exported-variables.html +0 -80
  240. package/docs/tutorial/3-data-types.html +0 -89
  241. package/docs/tutorial/4-extended-data-types.html +0 -83
  242. package/docs/tutorial/5-extended-functional-types.html +0 -96
  243. package/docs/tutorial/5.1-extended-functional-types.html +0 -79
  244. package/docs/tutorial/5.2-extended-functional-types.html +0 -70
  245. package/docs/tutorial/6-conventional-javascript.html +0 -75
  246. package/docs/tutorial/7-monitoring-with-observers.html +0 -107
  247. package/docs/tutorial/8-event-listeners.html +0 -65
  248. package/docs/tutorial/9-intro-to-components.html +0 -91
  249. package/docs/tutorial/contents.html +0 -32
  250. package/docs/tutorial/my-component.html +0 -29
  251. package/docs/tutorial/remote-value.json +0 -4
  252. package/docs/websiterepl.html +0 -46
  253. package/jest-puppeteer.config.js +0 -5
  254. package/jest.config.json +0 -12
  255. package/lightview.min.js +0 -1
  256. package/lightview_good.js +0 -1267
  257. package/lightview_optimized.js +0 -1274
  258. package/repl_hold.html +0 -320
  259. package/test/basic.html +0 -104
  260. package/test/basic.test.mjs +0 -315
  261. package/test/extended.html +0 -29
  262. package/test/extended.test.mjs +0 -448
  263. package/types.js +0 -607
  264. package/unsplash.key +0 -1
@@ -0,0 +1,416 @@
1
+ <!-- SEO-friendly SPA Shim -->
2
+ <script src="/lightview-router.js"></script>
3
+ <script>
4
+ if (window.LightviewRouter) {
5
+ LightviewRouter.base('/index.html');
6
+ }
7
+ </script>
8
+
9
+ <div class="playground-container" style="display: flex; min-height: 700px;">
10
+ <!-- Examples Drawer -->
11
+ <div class="examples-drawer" id="examples-drawer"
12
+ style="width: 220px; background: var(--site-bg-alt); border-right: 1px solid var(--site-border); display: flex; flex-direction: column; transition: width 0.3s ease; flex-shrink: 0;">
13
+ <div
14
+ style="display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--site-border);">
15
+ <span style="font-weight: 600; font-size: 0.875rem; color: var(--site-text-secondary);">EXAMPLES</span>
16
+ <button id="drawer-toggle"
17
+ style="background: none; border: none; cursor: pointer; padding: 0.25rem; color: var(--site-text-secondary);">
18
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
19
+ <path d="M10.5 3L6 8l4.5 5h-2L4 8l4.5-5h2z" />
20
+ </svg>
21
+ </button>
22
+ </div>
23
+ <div class="drawer-content" style="padding: 0.5rem; overflow-y: auto; flex: 1;">
24
+ <button class="example-item active" data-example="counter">🎯 Counter</button>
25
+ <button class="example-item" data-example="todo">✅ Todo List</button>
26
+ <button class="example-item" data-example="form">📝 Form Validation</button>
27
+ <button class="example-item" data-example="fetch">👥 Fetch Data</button>
28
+ <button class="example-item" data-example="tabs">📑 Tabs</button>
29
+ <button class="example-item" data-example="theme">🌙 Theme Toggle</button>
30
+ </div>
31
+ </div>
32
+
33
+ <!-- Main Content Area -->
34
+ <div style="flex: 1; display: flex; flex-direction: column; min-width: 0;">
35
+ <div class="playground-header"
36
+ style="display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--site-border); background: var(--site-bg-alt);">
37
+ <h2 style="margin: 0; font-size: 1.25rem;">Playground</h2>
38
+ </div>
39
+
40
+ <div class="playground-main" style="display: grid; grid-template-columns: 1fr 1fr; flex: 1;">
41
+ <!-- Code Editor -->
42
+ <div class="playground-editor"
43
+ style="border-right: 1px solid var(--site-border); display: flex; flex-direction: column;">
44
+ <div
45
+ style="padding: 0.5rem 1rem; background: var(--site-surface); border-bottom: 1px solid var(--site-border); display: flex; justify-content: space-between; align-items: center;">
46
+ <span style="font-weight: 600; color: var(--site-text-secondary); font-size: 0.875rem;">CODE</span>
47
+ </div>
48
+ <pre style="flex: 1; margin: 0; overflow: auto;"><code id="playground-code" contenteditable="true" style="display: block; padding: 1rem; min-height: 100%; outline: none;">// Welcome to the Lightview Playground! 🎉
49
+ // Click an example button above, or edit this code and click Run.
50
+
51
+ const { signal, tags, $ } = Lightview;
52
+ const { div, h1, p, button } = tags;
53
+
54
+ const count = signal(0);
55
+
56
+ const app = div({ style: 'text-align: center; padding: 2rem;' },
57
+ h1({ style: 'margin: 0 0 1rem;' }, '🎯 Counter'),
58
+ p({ style: 'font-size: 3rem; margin: 0;' },
59
+ () => count.value
60
+ ),
61
+ div({ style: 'display: flex; gap: 1rem; justify-content: center; margin-top: 1rem;' },
62
+ button({
63
+ onclick: () => count.value--,
64
+ style: 'padding: 0.75rem 1.5rem; font-size: 1.25rem; cursor: pointer;'
65
+ }, '−'),
66
+ button({
67
+ onclick: () => count.value++,
68
+ style: 'padding: 0.75rem 1.5rem; font-size: 1.25rem; cursor: pointer;'
69
+ }, '+')
70
+ )
71
+ );
72
+
73
+ $('#playground-preview').content(app);</code></pre>
74
+ </div>
75
+
76
+ <!-- Preview -->
77
+ <div class="playground-preview" style="display: flex; flex-direction: column;">
78
+ <div
79
+ style="padding: 0.5rem 1rem; background: var(--site-surface); border-bottom: 1px solid var(--site-border);">
80
+ <span
81
+ style="font-weight: 600; color: var(--site-text-secondary); font-size: 0.875rem;">PREVIEW</span>
82
+ </div>
83
+ <div id="playground-preview-container" style="flex: 1; background: var(--site-bg);">
84
+ <!-- Iframe inserted by examplify -->
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ </div>
90
+ </div>
91
+
92
+ <style>
93
+ .example-item {
94
+ display: block;
95
+ width: 100%;
96
+ text-align: left;
97
+ background: none;
98
+ border: none;
99
+ padding: 0.75rem 1rem;
100
+ cursor: pointer;
101
+ border-radius: var(--site-radius);
102
+ color: var(--site-text-secondary);
103
+ font-size: 0.875rem;
104
+ transition: all 0.2s ease;
105
+ margin-bottom: 0.25rem;
106
+ }
107
+
108
+ .example-item:hover {
109
+ background: var(--site-surface);
110
+ color: var(--site-text);
111
+ }
112
+
113
+ .example-item.active {
114
+ background: var(--site-primary);
115
+ color: white;
116
+ }
117
+
118
+ .examples-drawer.collapsed {
119
+ width: 0 !important;
120
+ overflow: hidden;
121
+ padding: 0;
122
+ }
123
+
124
+ .examples-drawer.collapsed .drawer-content,
125
+ .examples-drawer.collapsed>div:first-child>span {
126
+ opacity: 0;
127
+ }
128
+
129
+ @media (max-width: 900px) {
130
+ .playground-container {
131
+ flex-direction: column !important;
132
+ }
133
+
134
+ .examples-drawer {
135
+ width: 100% !important;
136
+ border-right: none !important;
137
+ border-bottom: 1px solid var(--site-border);
138
+ max-height: 200px;
139
+ }
140
+
141
+ .playground-main {
142
+ grid-template-columns: 1fr !important;
143
+ }
144
+
145
+ .playground-editor {
146
+ border-right: none !important;
147
+ border-bottom: 1px solid var(--site-border);
148
+ max-height: 400px;
149
+ }
150
+ }
151
+ </style>
152
+
153
+ <script>
154
+ (function () {
155
+ const codeEl = document.getElementById('playground-code');
156
+ const previewContainer = document.getElementById('playground-preview-container');
157
+
158
+ const examples = {
159
+ counter: `// Classic Counter Example
160
+ const { signal, tags, $ } = Lightview;
161
+ const { div, h1, p, button } = tags;
162
+
163
+ const count = signal(0);
164
+
165
+ const app = div({ style: 'text-align: center; padding: 2rem;' },
166
+ h1({ style: 'margin: 0 0 1rem;' }, '🎯 Counter'),
167
+ p({ style: 'font-size: 3rem; margin: 0;' },
168
+ () => count.value
169
+ ),
170
+ div({ style: 'display: flex; gap: 1rem; justify-content: center; margin-top: 1rem;' },
171
+ button({
172
+ onclick: () => count.value--,
173
+ style: 'padding: 0.75rem 1.5rem; font-size: 1.25rem; cursor: pointer;'
174
+ }, '−'),
175
+ button({
176
+ onclick: () => count.value++,
177
+ style: 'padding: 0.75rem 1.5rem; font-size: 1.25rem; cursor: pointer;'
178
+ }, '+')
179
+ )
180
+ );
181
+
182
+ $('#playground-preview').content(app);`,
183
+
184
+ todo: `// Todo List with State
185
+ const { state, signal, tags, $ } = Lightview;
186
+ const { div, h2, input, button, ul, li, span } = tags;
187
+
188
+ const todos = state([
189
+ { text: 'Learn Lightview', done: true },
190
+ { text: 'Build something cool', done: false }
191
+ ]);
192
+ const newTodo = signal('');
193
+
194
+ const addTodo = () => {
195
+ if (newTodo.value.trim()) {
196
+ todos.push({ text: newTodo.value, done: false });
197
+ newTodo.value = '';
198
+ }
199
+ };
200
+
201
+ const app = div({ style: 'padding: 1.5rem; max-width: 400px;' },
202
+ h2({ style: 'margin: 0 0 1rem;' }, '✅ Todo List'),
203
+ div({ style: 'display: flex; gap: 0.5rem; margin-bottom: 1rem;' },
204
+ input({
205
+ type: 'text',
206
+ placeholder: 'Add a task...',
207
+ value: () => newTodo.value,
208
+ oninput: (e) => newTodo.value = e.target.value,
209
+ onkeypress: (e) => e.key === 'Enter' && addTodo(),
210
+ style: 'flex: 1; padding: 0.5rem;'
211
+ }),
212
+ button({ onclick: addTodo, style: 'padding: 0.5rem 1rem;' }, 'Add')
213
+ ),
214
+ ul({ style: 'list-style: none; padding: 0; margin: 0;' },
215
+ () => todos.map((todo, i) =>
216
+ li({ style: 'display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0;' },
217
+ input({
218
+ type: 'checkbox',
219
+ checked: todo.done,
220
+ onchange: () => todos[i].done = !todos[i].done
221
+ }),
222
+ span({
223
+ style: () => todo.done ? 'text-decoration: line-through; opacity: 0.6;' : ''
224
+ }, todo.text),
225
+ button({
226
+ onclick: () => todos.splice(i, 1),
227
+ style: 'margin-left: auto; padding: 0.25rem 0.5rem; font-size: 0.75rem;'
228
+ }, '×')
229
+ )
230
+ )
231
+ )
232
+ );
233
+
234
+ $('#playground-preview').content(app);`,
235
+
236
+ form: `// Form Validation with Computed
237
+ const { signal, computed, tags, $ } = Lightview;
238
+ const { div, h2, label, input, button, p } = tags;
239
+
240
+ const email = signal('');
241
+ const password = signal('');
242
+
243
+ const isEmailValid = computed(() =>
244
+ /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email.value)
245
+ );
246
+ const isPasswordValid = computed(() =>
247
+ password.value.length >= 8
248
+ );
249
+ const canSubmit = computed(() =>
250
+ isEmailValid.value && isPasswordValid.value
251
+ );
252
+
253
+ const field = (labelText, type, sig, validation, hint) =>
254
+ div({ style: 'margin-bottom: 1rem;' },
255
+ label({ style: 'display: block; margin-bottom: 0.25rem;' }, labelText),
256
+ input({
257
+ type,
258
+ value: () => sig.value,
259
+ oninput: (e) => sig.value = e.target.value,
260
+ style: () => \`width: 100%; padding: 0.5rem; border: 1px solid \${sig.value && !validation.value ? '#ef4444' : '#ddd'}; border-radius: 4px;\`
261
+ }),
262
+ p({ style: 'font-size: 0.75rem; color: #666; margin: 0.25rem 0 0;' }, hint)
263
+ );
264
+
265
+ const app = div({ style: 'padding: 1.5rem; max-width: 350px;' },
266
+ h2({ style: 'margin: 0 0 1.5rem;' }, '📝 Sign Up'),
267
+ field('Email', 'email', email, isEmailValid, 'Enter a valid email'),
268
+ field('Password', 'password', password, isPasswordValid, 'At least 8 characters'),
269
+ button({
270
+ disabled: () => !canSubmit.value,
271
+ onclick: () => alert('Form submitted!'),
272
+ style: () => \`width: 100%; padding: 0.75rem; opacity: \${canSubmit.value ? 1 : 0.5};\`
273
+ }, 'Create Account')
274
+ );
275
+
276
+ $('#playground-preview').content(app);`,
277
+
278
+ fetch: `// Fetch Data Example
279
+ const { signal, tags, $ } = Lightview;
280
+ const { div, h2, button, ul, li, p } = tags;
281
+
282
+ const users = signal([]);
283
+ const loading = signal(false);
284
+
285
+ const fetchUsers = async () => {
286
+ loading.value = true;
287
+ const res = await fetch('https://jsonplaceholder.typicode.com/users');
288
+ users.value = await res.json();
289
+ loading.value = false;
290
+ };
291
+
292
+ const app = div({ style: 'padding: 1.5rem;' },
293
+ h2({ style: 'margin: 0 0 1rem;' }, '👥 Fetch Users'),
294
+ button({
295
+ onclick: fetchUsers,
296
+ disabled: () => loading.value,
297
+ style: 'padding: 0.5rem 1rem; margin-bottom: 1rem;'
298
+ }, () => loading.value ? 'Loading...' : 'Fetch Users'),
299
+ ul({ style: 'padding-left: 1.25rem; margin: 0;' },
300
+ () => users.value.slice(0, 5).map(user =>
301
+ li({ style: 'margin-bottom: 0.5rem;' },
302
+ \`\${user.name} (\${user.email})\`
303
+ )
304
+ )
305
+ )
306
+ );
307
+
308
+ $('#playground-preview').content(app);`,
309
+
310
+ tabs: `// Tabs Example
311
+ const { signal, tags, $ } = Lightview;
312
+ const { div, button, p, h3 } = tags;
313
+
314
+ const activeTab = signal(0);
315
+
316
+ const tabs = [
317
+ { label: '🏠 Home', content: 'Welcome to the home tab!' },
318
+ { label: '👤 Profile', content: 'Your profile info goes here.' },
319
+ { label: '⚙️ Settings', content: 'Adjust your preferences.' }
320
+ ];
321
+
322
+ const app = div({ style: 'padding: 1.5rem;' },
323
+ div({ style: 'display: flex; border-bottom: 1px solid #ddd; margin-bottom: 1rem;' },
324
+ ...tabs.map((tab, i) =>
325
+ button({
326
+ onclick: () => activeTab.value = i,
327
+ style: () => \`padding: 0.75rem 1rem; border: none; background: none; cursor: pointer; border-bottom: 2px solid \${activeTab.value === i ? '#6366f1' : 'transparent'}; color: \${activeTab.value === i ? '#6366f1' : '#666'};\`
328
+ }, tab.label)
329
+ )
330
+ ),
331
+ div({ style: 'padding: 1rem; background: #f9f9f9; border-radius: 8px;' },
332
+ h3({ style: 'margin: 0 0 0.5rem;' }, () => tabs[activeTab.value].label),
333
+ p({ style: 'margin: 0; color: #666;' }, () => tabs[activeTab.value].content)
334
+ )
335
+ );
336
+
337
+ $('#playground-preview').content(app);`,
338
+
339
+ theme: `// Theme Toggle
340
+ const { signal, tags, $ } = Lightview;
341
+ const { div, h2, button, p } = tags;
342
+
343
+ const isDark = signal(false);
344
+
345
+ const app = div({
346
+ style: () => \`padding: 2rem; text-align: center; background: \${isDark.value ? '#1e293b' : '#fff'}; color: \${isDark.value ? '#f1f5f9' : '#1e293b'}; transition: all 0.3s; min-height: 200px;\`
347
+ },
348
+ h2({ style: 'margin: 0 0 1rem;' },
349
+ () => isDark.value ? '🌙 Dark Mode' : '☀️ Light Mode'
350
+ ),
351
+ button({
352
+ onclick: () => isDark.value = !isDark.value,
353
+ style: () => \`padding: 0.75rem 1.5rem; border: none; border-radius: 8px; cursor: pointer; background: \${isDark.value ? '#f1f5f9' : '#1e293b'}; color: \${isDark.value ? '#1e293b' : '#f1f5f9'};\`
354
+ }, () => isDark.value ? 'Switch to Light' : 'Switch to Dark')
355
+ );
356
+
357
+ $('#playground-preview').content(app);`
358
+ };
359
+
360
+ let currentExamplify = null;
361
+
362
+ function runExample(code) {
363
+ // Clear previous
364
+ previewContainer.innerHTML = '';
365
+
366
+ // Use examplify
367
+ codeEl.textContent = code;
368
+ currentExamplify = examplify(codeEl, {
369
+ scripts: ['../../lightview.js', '../../lightview-x.js'],
370
+ html: '<div id="playground-preview"></div>',
371
+ location: 'afterEnd',
372
+ height: '100%'
373
+ });
374
+
375
+ // Move iframe into the preview container
376
+ if (currentExamplify && currentExamplify.iframe) {
377
+ previewContainer.appendChild(currentExamplify.iframe);
378
+ currentExamplify.iframe.style.height = '100%';
379
+ currentExamplify.iframe.style.minHeight = '400px';
380
+ }
381
+ }
382
+
383
+ // Example button clicks (drawer items)
384
+ const exampleItems = document.querySelectorAll('.example-item');
385
+ exampleItems.forEach(btn => {
386
+ btn.addEventListener('click', () => {
387
+ const name = btn.dataset.example;
388
+ if (examples[name]) {
389
+ // Update active state
390
+ exampleItems.forEach(item => item.classList.remove('active'));
391
+ btn.classList.add('active');
392
+
393
+ runExample(examples[name]);
394
+ }
395
+ });
396
+ });
397
+
398
+ // Drawer toggle
399
+ const drawer = document.getElementById('examples-drawer');
400
+ const drawerToggle = document.getElementById('drawer-toggle');
401
+ if (drawerToggle) {
402
+ drawerToggle.addEventListener('click', () => {
403
+ drawer.classList.toggle('collapsed');
404
+ // Rotate the arrow icon
405
+ const svg = drawerToggle.querySelector('svg');
406
+ if (svg) {
407
+ svg.style.transform = drawer.classList.contains('collapsed') ? 'rotate(180deg)' : '';
408
+ }
409
+ });
410
+ }
411
+
412
+ // Initial load
413
+ runExample(examples.counter);
414
+
415
+ })();
416
+ </script>