2023-10-09 13:49:38 +02:00
|
|
|
import { style, el, on, S } from '../exports.js';
|
2023-09-05 09:25:47 +02:00
|
|
|
const className= style.host(fullNameComponent).css`
|
|
|
|
:host form{
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column nowrap;
|
|
|
|
}
|
|
|
|
`;
|
2023-10-09 13:49:38 +02:00
|
|
|
export function fullNameComponent(_, scope){
|
2023-09-05 09:25:47 +02:00
|
|
|
const labels= [ "Name", "Surname" ];
|
|
|
|
const name= labels.map(_=> S(""));
|
|
|
|
const full_name= S(()=>
|
|
|
|
name.map(l=> l()).filter(Boolean).join(" ") || "-");
|
2023-10-09 13:49:38 +02:00
|
|
|
scope(on.connected(()=> console.log(fullNameComponent)));
|
|
|
|
scope(on.disconnected(()=> console.log(fullNameComponent)))
|
2023-09-05 09:25:47 +02:00
|
|
|
|
|
|
|
return el("div", { className }).append(
|
|
|
|
el("h2", "Simple form:"),
|
|
|
|
el("form", { onsubmit: ev=> ev.preventDefault() }).append(
|
|
|
|
...name.map((v, i)=>
|
|
|
|
el("label", labels[i]).append(
|
|
|
|
el("input", { type: "text", name: labels[i], value: v() }, on("change", ev=> v(ev.target.value)))
|
|
|
|
))
|
|
|
|
),
|
|
|
|
el("p").append(
|
|
|
|
el("strong", "Full name"),
|
2023-09-21 12:35:27 +02:00
|
|
|
": ",
|
2023-09-05 09:25:47 +02:00
|
|
|
el("#text", full_name)
|
2023-09-26 09:40:00 +02:00
|
|
|
),
|
2023-10-09 13:49:38 +02:00
|
|
|
scope.elNamespace("svg").append(
|
2023-09-26 09:40:00 +02:00
|
|
|
el("svg", { viewBox: "0 0 240 80", style: { height: "80px", display: "block" } }).append(
|
|
|
|
//el("style", { })
|
|
|
|
el("text", { x: 20, y: 35, textContent: "Text" })
|
|
|
|
)
|
2023-09-05 09:25:47 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|