-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
262 lines (193 loc) · 7.85 KB
/
index.html
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<link rel="stylesheet" type="text/css" href="barrel.css">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="importmap">
{
"imports": {
"picodash": "./dist/picodash-base.esm.js"
}
}
</script>
<script type="module" src="./dist/picodash-plugin-units-bundled.esm.js"></script>
<script type="module" src="./dist/picodash-plugin-confetti-bundled.esm.js"></script>
<script type="module">
import picodash from "./dist/picodash-base.esm.js"
var ds1 = new picodash.SimpleVariableDataSource("myDataSource", { step: 0.25 })
await ds1.register()
await ds1.pushData(10)
var ds2 = new picodash.SimpleVariableDataSource("myDataSource2", {})
await ds2.register()
var ds3 = new picodash.SimpleVariableDataSource("demo1", {})
await ds3.register()
await ds3.pushData(0)
var ds4 = new picodash.SimpleVariableDataSource("confetti", {})
await ds4.register()
await ds4.pushData(0)
var count = [0]
for (var i = 0; i < 100; i++) {
ds2.pushData(count[0])
count[0] += 1
}
setInterval(function () {
ds2.pushData(count[0])
count[0] += 1
}, 2500)
class Nop extends picodash.Filter {
constructor(s, conf, prev) {
// Prev can be undefined, the data source object,
// Or the previous filter
super(s, conf, prev)
}
async get(unfiltered) {
// Convert from unfiltered to filtered
return unfiltered
}
async set(val) {
// Convert from filtered to unfiltered
return val
}
}
picodash.addFilterProvider('nop', Nop)
</script>
<main>
<h2>Picodash Demo</h2>
<section class="window margin">
<div class="stacked-form">
<label>Random Data(Fixed Point)
<ds-span source="random:" filter="fixedpoint: 3"></ds-span>
</label>
<label>Random Data(nop filter does nothing)
<ds-meter source="random:" filter="nop:" class="w-4rem"></ds-meter>
</label>
<label>Readonly Data
<ds-input source="fixed:124.6779" filter="fixedpoint: 3"></ds-input>
</label>
<label>Two fields with same data source
<ds-input type="number" source="myDataSource"></ds-input>
</label>
<label>Two fields with same data source
<ds-input type="number" source="myDataSource"></ds-input>
</label>
<label>Same data source, but with multiplier x10 filter
<ds-input type="number" source="myDataSource" filter="mult: 10"></ds-input>
</label>
<label>Multiplier x50 and offset +1000 filter stacked
<ds-input type="number" source="myDataSource" filter="mult: 50 | offset: 1000"></ds-input>
</label>
<label>Trigger Buttons send an incrementing counter by default
<ds-button source="myDataSource">Press Me!</ds-button>
</label>
<label>Scrolling log window(x5 multiplier filter)
<ds-logwindow source="myDataSource2" filter="mult: 5" class="scroll max-h-12rem"></ds-logwindow>
</label>
</div>
</section>
<section class="window margin">
<div class="stacked-form">
<label>The confetti plugin puts confetti everywhere on changes.
<ds-input source="confetti" filter="confetti:"></ds-input>
</label>
<label>Button can set this to a random value!
<ds-span source="demo1" filter="fixedpoint: 3"></ds-span>
</label>
<p>The button uses source-pressed to set a specific value,
which it gives the main source when pressed.
</p>
<p>
We multiply the rand val by 100. Our filter stack is "fixedpoint: 1 | mult: 0.01".
</p>
<p>
Note that the filters are the reverse
order of what you'd think, because we're going from widget to source.
</p>
<p>Filters only apply to the primary source.</p>
<label>
<ds-button source="demo1" source-pressed="random:" filter="fixedpoint: 1 | mult: 0.01">Press
Me!</ds-button>
</label>
</div>
</section>
<script type="module">
import picodash from "./dist/picodash-base.esm.js"
let ds4 = new picodash.SimpleVariableDataSource('snackbar', {})
ds4.register()
let ds5 = new picodash.SimpleVariableDataSource('vib', {})
ds5.register()
</script>
<section class="window margin">
<div class="stacked-form">
<p>When this value changes, put up a snackbar</p>
<label>text
<ds-input source="snackbar" filter="notify: You changed the value!"></ds-input>
</label>
<label>Vibrate on change with the vibrate: filter
<ds-input source="vib" filter="vibrate:"></ds-input>
</label>
<label>Require confirmation
<ds-input source="vib" filter="confirm: Really change value?"></ds-input>
</label>
</div>
</section>
<script type="module">
import picodash from "./dist/picodash-base.esm.js"
let p = new picodash.SimpleVariableDataSource('pt', {})
p.register()
</script>
<section class="window margin">
<div class="stacked-form">
<p>The prompt: provider lets you ask the user questions.</p>
<label>text
<ds-input source="pt"></ds-input>
</label>
<label>Set Value
<ds-button source="pt" source-pressed="prompt: enter a new value">Set value</ds-button>
</label>
</div>
</section>
<script type="module">
import picodash from "./dist/picodash-base.esm.js"
let p2 = new picodash.SimpleVariableDataSource('nav', {})
p2.pushData([1, 2, 3, 4])
p2.register()
</script>
<section class="window margin">
<div class="stacked-form">
<p>The nav: key filter lets you get or set just one element of an array or object.</p>
<label>The json filter lets you work with lists and objects as json strings.
<ds-input source="nav" filter="json:" disabled></ds-input>
</label>
<p>Just edits the third element</p>
<label>Third Val
<ds-input type="number" source="nav" filter="nav: 2"></ds-input>
</label>
</div>
</section>
<script type="module">
import picodash from "./dist/picodash-base.esm.js"
let p3 = new picodash.SimpleVariableDataSource('temp', { unit: "C" })
p3.pushData(30)
p3.register()
let pb = new picodash.SimpleVariableDataSource('pb', {})
pb.pushData(1)
pb.register()
</script>
<section class="window margin">
<div class="stacked-form">
<p>The unit: filter converts to the given unit. It does nothing if the input data has no unit.</p>
<label>ds-span auto-shows the unit
<ds-span source="temp" filter="fixedpoint: 2"></ds-span>
</label>
<label>Degrees C
<ds-input source="temp" filter="fixedpoint: 2"></ds-input>
</label>
<label>Degrees F
<ds-input source="temp" filter="unit: F | fixedpoint: 2"></ds-input>
</label>
<label>Toggles push true/false but can take 0/1
<ds-input type="checkbox" class="toggle" source="pb"></ds-input>
</label>
<label>Number inputs can take true/false
<ds-input type="number" source="pb"></ds-input>
</label>
</div>
</section>
</main>