2020-01-21 15:50:35 +01:00
|
|
|
<script>
|
2020-02-03 10:50:30 +01:00
|
|
|
import PropsView from "./PropsView.svelte"
|
2020-02-26 10:43:38 +01:00
|
|
|
import StateBindingControl from "./StateBindingControl.svelte"
|
2020-03-31 13:16:03 +02:00
|
|
|
import { store } from "builderStore"
|
|
|
|
import IconButton from "components/common/IconButton.svelte"
|
2020-02-03 10:50:30 +01:00
|
|
|
import {
|
|
|
|
LayoutIcon,
|
|
|
|
PaintIcon,
|
|
|
|
TerminalIcon,
|
|
|
|
CircleIndicator,
|
|
|
|
EventsIcon,
|
2020-03-31 13:16:03 +02:00
|
|
|
} from "components/common/Icons/"
|
2020-02-03 10:50:30 +01:00
|
|
|
import CodeEditor from "./CodeEditor.svelte"
|
|
|
|
import LayoutEditor from "./LayoutEditor.svelte"
|
|
|
|
import EventsEditor from "./EventsEditor"
|
|
|
|
|
2020-05-04 17:07:04 +02:00
|
|
|
import panelStructure from "./temporaryPanelStructure.js"
|
|
|
|
import CategoryTab from "./CategoryTab.svelte"
|
|
|
|
import DesignView from "./DesignView.svelte"
|
|
|
|
|
|
|
|
let current_view = "design"
|
2020-02-03 10:50:30 +01:00
|
|
|
let codeEditor
|
2020-05-04 17:07:04 +02:00
|
|
|
let flattenedPanel = flattenComponents(panelStructure.categories)
|
|
|
|
let categories = [
|
|
|
|
{ name: "Design" },
|
|
|
|
{ name: "Settings" },
|
|
|
|
{ name: "Actions" },
|
|
|
|
]
|
|
|
|
let selectedCategory = categories[0]
|
2020-02-03 10:50:30 +01:00
|
|
|
|
|
|
|
$: components = $store.components
|
2020-05-04 17:07:04 +02:00
|
|
|
$: componentInstance = $store.currentComponentInfo //contains prop values of currently selected component
|
|
|
|
$: componentDefinition = $store.components.find(
|
|
|
|
c => c.name === componentInstance._component
|
|
|
|
)
|
|
|
|
|
|
|
|
$: panelDefinition = flattenedPanel.find(
|
|
|
|
//use for getting controls for each component property
|
|
|
|
c => c._component === componentInstance._component
|
|
|
|
)
|
|
|
|
|
|
|
|
// OLD PROPS =============================================
|
|
|
|
|
2020-02-26 10:43:38 +01:00
|
|
|
$: screen_props =
|
|
|
|
$store.currentFrontEndType === "page"
|
|
|
|
? getProps($store.currentPreviewItem, ["name", "favicon"])
|
2020-02-27 22:34:52 +01:00
|
|
|
: getProps($store.currentPreviewItem, ["name", "description", "route"])
|
2020-03-06 18:00:54 +01:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
const onPropChanged = store.setComponentProp
|
|
|
|
const onStyleChanged = store.setComponentStyle
|
2020-02-26 10:43:38 +01:00
|
|
|
|
2020-05-04 17:07:04 +02:00
|
|
|
function walkProps(component, action) {
|
|
|
|
action(component)
|
|
|
|
if (component.children) {
|
|
|
|
for (let child of component.children) {
|
|
|
|
walkProps(child, action)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function flattenComponents(props) {
|
|
|
|
const components = []
|
|
|
|
props.forEach(comp =>
|
|
|
|
walkProps(comp, c => {
|
|
|
|
if ("_component" in c) {
|
|
|
|
components.push(c)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
return components
|
|
|
|
}
|
|
|
|
|
2020-02-26 10:43:38 +01:00
|
|
|
function getProps(obj, keys) {
|
|
|
|
return keys.map((k, i) => [k, obj[k], obj.props._id + i])
|
|
|
|
}
|
2020-01-21 15:50:35 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="root">
|
2020-02-10 16:51:09 +01:00
|
|
|
|
2020-05-04 17:07:04 +02:00
|
|
|
<CategoryTab
|
|
|
|
onClick={category => (selectedCategory = category)}
|
|
|
|
{categories}
|
|
|
|
{selectedCategory} />
|
2020-02-10 16:51:09 +01:00
|
|
|
|
2020-05-04 17:07:04 +02:00
|
|
|
<div class="component-props-container">
|
|
|
|
{#if current_view === 'design'}
|
2020-05-05 15:45:52 +02:00
|
|
|
<DesignView
|
|
|
|
{panelDefinition}
|
|
|
|
{componentInstance}
|
|
|
|
{componentDefinition}
|
|
|
|
{onPropChanged} />
|
2020-05-04 17:07:04 +02:00
|
|
|
{/if}
|
2020-02-10 16:51:09 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
</div>
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
<style>
|
2020-02-03 10:50:30 +01:00
|
|
|
.root {
|
2020-01-21 15:50:35 +01:00
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2020-05-07 15:30:04 +02:00
|
|
|
overflow-x: hidden;
|
2020-02-03 10:50:30 +01:00
|
|
|
}
|
2020-01-21 15:50:35 +01:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
.title > div:nth-child(1) {
|
2020-01-21 15:50:35 +01:00
|
|
|
grid-column-start: name;
|
|
|
|
color: var(--secondary100);
|
2020-02-03 10:50:30 +01:00
|
|
|
}
|
2020-01-21 15:50:35 +01:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
.title > div:nth-child(2) {
|
2020-01-21 15:50:35 +01:00
|
|
|
grid-column-start: actions;
|
2020-02-03 10:50:30 +01:00
|
|
|
}
|
2020-01-21 15:50:35 +01:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
.component-props-container {
|
|
|
|
margin-top: 10px;
|
2020-01-21 15:50:35 +01:00
|
|
|
flex: 1 1 auto;
|
2020-02-03 10:50:30 +01:00
|
|
|
}
|
2020-01-21 15:50:35 +01:00
|
|
|
</style>
|