-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13bd794
commit 2782c6c
Showing
13 changed files
with
172 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./uiNode" | ||
export * from "./uiStyle" | ||
export * from "./uiText" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import { Component } from "../../component" | ||
|
||
export class UiNode extends Component {} | ||
export class UiNode {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export class UiStyle { | ||
public readonly cssObject: CSSStyleDeclaration | ||
|
||
constructor() { | ||
this.cssObject = document.createElement("div").style | ||
} | ||
|
||
public get css(): string { | ||
return this.cssObject.cssText | ||
} | ||
|
||
public set<K extends keyof CSSStyleDeclaration>(key: K, value: CSSStyleDeclaration[K]): this { | ||
this.cssObject[key] = value | ||
return this | ||
} | ||
|
||
public get<K extends keyof CSSStyleDeclaration>(key: K): CSSStyleDeclaration[K] { | ||
return this.cssObject[key] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import { Component } from "../../component" | ||
|
||
export class UiText extends Component { | ||
export class UiText { | ||
public value: string | ||
|
||
constructor(value: string) { | ||
super() | ||
this.value = value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
export abstract class Component { | ||
public componentId(): string { | ||
return this.constructor.name | ||
} | ||
} | ||
export type Component = Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export type Ident = symbol | ||
|
||
const __identifier__ = Symbol("__identifier__") | ||
|
||
export function identify<T extends Object>(o: T | (new (...arg: any[]) => T)): Ident { | ||
if (o instanceof Function) { | ||
return Symbol.for(String(o)) | ||
} | ||
if (__identifier__ in o) { | ||
return o[__identifier__] as Ident | ||
} | ||
|
||
if (o.constructor.name !== "Object") { | ||
// @ts-ignore | ||
return (o[__identifier__] = Symbol.for(String(o.constructor))) | ||
} else { | ||
console.warn("please use classes for components and resources") | ||
|
||
// all objects are considered the same use content to differentiate | ||
// @ts-ignore | ||
return (o[__identifier__] = Symbol.for(JSON.stringify(Object.keys(o).sort()))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.