tagu-tagu 3.4.0 → 3.4.2

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 (2) hide show
  1. package/README.md +66 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -313,8 +313,72 @@ function InitializerCallbackExample() {
313
313
 
314
314
  document.body.appendChild(InitializerCallbackExample());
315
315
  ```
316
+
317
+ ### `State`
318
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/j3948zpo/1/)
319
+ ```typescript
320
+ import { button, div, useState } from "tagu-tagu";
321
+
322
+ function SimpleStateExample() {
323
+ const count = useState(0);
324
+
325
+ function incrementCount() {
326
+ count.set(count.get() + 1);
327
+ }
328
+
329
+ return div([div(count), button("+", { on: { click: incrementCount } })]);
330
+ }
331
+
332
+ document.body.appendChild(SimpleStateExample());
333
+ ```
334
+
335
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/by934m81/2/)
336
+ ```typescript
337
+ import { button, div, useState } from "tagu-tagu";
338
+
339
+ function StateFromStateExample() {
340
+ const count = useState(0);
341
+
342
+ function incrementCount() {
343
+ count.set(count.get() + 1);
344
+ }
345
+
346
+ return div([
347
+ div(useState(count, (n) => (n ? n : "Zero"))),
348
+ button("+", { on: { click: incrementCount } }),
349
+ ]);
350
+ }
351
+
352
+ document.body.appendChild(StateFromStateExample());
353
+ ```
354
+
355
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/8hsuc5pn/1/)
356
+ ```typescript
357
+ import { button, div, useState } from "tagu-tagu";
358
+
359
+ function TwoStatesFromStateExample() {
360
+ const count = useState(0);
361
+
362
+ function incrementCount() {
363
+ count.set(count.get() + 1);
364
+ }
365
+
366
+ return div([
367
+ div(
368
+ useState(count, (n) => (n ? n : "Zero")),
369
+ {
370
+ css: { color: useState(count, (n) => (n % 2 === 0 ? "blue" : "tan")) },
371
+ },
372
+ ),
373
+ button("+", { on: { click: incrementCount } }),
374
+ ]);
375
+ }
376
+
377
+ document.body.appendChild(TwoStatesFromStateExample());
378
+ ```
379
+
316
380
  ### `If`
317
- [JSFiddle](https://jsfiddle.net/do_the_simplest/bxuqsh1d/20/)
381
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/bxuqsh1d/21/)
318
382
 
319
383
  ```typescript
320
384
  import { div, If, input, span, useState } from "tagu-tagu";
@@ -329,6 +393,7 @@ function IfExample() {
329
393
  return div([
330
394
  input({
331
395
  attr: { type: "checkbox" },
396
+ prop: { checked: isVisible },
332
397
  on: { click: toggle },
333
398
  }),
334
399
  If(isVisible, () =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tagu-tagu",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "A lightweight helper for vanilla `HTMLElement`, with reactivity.",
5
5
  "keywords": [
6
6
  "front-end",