2020-01-21 15:50:35 +01: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 { pipe } from "../common/core";
|
|
|
|
import {
|
|
|
|
getScreenInfo
|
|
|
|
} from "./pagesParsing/createProps";
|
|
|
|
import { LayoutIcon, PaintIcon, TerminalIcon } from '../common/Icons/';
|
|
|
|
import CodeEditor from './CodeEditor.svelte';
|
2020-01-22 12:21:42 +01:00
|
|
|
import LayoutEditor from './LayoutEditor.svelte';
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
import {
|
|
|
|
cloneDeep,
|
|
|
|
join,
|
|
|
|
split,
|
|
|
|
map,
|
|
|
|
keys,
|
|
|
|
isUndefined,
|
|
|
|
last
|
|
|
|
} from "lodash/fp";
|
|
|
|
import { assign } from "lodash";
|
|
|
|
|
|
|
|
let component;
|
|
|
|
let name = "";
|
|
|
|
let description = "";
|
|
|
|
let tagsString = "";
|
|
|
|
let nameInvalid = "";
|
2020-01-24 15:30:17 +01:00
|
|
|
let componentInfo = {};
|
2020-01-21 15:50:35 +01:00
|
|
|
let modalElement
|
|
|
|
let propsValidationErrors = [];
|
|
|
|
let originalName="";
|
|
|
|
let components;
|
|
|
|
let ignoreStore = false;
|
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
// $: shortName = last(name.split("/"));
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
store.subscribe(s => {
|
|
|
|
if(ignoreStore) return;
|
2020-01-24 15:30:17 +01:00
|
|
|
component = s.currentComponentInfo;
|
2020-01-21 15:50:35 +01:00
|
|
|
if(!component) return;
|
|
|
|
originalName = component.name;
|
|
|
|
name = component.name;
|
|
|
|
description = component.description;
|
|
|
|
tagsString = join(", ")(component.tags);
|
|
|
|
componentInfo = s.currentComponentInfo;
|
|
|
|
components = s.components;
|
|
|
|
});
|
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
const onPropsChanged = store.updateComponentProp;
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
let current_view = 'props';
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="root">
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<button class:selected={current_view === 'props'} on:click={() => current_view = 'props'}>
|
|
|
|
<PaintIcon />
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button class:selected={current_view === 'layout'} on:click={() => current_view = 'layout'}>
|
|
|
|
<LayoutIcon />
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button class:selected={current_view === 'code'} on:click={() => current_view = 'code'}>
|
|
|
|
<TerminalIcon />
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
{#if !componentInfo.component}
|
|
|
|
<div class="component-props-container">
|
2020-01-21 15:50:35 +01:00
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
{#if current_view === 'props'}
|
|
|
|
<PropsView {componentInfo} {components} {onPropsChanged} />
|
|
|
|
{:else if current_view === 'layout'}
|
|
|
|
<LayoutEditor />
|
|
|
|
{:else}
|
|
|
|
<CodeEditor />
|
|
|
|
{/if}
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
</div>
|
2020-01-24 15:30:17 +01:00
|
|
|
{:else}
|
|
|
|
<h1> This is a screen, this will be dealt with later</h1>
|
|
|
|
{/if}
|
2020-01-21 15:50:35 +01:00
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
</div>
|
2020-01-21 15:50:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.root {
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.title > div:nth-child(1) {
|
|
|
|
grid-column-start: name;
|
|
|
|
color: var(--secondary100);
|
|
|
|
}
|
|
|
|
|
|
|
|
.title > div:nth-child(2) {
|
|
|
|
grid-column-start: actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
.component-props-container {
|
|
|
|
margin-top: 10px;
|
|
|
|
flex: 1 1 auto;
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
ul {
|
|
|
|
list-style: none;
|
|
|
|
display: flex;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
li {
|
|
|
|
margin-right: 20px;
|
|
|
|
background: none;
|
|
|
|
border-radius: 5px;
|
2020-01-22 12:30:19 +01:00
|
|
|
width: 48px;
|
|
|
|
height: 48px;
|
2020-01-21 15:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
li button {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
border-radius: 5px;
|
|
|
|
padding: 12px;
|
|
|
|
outline: none;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selected {
|
|
|
|
color: var(--button-text);
|
|
|
|
background: var(--background-button)!important;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|