feat: moved css to html file, updated readme

This commit is contained in:
Daniel Ledda
2022-05-28 13:23:25 +02:00
parent e5e0c47f68
commit db4a332990
8 changed files with 535 additions and 48 deletions

View File

@@ -14,10 +14,6 @@ export default abstract class Rung {
return this.node;
}
protected getEl(): Node {
return this.render();
}
redraw(): void {
const oldNode = this.node;
if (!oldNode || !this.node) {

View File

@@ -24,13 +24,17 @@ export function bootstrap(app: Rung, id: string) {
}
}
export function frag(attributes: IRenderAttributes<DocumentFragment> | null, subs?: SubNode[]): DocumentFragment {
export function frag(attributes: IRenderAttributes<DocumentFragment> | null, ...subs: SubNode[]): DocumentFragment {
const frag = document.createDocumentFragment();
if (attributes) {
applyAttributes(frag, attributes);
}
if (subs) {
attachSubs(frag, subs);
if (Array.isArray(subs[0])) {
attachSubs(frag, subs[0]);
} else {
attachSubs(frag, subs);
}
}
return frag;
}
@@ -50,7 +54,7 @@ type Props<T> =
? CommonRenderAttributes<T>
: never;
export type SubNode = Rung | Node | ICapsule;
export type SubNode = Rung | Node | ICapsule | string;
export function h<T extends keyof HTMLElementTagNameMap>(type: T, attributes?: Props<T>, ...subNodes: SubNode[]): HTMLElementTagNameMap[T];
export function h<T extends FunctionalRung<any, any>, U extends Props<T>>(type: T, attributes?: U, ...subNodes: SubNode[]): ReturnType<T>;