2019-08-16 16:48:45 +02:00
|
|
|
<script>
|
|
|
|
|
|
|
|
import PropsView from "./PropsView.svelte";
|
|
|
|
import { store } from "../builderStore";
|
|
|
|
import { isRootComponent } from "./pagesParsing/searchComponents";
|
|
|
|
import IconButton from "../common/IconButton.svelte";
|
|
|
|
import Textbox from "../common/Textbox.svelte";
|
|
|
|
import UIkit from "uikit";
|
|
|
|
import { pipe } from "../common/core";
|
|
|
|
import {
|
2020-01-18 00:06:42 +01:00
|
|
|
getScreenInfo
|
2019-08-16 16:48:45 +02:00
|
|
|
} from "./pagesParsing/createProps";
|
|
|
|
import Button from "../common/Button.svelte";
|
|
|
|
import ButtonGroup from "../common/ButtonGroup.svelte";
|
2020-01-21 15:50:35 +01:00
|
|
|
import { LayoutIcon, PaintIcon, TerminalIcon } from '../common/Icons/';
|
2019-08-16 16:48:45 +02:00
|
|
|
|
2020-01-20 18:13:58 +01:00
|
|
|
import {
|
|
|
|
cloneDeep,
|
2019-08-16 16:48:45 +02:00
|
|
|
join,
|
|
|
|
split,
|
|
|
|
map,
|
|
|
|
keys,
|
|
|
|
isUndefined,
|
|
|
|
last
|
|
|
|
} from "lodash/fp";
|
|
|
|
import { assign } from "lodash";
|
|
|
|
|
|
|
|
let component;
|
|
|
|
let name = "";
|
|
|
|
let description = "";
|
|
|
|
let tagsString = "";
|
|
|
|
let nameInvalid = "";
|
|
|
|
let componentInfo;
|
|
|
|
let modalElement
|
|
|
|
let propsValidationErrors = [];
|
2019-10-03 07:12:13 +02:00
|
|
|
let originalName="";
|
2020-01-18 00:06:42 +01:00
|
|
|
let components;
|
2019-10-03 07:12:13 +02:00
|
|
|
let ignoreStore = false;
|
2019-08-19 09:51:01 +02:00
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
$: shortName = last(name.split("/"));
|
|
|
|
|
|
|
|
store.subscribe(s => {
|
2019-10-03 07:12:13 +02:00
|
|
|
if(ignoreStore) return;
|
2019-08-16 16:48:45 +02:00
|
|
|
component = s.currentFrontEndItem;
|
|
|
|
if(!component) return;
|
2019-10-03 07:12:13 +02:00
|
|
|
originalName = component.name;
|
2019-08-16 16:48:45 +02:00
|
|
|
name = component.name;
|
|
|
|
description = component.description;
|
|
|
|
tagsString = join(", ")(component.tags);
|
|
|
|
componentInfo = s.currentComponentInfo;
|
2020-01-18 00:06:42 +01:00
|
|
|
components = s.components;
|
2019-08-16 16:48:45 +02:00
|
|
|
});
|
|
|
|
|
2019-08-19 09:51:01 +02:00
|
|
|
const updateComponent = doChange => {
|
|
|
|
const newComponent = cloneDeep(component);
|
|
|
|
doChange(newComponent);
|
|
|
|
component = newComponent;
|
2020-01-18 00:06:42 +01:00
|
|
|
componentInfo = getScreenInfo(components, newComponent);
|
2019-08-19 09:51:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const onPropsChanged = newProps => {
|
2020-01-20 18:13:58 +01:00
|
|
|
updateComponent(newComponent =>
|
2019-08-19 09:51:01 +02:00
|
|
|
assign(newComponent.props, newProps));
|
2019-08-16 16:48:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="root">
|
|
|
|
|
2020-01-21 15:50:35 +01:00
|
|
|
<ul>
|
|
|
|
<li><button><PaintIcon /></button></li>
|
|
|
|
<li><button><LayoutIcon /></button></li>
|
|
|
|
<li><button><TerminalIcon /></button></li>
|
|
|
|
</ul>
|
2019-08-16 16:48:45 +02:00
|
|
|
|
2019-10-03 07:12:13 +02:00
|
|
|
<div class="component-props-container">
|
2019-08-16 16:48:45 +02:00
|
|
|
|
2020-01-20 18:13:58 +01:00
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
<PropsView
|
2019-08-16 16:48:45 +02:00
|
|
|
{componentInfo}
|
2020-01-18 00:06:42 +01:00
|
|
|
{onPropsChanged} />
|
2020-01-20 18:13:58 +01:00
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.root {
|
|
|
|
height: 100%;
|
2019-09-25 21:53:52 +02:00
|
|
|
display: flex;
|
2019-09-20 10:02:22 +02:00
|
|
|
flex-direction: column;
|
2020-01-20 18:13:58 +01:00
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
2020-01-18 00:06:42 +01:00
|
|
|
padding: 1rem;
|
2019-08-16 16:48:45 +02:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: [name] 1fr [actions] auto;
|
2019-09-25 21:53:52 +02:00
|
|
|
color: var(--secondary100);
|
|
|
|
font-size: .9rem;
|
|
|
|
font-weight: bold;
|
2019-08-16 16:48:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.title > div:nth-child(1) {
|
|
|
|
grid-column-start: name;
|
|
|
|
color: var(--secondary100);
|
|
|
|
}
|
|
|
|
|
|
|
|
.title > div:nth-child(2) {
|
|
|
|
grid-column-start: actions;
|
|
|
|
}
|
|
|
|
|
2019-09-20 10:02:22 +02:00
|
|
|
.component-props-container {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
ul {
|
|
|
|
list-style: none;
|
|
|
|
display: flex;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
li {
|
|
|
|
margin-right: 20px;
|
|
|
|
background: none;
|
|
|
|
border-radius: 5px;
|
|
|
|
width: 45px;
|
|
|
|
height: 45px;
|
|
|
|
}
|
|
|
|
|
|
|
|
li button {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
border-radius: 5px;
|
|
|
|
padding: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selected {
|
|
|
|
background: lightblue;
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:13:58 +01:00
|
|
|
</style>
|