Visual Console Refactor: WIP version of the label item

Former-commit-id: 8a8ef1b789442a566156e726edceb692911222b3
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-21 09:45:42 +01:00
parent 53d00d3c89
commit fa366590ce
1 changed files with 31 additions and 0 deletions

View File

@ -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");
}
}