TypeScript!

This commit is contained in:
Zaid Abdulla committed 2019-02-20 03:36:52 -08:00
1 parent ee8c43747e
commit 5d3c81cb23
105 files changed
+12054 -1901

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { ClosureComponent, Component } from "mithril";
import { m } from "../components";
const component: ClosureComponent = (): Component => {
return {
view: vnode => {
let deviceId;
if (vnode.attrs["device"])
deviceId = vnode.attrs["device"]["DeviceID.ID"].value[0];
const children = Object.values(vnode.attrs["components"]).map(c => {
if (typeof c !== "object") return `${c}`;
const attrs = Object.assign({}, vnode.attrs, c);
return m(attrs["type"], attrs);
});
if (deviceId) {
return m(
"a",
{ href: `#!/devices/${encodeURIComponent(deviceId)}` },
children
);
} else {
return children;
}
}
};
};
export default component;