This repository was archived by the owner on Jan 9, 2026. It is now read-only.
forked from jaandrle/dollar_dom_component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_p1.sub.html
More file actions
31 lines (26 loc) · 1.52 KB
/
example_p1.sub.html
File metadata and controls
31 lines (26 loc) · 1.52 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
gulp_place("app._BUILD_.example_el= toELID(app._BUILD_.example_el_id++)", "eval");
gulp_place("app._BUILD_.example_onkeyup= toKeyUp(app._BUILD_.example_el)", "eval");
<p>You can define reactive behaviour:</p>
<div class="output" id="gulp_place('app._BUILD_.example_el', 'variable')"></div>
<script onkeyup="gulp_place('app._BUILD_.example_onkeyup', 'variable')" contenteditable="">
(function(element_id){
//EXAMPLE START
const container= document.getElementById(element_id);
textInputComponent({ label_type: "name", placeholder: "Peter" }).mount(container);
textInputComponent({ label_type: "surname", placeholder: "Black" }).mount(container);
function textInputComponent(params){
const label_type= params.label_type || "name";
const default_listener_value= { listen_variable_name: " - " };
const c= $dom.component("DIV");
c.add("LABEL", { textContent: `Type your ${label_type}: ` });
c.add("INPUT", { type: "text", placeholder: params.placeholder, onkeyup: onkeyupHandler });
c.add("P", { textContent: `Your ${label_type} is: ` }, -2);
c.add("STRONG", null).onupdate(default_listener_value, onUpdateHandler);
return c.share;
function onkeyupHandler(){ c.update({ listen_variable_name: this.value }); }
function onUpdateHandler({ listen_variable_name }){ return { textContent: listen_variable_name }; }
}
//EXAMPLE END
})("gulp_place('app._BUILD_.example_el', 'variable')");
</script>
<!-- example source links -->