tagu-tagu 3.2.3 → 3.2.5

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 +182 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -54,6 +54,7 @@ button({css: {background: "blue"}}, "Hello!");
54
54
 
55
55
  #### Modify existing element
56
56
  You can use initializers for existing element.
57
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/o87nw6zL/15/)
57
58
 
58
59
  ```typescript
59
60
  import { Modify } from "tagu-tagu";
@@ -72,7 +73,185 @@ Modify(document.body, {
72
73
 
73
74
  ```
74
75
 
76
+ #### `html` initializer
77
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/6p9jh45L/2/)
78
+ ```typescript
79
+ import { div } from "tagu-tagu";
80
+
81
+ // Element: innerHTML
82
+ function HtmlExample() {
83
+ return div({ html: `<button>Hello World!</button>` });
84
+ }
85
+
86
+ document.body.appendChild(HtmlExample());
87
+
88
+ ```
89
+
90
+ #### `css` initializer
91
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/mfLutvnc/1/)
92
+
93
+ ```typescript
94
+ import { button } from "tagu-tagu";
95
+
96
+ // element.style.setProperty
97
+ function CssExample() {
98
+ return button({
99
+ css: { width: "300px", height: "300px" },
100
+ });
101
+ }
102
+
103
+ document.body.appendChild(CssExample());
104
+ ```
105
+
106
+ #### `attr` initializer
107
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/r8a423pw/1/)
108
+
109
+ ```typescript
110
+ import { input } from "tagu-tagu";
111
+
112
+ // Element: setAttribute
113
+ function AttrExample() {
114
+ return input({
115
+ attr: { type: "color" },
116
+ });
117
+ }
118
+
119
+ document.body.appendChild(AttrExample());
120
+ ```
121
+
122
+ #### `prop` initializer
123
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/mc38ksqw/1/)
124
+
125
+ ```typescript
126
+ import { option, select } from "tagu-tagu";
127
+
128
+ // Element: setAttribute
129
+ function AttrExample() {
130
+ return select([option("One"), option("Two"), option("Three")], {
131
+ prop: { selectedIndex: 1 },
132
+ });
133
+ }
134
+
135
+ document.body.appendChild(AttrExample());
136
+ ```
137
+
138
+ #### `on` initializer
139
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/Lsjmw263/)
140
+ ```typescript
141
+ import { button } from "tagu-tagu";
142
+
143
+ // Element: addEventListener
144
+ function OnExample() {
145
+ return button("Click Me", { on: { click: () => alert("Hello!") } });
146
+ }
147
+
148
+ document.body.appendChild(OnExample());
149
+ ```
150
+
151
+ #### `$` initializer
152
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/b8roj7wx/1/)
153
+ ```html
154
+ <form>
155
+ <div>Name: <input id="name"></div>
156
+ <div>Age: <input id="age"></div>
157
+ <button id="submit">Submit</button>
158
+ </form>
159
+ <script type="module" src="index.ts"></script>
160
+ ```
161
+ ```typescript
162
+ import { Modify, style } from "tagu-tagu";
163
+
164
+ // Element: querySelector
165
+ function $Example() {
166
+ Modify("form", {
167
+ $: {
168
+ "#name": { prop: { defaultValue: "Einstein" } },
169
+ "#age": { attr: { type: "number" }, prop: { defaultValue: 26 } },
170
+ "#submit": [
171
+ style({
172
+ "#submit": {
173
+ background: "blue",
174
+ color: "white",
175
+ border: "none",
176
+ "border-radius": "10px",
177
+ },
178
+ "#submit:hover": {
179
+ background: "skyblue",
180
+ },
181
+ }),
182
+ ],
183
+ },
184
+ });
185
+ }
186
+
187
+ $Example();
188
+ ```
189
+
190
+ #### `$$` initializer
191
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/gqe5378t/1/)
192
+ ```html
193
+ <meta charset="utf-8">
194
+ <div>
195
+ <h1>Unfertilized Eggs</h1>
196
+ <button>🥚</button>
197
+ <button>🥚</button>
198
+ <button>🥚</button>
199
+ <button>🥚</button>
200
+ <button>🥚</button>
201
+ </div>
202
+ <div id="fertilized">
203
+ <h1>Click!</h1>
204
+ <button>🥚</button>
205
+ <button>🥚</button>
206
+ <button>🥚</button>
207
+ <button>🥚</button>
208
+ <button>🥚</button>
209
+ </div>
210
+ <script type="module" src="index.ts"></script>
211
+ ```
212
+ ```typescript
213
+ import { Modify } from "tagu-tagu";
214
+
215
+ // Element: querySelectorAll
216
+ function $$Example() {
217
+ Modify("#fertilized", {
218
+ $$: {
219
+ button: {
220
+ on: {
221
+ click: (e) => {
222
+ (e.target as HTMLButtonElement).textContent = "🐣";
223
+ },
224
+ },
225
+ },
226
+ },
227
+ });
228
+ }
229
+
230
+ $$Example();
231
+ ```
232
+
233
+ #### Callback initializer
234
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/tfj8uqa7/3/)
235
+ ```typescript
236
+ import { button, div } from "tagu-tagu";
237
+
238
+ function InitializerCallbackExample() {
239
+ return div([
240
+ div([
241
+ div([
242
+ button("Deep", (button) =>
243
+ console.log("debug:", button, "is created!"),
244
+ ),
245
+ ]),
246
+ ]),
247
+ ]);
248
+ }
249
+
250
+ document.body.appendChild(InitializerCallbackExample());
251
+ ```
252
+
75
253
  ### `If`
254
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/bxuqsh1d/19/)
76
255
 
77
256
  ```typescript
78
257
  import { div, If, input, span, useState } from "tagu-tagu";
@@ -103,6 +282,7 @@ document.body.appendChild(IfExample());
103
282
  ```
104
283
 
105
284
  ### `Switch`
285
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/vw8hrz1t/14/)
106
286
 
107
287
  ```typescript
108
288
  import { button, div, Switch, useState } from "tagu-tagu";
@@ -132,6 +312,7 @@ document.body.appendChild(SwitchExample());
132
312
  ```
133
313
 
134
314
  ### `For`
315
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/soLa9v6t/12/)
135
316
 
136
317
  ```typescript
137
318
  import { button, div, For, useState } from "tagu-tagu";
@@ -166,6 +347,7 @@ document.body.appendChild(ForExample());
166
347
 
167
348
  ### Data binding
168
349
  You can use data of ancestors.
350
+ [JSFiddle](https://jsfiddle.net/do_the_simplest/9u6oz2bc/6/)
169
351
 
170
352
  ```typescript
171
353
  import { button, div, useBinding, useState } from "tagu-tagu";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tagu-tagu",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "description": "A lightweight helper for vanilla `HTMLElement`, with reactivity.",
5
5
  "keywords": [
6
6
  "front-end",