2024-05-22 21:43:49 +02:00
|
|
|
import { style, el, elNS, on, S, scope } 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-10 10:55:00 +02:00
|
|
|
export function fullNameComponent(){
|
2023-09-05 09:25:47 +02:00
|
|
|
const labels= [ "Name", "Surname" ];
|
2024-05-22 21:43:49 +02:00
|
|
|
const name= labels.map(_=> S(""));
|
|
|
|
const full_name= S(()=>
|
2023-09-05 09:25:47 +02:00
|
|
|
name.map(l=> l()).filter(Boolean).join(" ") || "-");
|
2023-11-17 14:48:11 +01:00
|
|
|
scope.host(
|
|
|
|
on.connected(()=> console.log(fullNameComponent)),
|
|
|
|
on.disconnected(()=> console.log(fullNameComponent))
|
|
|
|
);
|
2023-09-05 09:25:47 +02:00
|
|
|
|
2024-11-22 16:26:42 +01:00
|
|
|
const style= { height: "80px", display: "block", fill: "currentColor" };
|
2023-11-08 13:44:37 +01:00
|
|
|
const elSVG= elNS("http://www.w3.org/2000/svg");
|
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
|
|
|
),
|
2024-11-22 16:26:42 +01:00
|
|
|
elSVG("svg", { viewBox: "0 0 240 80", style }).append(
|
2023-11-08 13:44:37 +01:00
|
|
|
//elSVG("style", { })
|
2023-12-22 16:49:59 +01:00
|
|
|
elSVG("text", { x: 20, y: 35, textContent: "Text" }),
|
2023-09-05 09:25:47 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|