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
43
src/components/UiItems/index.js
Normal file
43
src/components/UiItems/index.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// @flow
|
||||
import Toggle from "./Toggle";
|
||||
import DropDown from "./DropDown";
|
||||
import Section from "./Section";
|
||||
import Link from "./Link";
|
||||
import Slider from "./Slider";
|
||||
import Text from "./Text";
|
||||
import Progress from "./Progress";
|
||||
|
||||
import type { ControlUI } from "config/flowtypes";
|
||||
|
||||
const Control = ({item}: {item: ControlUI}) => {
|
||||
switch (item.type) {
|
||||
case "toggle": {
|
||||
return Toggle.component(item);
|
||||
}
|
||||
case "dropDown": {
|
||||
return DropDown.component(item);
|
||||
}
|
||||
case "section": {
|
||||
return Section.component(item);
|
||||
}
|
||||
case "link": {
|
||||
return Link.component(item);
|
||||
}
|
||||
case "slider": {
|
||||
return Slider.component(item);
|
||||
}
|
||||
case "text": {
|
||||
return Text.component(item);
|
||||
}
|
||||
case "progress": {
|
||||
return Progress.component(item);
|
||||
}
|
||||
default: {
|
||||
throw new Error(
|
||||
`Unknown UI type "${item.type}" for "${item.text}" component`
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default Control;
|
||||
Loading…
Add table
Add a link
Reference in a new issue