divulge working!
This commit is contained in:
parent
de5ae48d56
commit
7eb8688af1
64
main.ts
64
main.ts
@ -1,3 +1,4 @@
|
|||||||
|
// tss.ts
|
||||||
type PseudoKeys = ["hover"|"before"|"after"] | ["hover", "after"|"before"];
|
type PseudoKeys = ["hover"|"before"|"after"] | ["hover", "after"|"before"];
|
||||||
type ValueSignature = (...args:number[])=>void
|
type ValueSignature = (...args:number[])=>void
|
||||||
type EnumDefinition<Signature> = [property:string, options:Record<string, string>, values?:Signature];
|
type EnumDefinition<Signature> = [property:string, options:Record<string, string>, values?:Signature];
|
||||||
@ -95,21 +96,54 @@ const styles = Block(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const userDeclaredStyleBlock =
|
let masterSheet = [];
|
||||||
(styles()
|
export function Sheet<UserClasses extends Record<string, (CSS:ReturnType<typeof styles>)=>void >>(userClasses:UserClasses):{[Class in keyof UserClasses]:string}
|
||||||
.Pos.Abs
|
|
||||||
("hover", "after")
|
|
||||||
.Pos.Rel
|
|
||||||
.Left(20)
|
|
||||||
[512]
|
|
||||||
.Left(100))
|
|
||||||
|
|
||||||
|
|
||||||
// internal stringification
|
|
||||||
console.log(userDeclaredStyleBlock().join(""));
|
|
||||||
|
|
||||||
function Sheet<UserClasses extends Record<string, ReturnType<typeof styles>>>(userClasses:UserClasses):{[Class in keyof UserClasses]:string}
|
|
||||||
{
|
{
|
||||||
return new Proxy({}, {get(_target, className){}});
|
const hash = Math.floor(Math.random()*10000);
|
||||||
|
return new Proxy(function(){}, {get(_target, className){
|
||||||
|
console.log("sheet accessor", className);
|
||||||
|
const lookup = userClasses[className];
|
||||||
|
if(typeof lookup == "string")
|
||||||
|
{
|
||||||
|
return lookup;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const skewer = styles();
|
||||||
|
lookup(skewer);
|
||||||
|
const name = `.${className}_${hash}`;
|
||||||
|
masterSheet.push( `${name}{ ${skewer().join("")} }` );
|
||||||
|
userClasses[className] = name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function Divulge()
|
||||||
|
{
|
||||||
|
return masterSheet.join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////// testing: ////////
|
||||||
|
|
||||||
|
const sheet = Sheet({
|
||||||
|
SpecialLink(styles)
|
||||||
|
{
|
||||||
|
styles
|
||||||
|
.Pos.Abs
|
||||||
|
("hover","after")
|
||||||
|
.Pos.Rel
|
||||||
|
.Left(20)
|
||||||
|
[512]
|
||||||
|
.Left(100)
|
||||||
|
},
|
||||||
|
Profile(styles)
|
||||||
|
{
|
||||||
|
styles.Display.Block
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const el1 = [sheet.Profile, sheet.SpecialLink];
|
||||||
|
|
||||||
|
console.log(Divulge());
|
||||||
Loading…
Reference in New Issue
Block a user