Completely rewrite the UI Components

to a new functional way of defining them with advantages towards generating docs and a potential editor functionality
This commit is contained in:
uwap 2018-11-10 01:34:31 +01:00
parent 62ad9db5f0
commit 0a027fd7c2
14 changed files with 461 additions and 371 deletions

View file

@ -0,0 +1,32 @@
// @flow
import * as React from "react";
import ListItem from "@material-ui/core/ListItem";
import type { ControlUI } from "config/flowtypes";
import UiItem from "components/UiItems";
export type UiItemListProps = {
controls: Array<ControlUI>
};
export default function UiItemList(props: UiItemListProps): React.Node {
return props.controls.map((control, key) => {
if (control.type == null) {
throw new Error(
"A control is missing the \"type\" parameter"
);
}
if (control.type === "section") {
return (
<UiItem item={control} />
);
}
return (
<ListItem key={key}>
<UiItem item={control} />
</ListItem>
);
});
}