Visual Console Refactor: WIP version of the label item
Former-commit-id: 8a8ef1b789442a566156e726edceb692911222b3
This commit is contained in:
parent
53d00d3c89
commit
fa366590ce
|
@ -0,0 +1,31 @@
|
||||||
|
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
|
||||||
|
import { linkedVCPropsDecoder } from "../lib";
|
||||||
|
import Item, { ItemType, ItemProps, itemBasePropsDecoder } from "../Item";
|
||||||
|
|
||||||
|
export type LabelProps = {
|
||||||
|
type: ItemType.LABEL;
|
||||||
|
} & ItemProps &
|
||||||
|
LinkedVisualConsoleProps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a valid typed object from a raw object.
|
||||||
|
* This will allow us to ensure the type safety.
|
||||||
|
*
|
||||||
|
* @param data Raw object.
|
||||||
|
* @return An object representing the label props.
|
||||||
|
* @throws Will throw a TypeError if some property
|
||||||
|
* is missing from the raw object or have an invalid type.
|
||||||
|
*/
|
||||||
|
export function labelPropsDecoder(data: UnknownObject): LabelProps | never {
|
||||||
|
return {
|
||||||
|
...itemBasePropsDecoder(data), // Object spread. It will merge the properties of the two objects.
|
||||||
|
type: ItemType.LABEL,
|
||||||
|
...linkedVCPropsDecoder(data) // Object spread. It will merge the properties of the two objects.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Label extends Item<LabelProps> {
|
||||||
|
public createDomElement(): HTMLElement {
|
||||||
|
throw new Error("not implemented");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue