Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
177 lines (163 loc) · 8.13 KB
/
Copy pathindex.html
File metadata and controls
177 lines (163 loc) · 8.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!-- SEO-friendly SPA Shim -->
<script src="/lightview-router.js?base=/index.html"></script>
</script>
<div class="docs-layout">
<aside class="docs-sidebar" src="./nav.html" data-preserve-scroll="docs-nav"></aside>
<main class="docs-content">
<h1>API Reference</h1>
<p>
Lightview provides a small but powerful API. Everything you need, nothing you don't.
<em>Keep it light, remember?</em>
</p>
<h2>Lightview Overview</h2>
<table class="api-table">
<thead>
<tr>
<th>Function</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="./signals.html"><code>signal(value, optionsOrName?)</code></a><br><code>signal.get(name)</code>
</td>
<td>Create reactive state that triggers updates when changed. Optional name or options object allows
global access and persistence.
</td>
</tr>
<tr>
<td><a href="./computed.html"><code>computed(fn)</code></a></td>
<td>Derive values from signals automatically</td>
</tr>
<tr>
<td><a href="./effects.html"><code>effect(fn)</code></a></td>
<td>Run side effects when dependencies change</td>
</tr>
<tr>
<td><a href="./elements.html"><code>tags.*</code></a></td>
<td>Shorthand element creators (div, span, button, etc.)</td>
</tr>
<tr>
<td><code>$(selector)</code></td>
<td>Query the DOM and return a native element enhanced with a <code>.content(node, location?)</code>
method.
The <code>location</code> can be <code>'inner'</code> (default), <code>'outer'</code>,
<code>'shadow'</code>,
<code>'beforebegin'</code>, <code>'afterbegin'</code>, <code>'beforeend'</code>, or
<code>'afterend'</code>.
The <code>node</code> argument is polymorphic and can be a real DOM node, a virtual node (vDOM),
Object DOM, or an array of these.
</td>
</tr>
<tr>
<td><a href="./enhance.html"><code>enhance(selector, options)</code></a></td>
<td>Add reactivity to existing DOM elements. Perfect for progressive enhancement of traditional HTML
pages.</td>
</tr>
</tbody>
</table>
<h2>Lightview X Overview</h2>
<p>
Lightview X automatically enhances the core Lightview instance when loaded, adding hypermedia capabilities,
template literal support, and deep reactive state. Object DOM syntax is now always available in core
Lightview.
</p>
<table class="api-table">
<thead>
<tr>
<th>Feature / Function</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="./state.html"><code>state(obj, optionsOrName?)</code></a><br><code>state.get(name)</code>
</td>
<td>Create deep reactive state for complex objects/arrays. Optional name or options object allows
global access and persistence.</td>
</tr>
<tr>
<td><code>registerStyleSheet(id, css)</code></td>
<td>Register a named stylesheet for use in Shadow DOM components. Can take a CSS string, a URL, or a
selector to a <code><style></code> tag.</td>
</tr>
<tr>
<td><code>registerThemeSheet(url)</code></td>
<td>Register a global theme stylesheet that is automatically applied to all Shadow DOM components.
</td>
</tr>
<tr>
<td><a href="/docs/hypermedia/#fetching-content"><code>src="..."</code></a></td>
<td>Attribute to automatically fetch HTML or JSON representing HTML and inject it into the element.
</td>
</tr>
<tr>
<td><a href="/docs/hypermedia/#href-navigation"><code>href="..."</code></a></td>
<td>Attribute for SPA navigation and src injection on any element. Supports targeting content
before, at the start of, and the end of or after other elements via CSS selectors.</td>
</tr>
<tr>
<td>
<code><div>${signal.get('count').value}</div></code><br><code><span>${state.get('user').name}</span></code>
</td>
<td>Syntax support for using signals and state directly inside string templates in HTML or JSON
representation of HTML.</td>
</tr>
</tbody>
</table>
<h2>Using Lightview</h2>
<pre><code><!-- Core only -->
<script src="lightview.js"></script>
<!-- Full power -->
<script src="lightview.js"></script>
<script src="lightview-x.js"></script></code></pre>
<pre><code>// Destructure what you need from the global instances
const { signal, computed, effect, element, tags, $, enhance } = Lightview;
const { state } = LightviewX; // Deep state (lightview-x)</code></pre>
<h2>Core Modules</h2>
<div class="feature-grid" style="margin-top: 1.5rem;">
<a href="./signals" class="feature-card" style="text-decoration: none; color: inherit;">
<h3 class="feature-title">Signals</h3>
<p class="feature-description">
The foundation. Reactive primitives that make everything tick.
</p>
</a>
<a href="./computed" class="feature-card" style="text-decoration: none; color: inherit;">
<h3 class="feature-title">Computed</h3>
<p class="feature-description">
Derived state. Values that update themselves.
</p>
</a>
<a href="./effects" class="feature-card" style="text-decoration: none; color: inherit;">
<h3 class="feature-title">Effects</h3>
<p class="feature-description">
Side effects. Do things when state changes.
</p>
</a>
<a href="./elements.html" class="feature-card" style="text-decoration: none; color: inherit;">
<h3 class="feature-title">Syntax Styles</h3>
<p class="feature-description">
Five ways to build UI: tag functions, vDOM, Object DOM, Custom Elements, and the experimental cDOM.
</p>
<p style="margin-top: 1rem; font-style: italic;">
An exciting 5th option is coming: the <strong>Computational DOM</strong>, a.k.a. <strong><a
href="/docs/cdom.html">cDOM</a></strong>.
</p>
</a>
<a href="./enhance" class="feature-card" style="text-decoration: none; color: inherit;">
<h3 class="feature-title">Enhance</h3>
<p class="feature-description">
Add reactivity to existing HTML. Progressive enhancement made easy.
</p>
</a>
<a href="/docs/hypermedia/" class="feature-card" style="text-decoration: none; color: inherit;">
<h3 class="feature-title">Hypermedia</h3>
<p class="feature-description">
Fetch content with src. HTM-style patterns, built in.
</p>
</a>
</div>
</main>
</div>