initial commit (it all starts here...)

This commit is contained in:
M. George Hansen 2020-05-25 22:36:20 -07:00
commit 13cbc07c11
36 changed files with 4550 additions and 0 deletions

39
src/component.ts Normal file
View file

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/**
* An in-memory representation of a renderable HTML element.
*/
export interface HTMLElement {
/**
* Name of the tag that gets output upon rendering.
*/
tag: string;
/**
* Record of attribute names and values that should be output in the opening
* tag.
*/
attributes: Record<string, string | number | boolean>;
/**
* Child elements to render nested within this HTML element.
*/
children: Element[];
}
/**
* All valid types of elements that can be rendered to HTML.
*/
export type Element = HTMLElement | string | boolean | undefined | null;
/**
* Custom HTMLElement factory that can be parameterized by props.
*/
export interface Component<P extends object = {}> {
(
props: P & {
children?: Element[];
}
): HTMLElement;
}