element builder working with Van
This commit is contained in:
parent
1610f490e2
commit
a009f334eb
6
app.js
6
app.js
@ -12,4 +12,8 @@ const sheet = Styles({
|
||||
Outline:{border:"2px solid orange"}
|
||||
});
|
||||
|
||||
const el = sheet.dom.div.Button.Outline();
|
||||
const el = sheet.dom.a.Button.Outline({onclick(){console.log("clicked!")}}, "Click!");
|
||||
console.log(el);
|
||||
|
||||
|
||||
van.add(document.body, el, sheet.dom.p.Outline("paragraph!"));
|
@ -5,6 +5,6 @@
|
||||
"deno.window",
|
||||
"DOM"
|
||||
],
|
||||
"types": ["./drill.d.ts"]
|
||||
"types": ["./drill.d.ts", "./types.d.ts"]
|
||||
}
|
||||
}
|
7
drill.d.ts
vendored
7
drill.d.ts
vendored
@ -3,10 +3,9 @@ export {}
|
||||
declare global {
|
||||
namespace Gale
|
||||
{
|
||||
type Invoker =()=>HTMLElement
|
||||
type Elemental<T extends string> = {[K in keyof HTMLElementTagNameMap]: Circular<T>}
|
||||
type Circular<Keys extends string> = {
|
||||
[K in Keys]: Circular<Keys>&Invoker;
|
||||
type Elemental<T extends string> = {[K in keyof HTMLElementTagNameMap]: Circular<T, K>}
|
||||
type Circular<Keys extends string, ElementName extends keyof HTMLElementTagNameMap> = {
|
||||
[K in Keys]: Circular<Keys, ElementName>&Van.TagFunc<HTMLElementTagNameMap[ElementName]>;
|
||||
};
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://vanjs.org/code/van-1.5.3.nomodule.min.js"></script>
|
||||
<script type="module" src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -57,7 +57,12 @@ function MakeElemental(ref)
|
||||
let pending = false;
|
||||
let classes = [];
|
||||
|
||||
const collector = new Proxy(()=>{console.log("original func invoked!", pending, classes)},
|
||||
const collector = new Proxy((...args)=>{
|
||||
console.log("original func invoked!", pending, classes);
|
||||
const element = van.tags[pending](...args);
|
||||
element.className = classes.join(" ");
|
||||
return element
|
||||
},
|
||||
{
|
||||
get(target, prop, rec)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user