mirror of
https://github.com/MercuryWorkshop/dreamlandjs.git
synced 2025-05-15 23:20:01 -04:00
new functional component syntax
This commit is contained in:
parent
fcc411d842
commit
2dcae6ad11
2 changed files with 20 additions and 9 deletions
25
AliceJS.d.ts
vendored
25
AliceJS.d.ts
vendored
|
@ -1,5 +1,7 @@
|
||||||
declare namespace JSX {
|
declare namespace JSX {
|
||||||
export type IntrinsicElements = { [index: string]: any };
|
export type IntrinsicElements = {
|
||||||
|
[index: string]: any
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function h(
|
declare function h(
|
||||||
|
@ -26,19 +28,28 @@ declare var styled: { new: typeof css, rule: typeof rule };
|
||||||
|
|
||||||
type DLCSS = string;
|
type DLCSS = string;
|
||||||
|
|
||||||
|
declare var $el: HTMLElement;
|
||||||
|
|
||||||
interface Element {
|
interface Element {
|
||||||
$: DLComponent<any>
|
$: OuterComponentTypes & { [index: string | symbol]: any }
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DLElement<T> extends Element {
|
interface DLElement<T> extends Element {
|
||||||
$: T
|
$: T & OuterComponentTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var $el: HTMLElement;
|
type ComponentElement<T extends (...args: any) => any> = DLElement<ReturnType<T>>;
|
||||||
|
|
||||||
type DLComponent<T> = {
|
type OuterComponentTypes = {
|
||||||
css: DLCSS,
|
|
||||||
root: Element,
|
root: Element,
|
||||||
children: Element[],
|
children: Element[],
|
||||||
|
}
|
||||||
|
type InnerComponentTypes = {
|
||||||
|
css: DLCSS,
|
||||||
mount?: () => void,
|
mount?: () => void,
|
||||||
} & T;
|
}
|
||||||
|
type ComponentTypes = OuterComponentTypes & InnerComponentTypes;
|
||||||
|
|
||||||
|
type Component<Public, Private> = ((this: Public & Private & ComponentTypes, _props: Public) => DLElement<Public>);
|
||||||
|
|
||||||
|
|
||||||
|
|
4
css.js
4
css.js
|
@ -20,10 +20,10 @@ function scopify_css(uid, css) {
|
||||||
return cssParsed;
|
return cssParsed;
|
||||||
}
|
}
|
||||||
function tagcss(strings, values, isblock) {
|
function tagcss(strings, values, isblock) {
|
||||||
const uid = `dream-${Array(16)
|
const uid = `dl${Array(5)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
.map(() => {
|
.map(() => {
|
||||||
return Math.floor(Math.random() * 16).toString(16);
|
return Math.floor(Math.random() * 36).toString(36);
|
||||||
})
|
})
|
||||||
.join("")}`;
|
.join("")}`;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue