lightview 1.8.1-b → 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 (224) 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 +1331 -21
  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 +612 -0
  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 +487 -0
  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 +134 -0
  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 +658 -1109
  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/components/chart/chart.html +0 -17
  165. package/components/chart/example.html +0 -32
  166. package/components/chart.html +0 -83
  167. package/components/components.js +0 -113
  168. package/components/gantt/example.html +0 -22
  169. package/components/gantt/gantt.html +0 -42
  170. package/components/gauge/example.html +0 -28
  171. package/components/gauge/gauge.html +0 -20
  172. package/components/gauge.html +0 -60
  173. package/components/orgchart/example.html +0 -25
  174. package/components/orgchart/orgchart.html +0 -41
  175. package/components/repl/code-editor.html +0 -64
  176. package/components/repl/editor.html +0 -37
  177. package/components/repl/editorjs-inline-tool/index.js +0 -3
  178. package/components/repl/editorjs-inline-tool/inline-tools.js +0 -28
  179. package/components/repl/editorjs-inline-tool/tool.js +0 -175
  180. package/components/repl/repl-with-wysiwyg.html +0 -355
  181. package/components/repl/repl.html +0 -345
  182. package/components/repl/sup.js +0 -44
  183. package/components/repl/wysiwyg-repl.html +0 -258
  184. package/components/timeline/example.html +0 -33
  185. package/components/timeline/timeline.html +0 -44
  186. package/components/timeline.html +0 -81
  187. package/examples/anchor.html +0 -11
  188. package/examples/chart.html +0 -34
  189. package/examples/counter.html +0 -26
  190. package/examples/counter.test.mjs +0 -47
  191. package/examples/counter2.html +0 -26
  192. package/examples/directives.html +0 -79
  193. package/examples/foreign.html +0 -50
  194. package/examples/forgeinform.html +0 -98
  195. package/examples/form.html +0 -61
  196. package/examples/gauge.html +0 -18
  197. package/examples/invalid-template-literals.html +0 -44
  198. package/examples/medium/remote.html +0 -60
  199. package/examples/message.html +0 -18
  200. package/examples/nested.html +0 -11
  201. package/examples/object-bound-form.html +0 -34
  202. package/examples/remote-server.js +0 -51
  203. package/examples/remote.html +0 -34
  204. package/examples/remote.json +0 -1
  205. package/examples/scratch.html +0 -69
  206. package/examples/sensors/index.html +0 -30
  207. package/examples/sensors/sensor-server.js +0 -30
  208. package/examples/shared.html +0 -41
  209. package/examples/template.html +0 -33
  210. package/examples/timeline.html +0 -21
  211. package/examples/todo.html +0 -38
  212. package/examples/top.html +0 -10
  213. package/examples/types.html +0 -94
  214. package/examples/xor.html +0 -62
  215. package/jest-puppeteer.config.js +0 -5
  216. package/jest.config.json +0 -12
  217. package/sites/client.html +0 -48
  218. package/sites/index.html +0 -247
  219. package/test/basic.html +0 -93
  220. package/test/basic.test.mjs +0 -315
  221. package/test/extended.html +0 -29
  222. package/test/extended.test.mjs +0 -448
  223. package/types.js +0 -534
  224. package/unsplash.key +0 -1
@@ -0,0 +1,517 @@
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
+ <!-- Load the page-specific stylesheet -->
10
+ <link rel="stylesheet" href="./index.css">
11
+
12
+ <!-- Gallery Structure -->
13
+ <div class="gallery-page">
14
+ <div class="gallery-layout">
15
+ <!-- Sidebar Overlay -->
16
+ <div id="sidebar-overlay" class="sidebar-overlay"></div>
17
+
18
+ <!-- Sidebar -->
19
+ <div id="gallery-sidebar" class="gallery-sidebar" style="visibility: hidden" src="./component-nav.html"></div>
20
+
21
+ <!-- Main Content -->
22
+ <div id="gallery-main" class="gallery-main">
23
+ <!-- Header Container -->
24
+ <div
25
+ style="position: sticky; top: 0; z-index: 30; background: var(--gallery-surface); border-bottom: 1px solid var(--gallery-border); backdrop-filter: blur(8px);">
26
+ <!-- Breadcrumbs Row -->
27
+ <div style="padding: 0.75rem 1.5rem 0;">
28
+ <script>
29
+ (() => {
30
+ const { Breadcrumbs } = Lightview.tags;
31
+ const breadcrumbs = Breadcrumbs({
32
+ id: 'page-breadcrumbs',
33
+ items: [
34
+ { label: 'Components', href: '/docs/components' },
35
+ { label: 'Swap' }
36
+ ]
37
+ });
38
+ document.currentScript.replaceWith(breadcrumbs.domEl);
39
+ })();
40
+ </script>
41
+ </div>
42
+ <!-- Title Row -->
43
+ <div class="gallery-header"
44
+ style="border-bottom: none; height: auto; padding-top: 0.5rem; padding-bottom: 0.75rem;">
45
+ <button id="toggle-btn" class="toggle-btn" aria-label="Toggle Sidebar">
46
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="toggle-icon"
47
+ style="stroke: currentColor; stroke-width: 2;">
48
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
49
+ <path stroke-linecap="round" stroke-linejoin="round" d="M11 19l-7-7 7-7" />
50
+ </svg>
51
+ </button>
52
+ <h1 class="gallery-title">Swap</h1>
53
+ </div>
54
+ </div>
55
+
56
+ <!-- Content -->
57
+ <div class="gallery-content">
58
+ <div class="section-content" style="max-width: 1000px;">
59
+ <p class="text-lg" style="opacity: 0.7; margin-bottom: 1.5rem;">
60
+ Swap toggles the visibility of two elements with a smooth transition.
61
+ Perfect for toggle buttons, theme switchers, and animated icons.
62
+ </p>
63
+
64
+ <!-- Basic Example with Examplify -->
65
+ <div class="card bg-base-200" style="margin-bottom: 2rem;">
66
+ <div class="card-body">
67
+ <h2 class="card-title">Basic Example</h2>
68
+ <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">Swap with rotate animation</p>
69
+
70
+ <!-- Tabs -->
71
+ <script>
72
+ window.switchSyntaxTab = (tabId) => {
73
+ const tabs = ['tagged', 'vdom', 'object'];
74
+ tabs.forEach(t => {
75
+ const tabEl = document.getElementById(`tab-btn-${t}`);
76
+ const contentEl = document.getElementById(`syntax-${t}`);
77
+ if (t === tabId) {
78
+ tabEl.classList.add('syntax-tab-active');
79
+ contentEl.style.display = 'block';
80
+ } else {
81
+ tabEl.classList.remove('syntax-tab-active');
82
+ contentEl.style.display = 'none';
83
+ }
84
+ });
85
+ };
86
+ </script>
87
+ <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
88
+ <button id="tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
89
+ onclick="switchSyntaxTab('tagged')">Tagged</button>
90
+ <button id="tab-btn-vdom" role="tab" class="syntax-tab"
91
+ onclick="switchSyntaxTab('vdom')">vDOM</button>
92
+ <button id="tab-btn-object" role="tab" class="syntax-tab"
93
+ onclick="switchSyntaxTab('object')">Object
94
+ DOM</button>
95
+ </div>
96
+
97
+ <!-- Tagged Syntax -->
98
+ <div id="syntax-tagged">
99
+ <pre><script>
100
+ examplify(document.currentScript.nextElementSibling, {
101
+ at: document.currentScript.parentElement,
102
+ scripts: ['/lightview.js', '/lightview-x.js'],
103
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
104
+ type: 'module',
105
+ minHeight: 80,
106
+ autoRun: true
107
+ });
108
+ </script><code contenteditable="true">await import('/components/actions/swap.js');
109
+ const { tags, $ } = Lightview;
110
+ const { div, Swap } = tags;
111
+
112
+ // Emoji swap with rotate effect
113
+ const emojiSwap = Swap({ effect: 'rotate', class: 'text-4xl' },
114
+ Swap.On({}, '😈'),
115
+ Swap.Off({}, '😇')
116
+ );
117
+
118
+ // Play/Pause swap
119
+ const playPause = Swap({ effect: 'rotate', class: 'btn btn-circle' },
120
+ Swap.On({}, '⏸️'),
121
+ Swap.Off({}, '▶️')
122
+ );
123
+
124
+ $('#example').content(
125
+ div({ style: 'display: flex; gap: 2rem; align-items: center' },
126
+ emojiSwap,
127
+ playPause
128
+ )
129
+ );</code></pre>
130
+ </div>
131
+
132
+ <!-- vDOM Syntax -->
133
+ <div id="syntax-vdom" style="display: none;">
134
+ <pre><script>
135
+ examplify(document.currentScript.nextElementSibling, {
136
+ at: document.currentScript.parentElement,
137
+ scripts: ['/lightview.js', '/lightview-x.js'],
138
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
139
+ type: 'module',
140
+ minHeight: 80
141
+ });
142
+ </script><code contenteditable="true">await import('/components/actions/swap.js');
143
+ const { $, tags } = Lightview;
144
+ const { Swap, div } = tags;
145
+
146
+ const emojiSwap = {
147
+ tag: Swap,
148
+ attributes: { effect: 'rotate', class: 'text-4xl' },
149
+ children: [
150
+ { tag: Swap.On, children: ['😈'] },
151
+ { tag: Swap.Off, children: ['😇'] }
152
+ ]
153
+ };
154
+
155
+ const playPause = {
156
+ tag: Swap,
157
+ attributes: { effect: 'rotate', class: 'btn btn-circle' },
158
+ children: [
159
+ { tag: Swap.On, children: ['⏸️'] },
160
+ { tag: Swap.Off, children: ['▶️'] }
161
+ ]
162
+ };
163
+
164
+ $('#example').content({
165
+ tag: div,
166
+ attributes: { style: 'display: flex; gap: 2rem; align-items: center' },
167
+ children: [emojiSwap, playPause]
168
+ });</code></pre>
169
+ </div>
170
+
171
+ <!-- Object DOM Syntax -->
172
+ <div id="syntax-object" style="display: none;">
173
+ <pre><script>
174
+ examplify(document.currentScript.nextElementSibling, {
175
+ at: document.currentScript.parentElement,
176
+ scripts: ['/lightview.js', '/lightview-x.js'],
177
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
178
+ type: 'module',
179
+ minHeight: 80
180
+ });
181
+ </script><code contenteditable="true">await import('/components/actions/swap.js');
182
+ const { $ } = Lightview;
183
+
184
+ const demo = {
185
+ div: {
186
+ style: 'display: flex; gap: 2rem; align-items: center',
187
+ children: [
188
+ {
189
+ Swap: {
190
+ effect: 'rotate',
191
+ class: 'text-4xl',
192
+ children: [
193
+ { 'Swap.On': { children: ['😈'] } },
194
+ { 'Swap.Off': { children: ['😇'] } }
195
+ ]
196
+ }
197
+ },
198
+ {
199
+ Swap: {
200
+ effect: 'rotate',
201
+ class: 'btn btn-circle',
202
+ children: [
203
+ { 'Swap.On': { children: ['⏸️'] } },
204
+ { 'Swap.Off': { children: ['▶️'] } }
205
+ ]
206
+ }
207
+ }
208
+ ]
209
+ }
210
+ };
211
+
212
+ $('#example').content(demo);</code></pre>
213
+ </div>
214
+ </div>
215
+ </div>
216
+
217
+ <!-- Reactive Example with Examplify -->
218
+ <div class="card bg-base-200" style="margin-bottom: 2rem;">
219
+ <div class="card-body">
220
+ <h2 class="card-title">Reactive Toggle</h2>
221
+ <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">Controlled swap with signal
222
+ binding</p>
223
+
224
+ <!-- Tabs -->
225
+ <script>
226
+ window.switchReactiveSyntaxTab = (tabId) => {
227
+ const tabs = ['tagged', 'vdom', 'object'];
228
+ tabs.forEach(t => {
229
+ const tabEl = document.getElementById(`reactive-tab-btn-${t}`);
230
+ const contentEl = document.getElementById(`reactive-syntax-${t}`);
231
+ if (t === tabId) {
232
+ tabEl.classList.add('syntax-tab-active');
233
+ contentEl.style.display = 'block';
234
+ } else {
235
+ tabEl.classList.remove('syntax-tab-active');
236
+ contentEl.style.display = 'none';
237
+ }
238
+ });
239
+ };
240
+ </script>
241
+ <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
242
+ <button id="reactive-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
243
+ onclick="switchReactiveSyntaxTab('tagged')">Tagged</button>
244
+ <button id="reactive-tab-btn-vdom" role="tab" class="syntax-tab"
245
+ onclick="switchReactiveSyntaxTab('vdom')">vDOM</button>
246
+ <button id="reactive-tab-btn-object" role="tab" class="syntax-tab"
247
+ onclick="switchReactiveSyntaxTab('object')">Object DOM</button>
248
+ </div>
249
+
250
+ <!-- Tagged Syntax -->
251
+ <div id="reactive-syntax-tagged">
252
+ <pre><script>
253
+ examplify(document.currentScript.nextElementSibling, {
254
+ at: document.currentScript.parentElement,
255
+ scripts: ['/lightview.js', '/lightview-x.js'],
256
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
257
+ type: 'module',
258
+ minHeight: 180
259
+ });
260
+ </script><code contenteditable="true">await import('/components/actions/swap.js');
261
+ await import('/components/actions/button.js');
262
+
263
+ const { signal, tags, $ } = Lightview;
264
+ const { div, p, Swap, Button } = tags;
265
+
266
+ const isActive = signal(false);
267
+
268
+ // Controlled swap
269
+ const swap = Swap({
270
+ effect: 'flip',
271
+ class: 'text-6xl',
272
+ active: () => isActive.value,
273
+ onChange: (checked) => { isActive.value = checked; }
274
+ },
275
+ Swap.On({}, '🥳'),
276
+ Swap.Off({}, '😭')
277
+ );
278
+
279
+ // External control
280
+ const demo = div({ style: 'display: flex; flex-direction: column; gap: 1rem; align-items: center' },
281
+ swap,
282
+ p({ class: 'text-sm' },
283
+ () => isActive.value ? 'Party time! 🎉' : 'So sad... 💔'
284
+ ),
285
+ Button({
286
+ color: 'primary',
287
+ size: 'sm',
288
+ onclick: () => { isActive.value = !isActive.value; }
289
+ }, 'Toggle from button')
290
+ );
291
+
292
+ $('#example').content(demo);</code></pre>
293
+ </div>
294
+
295
+ <!-- vDOM Syntax -->
296
+ <div id="reactive-syntax-vdom" style="display: none;">
297
+ <pre><script>
298
+ examplify(document.currentScript.nextElementSibling, {
299
+ at: document.currentScript.parentElement,
300
+ scripts: ['/lightview.js', '/lightview-x.js'],
301
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
302
+ type: 'module',
303
+ minHeight: 180
304
+ });
305
+ </script><code contenteditable="true">await import('/components/actions/swap.js');
306
+ await import('/components/actions/button.js');
307
+ const { signal, $, tags } = Lightview;
308
+ const { Swap, Button, div, p } = tags;
309
+
310
+ const isActive = signal(false);
311
+
312
+ const demo = {
313
+ tag: div,
314
+ attributes: { style: 'display: flex; flex-direction: column; gap: 1rem; align-items: center' },
315
+ children: [
316
+ {
317
+ tag: Swap,
318
+ attributes: {
319
+ effect: 'flip',
320
+ class: 'text-6xl',
321
+ active: () => isActive.value,
322
+ onChange: (checked) => { isActive.value = checked; }
323
+ },
324
+ children: [
325
+ { tag: Swap.On, children: ['🥳'] },
326
+ { tag: Swap.Off, children: ['😭'] }
327
+ ]
328
+ },
329
+ {
330
+ tag: p,
331
+ attributes: { class: 'text-sm' },
332
+ children: [() => isActive.value ? 'Party time! 🎉' : 'So sad... 💔']
333
+ },
334
+ {
335
+ tag: Button,
336
+ attributes: {
337
+ color: 'primary',
338
+ size: 'sm',
339
+ onclick: () => { isActive.value = !isActive.value; }
340
+ },
341
+ children: ['Toggle from button']
342
+ }
343
+ ]
344
+ };
345
+
346
+ $('#example').content(demo);</code></pre>
347
+ </div>
348
+
349
+ <!-- Object DOM Syntax -->
350
+ <div id="reactive-syntax-object" style="display: none;">
351
+ <pre><script>
352
+ examplify(document.currentScript.nextElementSibling, {
353
+ at: document.currentScript.parentElement,
354
+ scripts: ['/lightview.js', '/lightview-x.js'],
355
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
356
+ type: 'module',
357
+ minHeight: 180
358
+ });
359
+ </script><code contenteditable="true">await import('/components/actions/swap.js');
360
+ await import('/components/actions/button.js');
361
+ const { signal, $ } = Lightview;
362
+
363
+ const isActive = signal(false);
364
+
365
+ const demo = {
366
+ div: {
367
+ style: 'display: flex; flex-direction: column; gap: 1rem; align-items: center',
368
+ children: [
369
+ {
370
+ Swap: {
371
+ effect: 'flip',
372
+ class: 'text-6xl',
373
+ active: () => isActive.value,
374
+ onChange: (checked) => { isActive.value = checked; },
375
+ children: [
376
+ { 'Swap.On': { children: ['🥳'] } },
377
+ { 'Swap.Off': { children: ['😭'] } }
378
+ ]
379
+ }
380
+ },
381
+ {
382
+ p: {
383
+ class: 'text-sm',
384
+ children: [() => isActive.value ? 'Party time! 🎉' : 'So sad... 💔']
385
+ }
386
+ },
387
+ {
388
+ Button: {
389
+ color: 'primary',
390
+ size: 'sm',
391
+ onclick: () => { isActive.value = !isActive.value; },
392
+ children: ['Toggle from button']
393
+ }
394
+ }
395
+ ]
396
+ }
397
+ };
398
+
399
+ $('#example').content(demo);</code></pre>
400
+ </div>
401
+ </div>
402
+ </div>
403
+
404
+ <!-- Props Table -->
405
+ <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Props</h2>
406
+ <div style="overflow-x: auto; margin-bottom: 2rem;">
407
+ <table class="table table-zebra">
408
+ <thead>
409
+ <tr>
410
+ <th>Prop</th>
411
+ <th>Type</th>
412
+ <th>Default</th>
413
+ <th>Description</th>
414
+ </tr>
415
+ </thead>
416
+ <tbody>
417
+ <tr>
418
+ <td><code>active</code></td>
419
+ <td>boolean | function</td>
420
+ <td>false</td>
421
+ <td>Control swap state (reactive)</td>
422
+ </tr>
423
+ <tr>
424
+ <td><code>effect</code></td>
425
+ <td>string</td>
426
+ <td>-</td>
427
+ <td>'rotate' | 'flip'</td>
428
+ </tr>
429
+ <tr>
430
+ <td><code>onChange</code></td>
431
+ <td>function</td>
432
+ <td>-</td>
433
+ <td>Callback when state changes: <code>(checked) => void</code></td>
434
+ </tr>
435
+ </tbody>
436
+ </table>
437
+ </div>
438
+
439
+ <!-- Sub-components -->
440
+ <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Sub-components</h2>
441
+ <div style="overflow-x: auto; margin-bottom: 2rem;">
442
+ <table class="table table-zebra">
443
+ <thead>
444
+ <tr>
445
+ <th>Component</th>
446
+ <th>Description</th>
447
+ </tr>
448
+ </thead>
449
+ <tbody>
450
+ <tr>
451
+ <td><code>Swap.On</code></td>
452
+ <td>Content visible when active/checked</td>
453
+ </tr>
454
+ <tr>
455
+ <td><code>Swap.Off</code></td>
456
+ <td>Content visible when inactive/unchecked</td>
457
+ </tr>
458
+ </tbody>
459
+ </table>
460
+ </div>
461
+
462
+ <!-- Effects -->
463
+ <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Effects</h2>
464
+ <div class="example-flex" style="margin-bottom: 2rem;">
465
+ <div class="text-center">
466
+ <p class="text-sm opacity-70 mb-2">Rotate</p>
467
+ <label class="swap swap-rotate text-4xl">
468
+ <input type="checkbox" />
469
+ <div class="swap-on">😈</div>
470
+ <div class="swap-off">😇</div>
471
+ </label>
472
+ </div>
473
+ <div class="text-center">
474
+ <p class="text-sm opacity-70 mb-2">Flip</p>
475
+ <label class="swap swap-flip text-4xl">
476
+ <input type="checkbox" />
477
+ <div class="swap-on">🥳</div>
478
+ <div class="swap-off">😭</div>
479
+ </label>
480
+ </div>
481
+ </div>
482
+
483
+ <!-- Hamburger Menu Icon -->
484
+ <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Hamburger Menu Icon</h2>
485
+ <label class="btn btn-circle swap swap-rotate" style="margin-bottom: 2rem;">
486
+ <input type="checkbox" />
487
+ <svg class="swap-off fill-current" xmlns="http://www.w3.org/2000/svg" width="32" height="32"
488
+ viewBox="0 0 512 512">
489
+ <path d="M64,384H448V341.33H64Zm0-106.67H448V234.67H64ZM64,128v42.67H448V128Z" />
490
+ </svg>
491
+ <svg class="swap-on fill-current" xmlns="http://www.w3.org/2000/svg" width="32" height="32"
492
+ viewBox="0 0 512 512">
493
+ <polygon
494
+ points="400 145.49 366.51 112 256 222.51 145.49 112 112 145.49 222.51 256 112 366.51 145.49 400 256 289.49 366.51 400 400 366.51 289.49 256 400 145.49" />
495
+ </svg>
496
+ </label>
497
+
498
+ <!-- Theme Toggle -->
499
+ <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Theme Toggle (Sun/Moon)</h2>
500
+ <label class="swap swap-rotate" style="margin-bottom: 2rem;">
501
+ <input type="checkbox" class="theme-controller" value="dark" />
502
+ <svg class="swap-off h-10 w-10 fill-current" xmlns="http://www.w3.org/2000/svg"
503
+ viewBox="0 0 24 24">
504
+ <path
505
+ d="M5.64,17l-.71.71a1,1,0,0,0,0,1.41,1,1,0,0,0,1.41,0l.71-.71A1,1,0,0,0,5.64,17ZM5,12a1,1,0,0,0-1-1H3a1,1,0,0,0,0,2H4A1,1,0,0,0,5,12Zm7-7a1,1,0,0,0,1-1V3a1,1,0,0,0-2,0V4A1,1,0,0,0,12,5ZM5.64,7.05a1,1,0,0,0,.7.29,1,1,0,0,0,.71-.29,1,1,0,0,0,0-1.41l-.71-.71A1,1,0,0,0,4.93,6.34Zm12,.29a1,1,0,0,0,.7-.29l.71-.71a1,1,0,1,0-1.41-1.41L17,5.64a1,1,0,0,0,0,1.41A1,1,0,0,0,17.66,7.34ZM21,11H20a1,1,0,0,0,0,2h1a1,1,0,0,0,0-2Zm-9,8a1,1,0,0,0-1,1v1a1,1,0,0,0,2,0V20A1,1,0,0,0,12,19ZM18.36,17A1,1,0,0,0,17,18.36l.71.71a1,1,0,0,0,1.41,0,1,1,0,0,0,0-1.41ZM12,6.5A5.5,5.5,0,1,0,17.5,12,5.51,5.51,0,0,0,12,6.5Zm0,9A3.5,3.5,0,1,1,15.5,12,3.5,3.5,0,0,1,12,15.5Z" />
506
+ </svg>
507
+ <svg class="swap-on h-10 w-10 fill-current" xmlns="http://www.w3.org/2000/svg"
508
+ viewBox="0 0 24 24">
509
+ <path
510
+ d="M21.64,13a1,1,0,0,0-1.05-.14,8.05,8.05,0,0,1-3.37.73A8.15,8.15,0,0,1,9.08,5.49a8.59,8.59,0,0,1,.25-2A1,1,0,0,0,8,2.36,10.14,10.14,0,1,0,22,14.05,1,1,0,0,0,21.64,13Zm-9.5,6.69A8.14,8.14,0,0,1,7.08,5.22v.27A10.15,10.15,0,0,0,17.22,15.63a9.79,9.79,0,0,0,2.1-.22A8.11,8.11,0,0,1,12.14,19.73Z" />
511
+ </svg>
512
+ </label>
513
+ </div>
514
+ </div>
515
+ </div>
516
+ </div>
517
+ </div>
@@ -0,0 +1,68 @@
1
+ <!-- SEO-friendly SPA Shim -->
2
+ <script src="/lightview-router.js"></script>
3
+ <script>
4
+ if (window.LightviewRouter) {
5
+ window.location.replace('/docs/components/toggle');
6
+ } else {
7
+ window.location.href = 'toggle.html';
8
+ }
9
+ </script>
10
+
11
+ <!-- Load the page-specific stylesheet -->
12
+ <link rel="stylesheet" href="./index.css">
13
+
14
+ <!-- Gallery Structure -->
15
+ <div class="gallery-page">
16
+ <div class="gallery-layout">
17
+ <!-- Sidebar Overlay -->
18
+ <div id="sidebar-overlay" class="sidebar-overlay"></div>
19
+
20
+ <!-- Sidebar -->
21
+ <div id="gallery-sidebar" class="gallery-sidebar" style="visibility: hidden" src="./component-nav.html"></div>
22
+
23
+ <!-- Main Content -->
24
+ <div id="gallery-main" class="gallery-main">
25
+ <!-- Header Container -->
26
+ <div
27
+ style="position: sticky; top: 0; z-index: 30; background: var(--gallery-surface); border-bottom: 1px solid var(--gallery-border); backdrop-filter: blur(8px);">
28
+ <!-- Breadcrumbs Row -->
29
+ <div style="padding: 0.75rem 1.5rem 0;">
30
+ <script>
31
+ (() => {
32
+ const { Breadcrumbs } = Lightview.tags;
33
+ const breadcrumbs = Breadcrumbs({
34
+ id: 'page-breadcrumbs',
35
+ items: [
36
+ { label: 'Components', href: '/docs/components' },
37
+ { label: 'Switch' }
38
+ ]
39
+ });
40
+ document.currentScript.replaceWith(breadcrumbs.domEl);
41
+ })();
42
+ </script>
43
+ </div>
44
+ <!-- Title Row -->
45
+ <div class="gallery-header"
46
+ style="border-bottom: none; height: auto; padding-top: 0.5rem; padding-bottom: 0.75rem;">
47
+ <button id="toggle-btn" class="toggle-btn" aria-label="Toggle Sidebar">
48
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="toggle-icon"
49
+ style="stroke: currentColor; stroke-width: 2;">
50
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
51
+ <path stroke-linecap="round" stroke-linejoin="round" d="M11 19l-7-7 7-7" />
52
+ </svg>
53
+ </button>
54
+ <h1 class="gallery-title">Switch</h1>
55
+ </div>
56
+ </div>
57
+
58
+ <!-- Content -->
59
+ <div class="gallery-content">
60
+ <div class="section-content" style="max-width: 1000px;">
61
+ <p class="text-lg" style="opacity: 0.7; margin-bottom: 1.5rem;">
62
+ Redirecting to <a href="/docs/components/toggle">Toggle</a>...
63
+ </p>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>