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:
parent
62ad9db5f0
commit
0a027fd7c2
14 changed files with 461 additions and 371 deletions
32
src/components/UiItemList.js
Normal file
32
src/components/UiItemList.js
Normal 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>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue