48 builder frontend 2 (#70)

* Implement collapsing component hierarchy.

* Save screen when adding new components.

* Allow creation of nested child components.

* Fix level-based indentation of hierarchy.

* Rename updateComponentProps to setComponentProps

* Save layout information to the disk.

* Cleanup: switch to autosubscriptions to prevent memory leaks, remove unused imports.

* Remove unused css.

* Fix incorrect subscription.
This commit is contained in:
pngwn 2020-01-28 21:17:04 +00:00 committed by Michael Shanks
parent 6cb523478d
commit 6aa6c4d433
24 changed files with 1022 additions and 1208 deletions

View File

@ -4,7 +4,7 @@ import {
import {
filter, cloneDeep, sortBy,
map, last, keys, concat, keyBy,
find, isEmpty, reduce, values
find, isEmpty, reduce, values, isEqual
} from "lodash/fp";
import {
pipe, getNode, validate,
@ -93,8 +93,8 @@ export const getStore = () => {
store.createGeneratedComponents = createGeneratedComponents(store);
store.addChildComponent = addChildComponent(store);
store.selectComponent = selectComponent(store);
store.updateComponentProp = updateComponentProp(store);
store.setComponentProp = setComponentProp(store);
store.setComponentStyle = setComponentStyle(store);
return store;
}
@ -456,6 +456,10 @@ const _saveScreen = (store, s, screen) => {
return s;
}
const _save = (appname, screen, store, s) =>
api.post(`/_builder/api/${appname}/screen`, screen)
.then(() => savePackage(store, s));
const createScreen = store => (screenName, layoutComponentName) => {
store.update(s => {
const newComponentInfo = getNewComponentInfo(
@ -597,8 +601,6 @@ const addComponentLibrary = store => async lib => {
return s;
})
}
const removeComponentLibrary = store => lib => {
@ -701,17 +703,31 @@ const addChildComponent = store => component => {
const newComponent = getNewComponentInfo(
s.components, component);
const children = s.currentFrontEndItem.props._children;
let children = s.currentComponentInfo.component ?
s.currentComponentInfo.component.props._children :
s.currentComponentInfo._children;
const component_definition = Object.assign(
cloneDeep(newComponent.fullProps), {
_component: component,
_layout: {}
})
s.currentFrontEndItem.props._children =
children ?
children.concat(component_definition) :
[component_definition];
if (children) {
if (s.currentComponentInfo.component) {
s.currentComponentInfo.component.props._children = children.concat(component_definition);
} else {
s.currentComponentInfo._children = children.concat(component_definition)
}
} else {
if (s.currentComponentInfo.component) {
s.currentComponentInfo.component.props._children = [component_definition];
} else {
s.currentComponentInfo._children = [component_definition]
}
}
_saveScreen(store, s, s.currentFrontEndItem);
return s;
})
@ -725,7 +741,7 @@ const selectComponent = store => component => {
}
const updateComponentProp = store => (name, value) => {
const setComponentProp = store => (name, value) => {
store.update(s => {
const current_component = s.currentComponentInfo;
s.currentComponentInfo[name] = value;
@ -733,5 +749,18 @@ const updateComponentProp = store => (name, value) => {
s.currentComponentInfo = current_component;
return s;
})
}
const setComponentStyle = store => (name, value) => {
store.update(s => {
if (!s.currentComponentInfo._layout) {
s.currentComponentInfo._layout = {};
}
s.currentComponentInfo._layout[name] = value;
// save without messing with the store
_save(s.appname, s.currentFrontEndItem, store, s)
return s;
})
}

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="none" d="M0 0h24v24H0z"/>
<path fill="currentColor" d="M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z"/>
</svg>

After

Width:  |  Height:  |  Size: 228 B

View File

@ -3,3 +3,4 @@ export { default as PaintIcon } from './Paint.svelte';
export { default as TerminalIcon } from './Terminal.svelte';
export { default as InputIcon } from './Input.svelte';
export { default as ImageIcon } from './Image.svelte';
export { default as ArrowDownIcon } from './ArrowDown.svelte';

View File

@ -2,11 +2,19 @@
export let meta = [];
export let size = '';
export let values = [];
export let onStyleChanged = () => {};
let _values = values.map(v => v);
$: onStyleChanged(_values);
</script>
<div class="inputs {size}">
{#each meta as { placeholder }, i}
<input type="number" placeholder="{placeholder}" bind:value={values[i]}/>
<input type="number"
placeholder="{placeholder}"
value={values[i]}
on:input={(e) => _values[i] = e.target.value} />
{/each}
</div>

View File

@ -1,58 +1,22 @@
<script>
import PropsView from "./PropsView.svelte";
import { store } from "../builderStore";
import IconButton from "../common/IconButton.svelte";
import { LayoutIcon, PaintIcon, TerminalIcon } from '../common/Icons/';
import CodeEditor from './CodeEditor.svelte';
import LayoutEditor from './LayoutEditor.svelte';
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';
import LayoutEditor from './LayoutEditor.svelte';
let current_view = 'props';
import {
cloneDeep,
join,
split,
map,
keys,
isUndefined,
last
} from "lodash/fp";
import { assign } from "lodash";
$: component = $store.currentComponentInfo;
$: originalName = component.name;
$: name = component.name;
$: description = component.description;
$: componentInfo = $store.currentComponentInfo;
$: components = $store.components;
let component;
let name = "";
let description = "";
let tagsString = "";
let nameInvalid = "";
let componentInfo = {};
let modalElement
let propsValidationErrors = [];
let originalName="";
let components;
let ignoreStore = false;
// $: shortName = last(name.split("/"));
store.subscribe(s => {
if(ignoreStore) return;
component = s.currentComponentInfo;
if(!component) return;
originalName = component.name;
name = component.name;
description = component.description;
tagsString = join(", ")(component.tags);
componentInfo = s.currentComponentInfo;
components = s.components;
});
const onPropsChanged = store.updateComponentProp;
let current_view = 'props';
const onPropChanged = store.setComponentProp;
const onStyleChanged = store.setComponentStyle;
</script>
<div class="root">
@ -78,9 +42,9 @@ let current_view = 'props';
<div class="component-props-container">
{#if current_view === 'props'}
<PropsView {componentInfo} {components} {onPropsChanged} />
<PropsView {componentInfo} {components} {onPropChanged} />
{:else if current_view === 'layout'}
<LayoutEditor />
<LayoutEditor {onStyleChanged} {componentInfo}/>
{:else}
<CodeEditor />
{/if}

View File

@ -1,22 +1,18 @@
<script>
import { searchAllComponents } from "./pagesParsing/searchComponents";
import { store } from "../builderStore";
import { searchAllComponents } from "./pagesParsing/searchComponents";
import { store } from "../builderStore";
export let onComponentChosen = () => {};
export let onComponentChosen = () => {};
let components = [];
let phrase = "";
let phrase = "";
store.subscribe(s => {
components = s.components;
});
components = $store.components;
$: filteredComponents =
$: filteredComponents =
!phrase
? []
: searchAllComponents(components, phrase);
</script>
<div class="root">

View File

@ -1,22 +1,19 @@
<script>
import {
import {
isRootComponent
} from "./pagesParsing/searchComponents"
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import { store } from "../builderStore";
import {
groupBy, keys, find, sortBy
} from "lodash/fp";
import { pipe } from "../common/core";
} from "./pagesParsing/searchComponents"
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import { store } from "../builderStore";
import { find, sortBy } from "lodash/fp";
export let onComponentChosen;
export let onGeneratorChosen;
export let allowGenerators;
export let onComponentChosen;
export let onGeneratorChosen;
export let allowGenerators;
let screens=[];
let componentLibraries=[];
let screens = [];
let componentLibraries=[];
const addRootComponent = (c, all, isGenerator) => {
const addRootComponent = (c, all, isGenerator) => {
const { libName } = splitName(c.name);
let group = find(r => r.libName === libName)(all);
@ -36,14 +33,14 @@ const addRootComponent = (c, all, isGenerator) => {
group.components.push(c)
}
};
};
store.subscribe(s => {
$: {
const newComponentLibraries = [];
const newscreens = [];
for(let comp of sortBy(["name"])(s.components)) {
for(let comp of sortBy(["name"])($store.components)) {
if(isRootComponent(comp)) {
addRootComponent(
comp,
@ -54,7 +51,7 @@ store.subscribe(s => {
}
}
for(let generator of s.generators) {
for(let generator of $store.generators) {
addRootComponent(
generator,
newComponentLibraries,
@ -63,12 +60,7 @@ store.subscribe(s => {
screens = sortBy(["name"])(newscreens);
componentLibraries = newComponentLibraries;
});
};
</script>
{#each componentLibraries as lib}

View File

@ -1,90 +1,79 @@
<script>
import ComponentsHierarchyChildren from './ComponentsHierarchyChildren.svelte';
import ComponentsHierarchyChildren from './ComponentsHierarchyChildren.svelte';
import {
import {
last,
sortBy,
filter,
map,
uniqWith,
isEqual,
trimCharsStart,
trimChars,
join,
includes
} from "lodash/fp";
} from "lodash/fp";
import { pipe } from "../common/core";
import getIcon from "../common/icon";
import { store } from "../builderStore";
import { pipe } from "../common/core";
import { store } from "../builderStore";
import { ArrowDownIcon } from '../common/Icons/'
export let components = []
export let components = []
const joinPath = join("/");
const joinPath = join("/");
const normalizedName = name => pipe(name, [
const normalizedName = name => pipe(name, [
trimCharsStart("./"),
trimCharsStart("~/"),
trimCharsStart("../"),
trimChars(" ")
]);
const lastPartOfName = (c) =>
const lastPartOfName = (c) =>
last(c.name ? c.name.split("/") : c._component.split("/"))
const expandFolder = folder => {
const expandedFolder = {...folder};
if(expandedFolder.isExpanded) {
expandedFolder.isExpanded = false;
expandedFolders = filter(f => f.name !== folder.name)(expandedFolders);
} else {
expandedFolder.isExpanded = true;
expandedFolders.push(folder.name);
}
const newFolders = [...subfolders];
newFolders.splice(
newFolders.indexOf(folder),
1,
expandedFolder);
subfolders = newFolders;
const isComponentSelected = (current, comp) =>
current &&
current.component &&
comp.component &&
current.component.name === comp.component.name
}
const isComponentSelected = (type, current,c) =>
type==="screen"
&& current
&& current.name === c.name
const isFolderSelected = (current, folder) =>
const isFolderSelected = (current, folder) =>
isInSubfolder(current, folder)
$: _components =
$: _components =
pipe(components, [
map(c => ({component: c, title:lastPartOfName(c)})),
sortBy("title")
]);
function select_component(screen, component) {
function select_component(screen, component) {
store.setCurrentScreen(screen);
store.selectComponent(component);
}
}
const isScreenSelected = component =>
component.component &&
$store.currentFrontEndItem &&
component.component.name === $store.currentFrontEndItem.name;
</script>
<div class="root">
{#each _components as component}
<div class="hierarchy-item component"
class:selected={isComponentSelected($store.currentFrontEndType, $store.currentFrontEndItem, component.component)}
class:selected={isComponentSelected($store.currentComponentInfo, component)}
on:click|stopPropagation={() => store.setCurrentScreen(component.component.name)}>
<span class="icon" style="transform: rotate({isScreenSelected(component) ? 0 : -90}deg);">
{#if component.component.props && component.component.props._children}
<ArrowDownIcon />
{/if}
</span>
<span class="title">{component.title}</span>
</div>
{#if component.component.props && component.component.props._children}
{#if isScreenSelected(component) && component.component.props && component.component.props._children}
<ComponentsHierarchyChildren components={component.component.props._children}
currentComponent={$store.currentComponentInfo}
onSelect={child => select_component(component.component.name, child)} />
{/if}
{/each}
@ -102,9 +91,10 @@ function select_component(screen, component) {
.hierarchy-item {
cursor: pointer;
padding: 11px 7px;
margin: 5px 0;
border-radius: 5px;
display: flex;
align-items: center;
}
.hierarchy-item:hover {
@ -112,12 +102,6 @@ function select_component(screen, component) {
background: #fafafa;
}
.currentfolder {
color: var(--secondary100);
}
.selected {
color: var(--button-text);
background: var(--background-button)!important;
@ -127,5 +111,10 @@ function select_component(screen, component) {
margin-left: 10px;
}
.icon {
display: inline-block;
transition: 0.2s;
width: 24px;
height: 24px;
}
</style>

View File

@ -3,22 +3,55 @@
import { pipe } from "../common/core";
export let components = [];
export let currentComponent;
export let onSelect = () => {};
export let level = 0;
const capitalise = s => s.substring(0,1).toUpperCase() + s.substring(1);
const get_name = s => last(s.split('/'));
const get_capitalised_name = name => pipe(name, [get_name,capitalise]);
</script>
{#each components as component}
<ul>
<ul>
{#each components as component}
<li on:click|stopPropagation={() => onSelect(component)}>
<span class="item"
class:selected={currentComponent === component}
style="padding-left: {level * 20 + 67}px">
{get_capitalised_name(component._component)}
</span>
{#if component._children}
<svelte:self components={component._children}/>
<svelte:self components={component._children}
{currentComponent}
{onSelect}
level={level + 1}/>
{/if}
</li>
{/each}
</ul>
</ul>
{/each}
<style>
ul {
list-style: none;
padding-left: 0;
margin: 0;
}
.item {
display: block;
padding: 11px 67px;
border-radius: 3px;
}
.item:hover {
background: #fafafa;
cursor: pointer;
}
.selected {
color: var(--button-text);
background: var(--background-button)!important;
}
</style>

View File

@ -1,18 +1,13 @@
<script>
import {
isRootComponent
} from "./pagesParsing/searchComponents"
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import { store } from "../builderStore";
import {
groupBy, keys, find, sortBy
} from "lodash/fp";
import { pipe } from "../common/core";
import { ImageIcon, InputIcon, LayoutIcon } from '../common/Icons/';
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import { store } from "../builderStore";
import { find, sortBy } from "lodash/fp";
import { ImageIcon, InputIcon, LayoutIcon } from '../common/Icons/';
let componentLibraries=[];
let componentLibraries = [];
let current_view = 'text';
const addRootComponent = (c, all) => {
const addRootComponent = (c, all) => {
const { libName } = splitName(c.name);
let group = find(r => r.libName === libName)(all);
@ -28,25 +23,21 @@ const addRootComponent = (c, all) => {
group.components.push(c)
};
};
const onComponentChosen = store.addChildComponent;
store.subscribe(s => {
const onComponentChosen = store.addChildComponent;
$: {
const newComponentLibraries = [];
for(let comp of sortBy(["name"])(s.components)) {
for(let comp of sortBy(["name"])($store.components)) {
addRootComponent(
comp,
newComponentLibraries);
}
componentLibraries = newComponentLibraries;
});
let current_view = 'text';
}
</script>
<div class="root">
@ -115,13 +106,6 @@ let current_view = 'text';
min-height: 0px;
}
.inner-header {
font-size: 0.9em;
font-weight: bold;
margin-top: 7px;
margin-bottom: 3px;
}
.component {
padding: 0 15px;
cursor: pointer;
@ -147,13 +131,6 @@ let current_view = 'text';
opacity: 0.6;
}
.component > .description {
font-size: 0.8em;
color: var(--secondary75);
display: inline-block;
margin-left: 10px;
}
ul {
list-style: none;
display: flex;

View File

@ -1,16 +1,14 @@
<script>
import ComponentPanel from "./ComponentPanel.svelte";
import ComponentsList from "./ComponentsList.svelte";
import ComponentPanel from "./ComponentPanel.svelte";
import ComponentsList from "./ComponentsList.svelte";
let selected="properties";
let selected="properties";
const isSelected = tab =>
const isSelected = tab =>
selected === tab;
const selectTab = tab =>
const selectTab = tab =>
selected = tab;
</script>
<div class="root">

View File

@ -1,41 +1,25 @@
<script>
import { store } from "../builderStore";
import { makeLibraryUrl } from "../builderStore/loadComponentLibraries";
import {
last, split, map, join
} from "lodash/fp";
import { pipe } from "../common/core";
import { splitName } from "./pagesParsing/splitRootComponentName"
import { afterUpdate } from 'svelte';
import { getRootComponent } from "./pagesParsing/getRootComponent";
import { buildPropsHierarchy } from "./pagesParsing/buildPropsHierarchy";
import { store } from "../builderStore";
import { map, join } from "lodash/fp";
import { pipe } from "../common/core";
import { buildPropsHierarchy } from "./pagesParsing/buildPropsHierarchy";
$: hasComponent = !!$store.currentFrontEndItem;
let hasComponent=false;
let stylesheetLinks = "";
let appDefinition = {};
store.subscribe(s => {
hasComponent = !!s.currentFrontEndItem;
stylesheetLinks = pipe(s.pages.stylesheets, [
$: stylesheetLinks = pipe($store.pages.stylesheets, [
map(s => `<link rel="stylesheet" href="${s}"/>`),
join("\n")
]);
appDefinition = {
componentLibraries: s.loadLibraryUrls(),
$: appDefinition = {
componentLibraries: $store.loadLibraryUrls(),
props: buildPropsHierarchy(
s.components,
s.screens,
s.currentFrontEndItem),
hierarchy: s.hierarchy,
$store.components,
$store.screens,
$store.currentFrontEndItem),
hierarchy: $store.hierarchy,
appRootPath: ""
};
});
</script>
@ -52,7 +36,6 @@ store.subscribe(s => {
window["##BUDIBASE_APPDEFINITION##"] = ${JSON.stringify(appDefinition)};
import('/_builder/budibase-client.esm.mjs')
.then(module => {
console.log(module, window);
module.loadBudibase({ window, localStorage });
})
</script>
@ -73,23 +56,21 @@ store.subscribe(s => {
<style>
.component-container {
.component-container {
grid-row-start: middle;
grid-column-start: middle;
position: relative;
overflow: hidden;
padding-top: 56.25%;
margin: auto;
}
}
.component-container iframe {
.component-container iframe {
border: 0;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
}
</style>

View File

@ -1,68 +1,31 @@
<script>
import PropsView from "./PropsView.svelte";
import { store } from "../builderStore";
import IconButton from "../common/IconButton.svelte";
import Textbox from "../common/Textbox.svelte";
import Button from "../common/Button.svelte";
import { LayoutIcon, PaintIcon, TerminalIcon } from '../common/Icons/';
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 {
getScreenInfo
} from "./pagesParsing/createProps";
import Button from "../common/Button.svelte";
import ButtonGroup from "../common/ButtonGroup.svelte";
import { LayoutIcon, PaintIcon, TerminalIcon } from '../common/Icons/';
import {
import {
cloneDeep,
join,
split,
map,
keys,
isUndefined,
last
} from "lodash/fp";
import { assign } from "lodash";
} from "lodash/fp";
import { assign } from "lodash";
let component;
let name = "";
let description = "";
let tagsString = "";
let nameInvalid = "";
let componentInfo;
let modalElement
let propsValidationErrors = [];
let originalName="";
let components;
let ignoreStore = false;
$: component = $store.currentFrontEndItem;
$: componentInfo = $store.currentComponentInfo;
$: components = $store.components;
$: shortName = last(name.split("/"));
store.subscribe(s => {
if(ignoreStore) return;
component = s.currentFrontEndItem;
if(!component) return;
originalName = component.name;
name = component.name;
description = component.description;
tagsString = join(", ")(component.tags);
componentInfo = s.currentComponentInfo;
components = s.components;
});
const updateComponent = doChange =>
doChange(cloneDeep(component));
const updateComponent = doChange => {
const newComponent = cloneDeep(component);
doChange(newComponent);
component = newComponent;
componentInfo = getScreenInfo(components, newComponent);
}
const onPropsChanged = newProps => {
const onPropsChanged = newProps => {
updateComponent(newComponent =>
assign(newComponent.props, newProps));
}
}
</script>
<div class="root">
@ -74,74 +37,54 @@ const onPropsChanged = newProps => {
</ul>
<div class="component-props-container">
<PropsView
{componentInfo}
{onPropsChanged} />
</div>
</div>
<style>
.root {
.root {
height: 100%;
display: flex;
flex-direction: column;
}
}
.title {
padding: 1rem;
display: grid;
grid-template-columns: [name] 1fr [actions] auto;
color: var(--secondary100);
font-size: .9rem;
font-weight: bold;
}
.title > div:nth-child(1) {
.title > div:nth-child(1) {
grid-column-start: name;
color: var(--secondary100);
}
}
.title > div:nth-child(2) {
.title > div:nth-child(2) {
grid-column-start: actions;
}
}
.component-props-container {
.component-props-container {
flex: 1 1 auto;
overflow-y: auto;
}
}
ul {
ul {
list-style: none;
display: flex;
padding: 0;
}
}
li {
li {
margin-right: 20px;
background: none;
border-radius: 5px;
width: 45px;
height: 45px;
}
}
li button {
li button {
width: 100%;
height: 100%;
background: none;
border: none;
border-radius: 5px;
padding: 12px;
}
.selected {
background: lightblue;
}
}
</style>

View File

@ -1,31 +1,25 @@
<script>
import IconButton from "../common/IconButton.svelte";
import EventSelector from "./EventSelector.svelte";
import {
import IconButton from "../common/IconButton.svelte";
import EventSelector from "./EventSelector.svelte";
import {
filter
} from "lodash/fp";
import {EVENT_TYPE_MEMBER_NAME} from "../common/eventHandlers";
} from "lodash/fp";
import {EVENT_TYPE_MEMBER_NAME} from "../common/eventHandlers";
export let parentProps;
export let propDef;
export let onValueChanged;
export let onValidate = () => {};
export let parentProps;
export let propDef;
export let onValueChanged;
let events = [];
let elementErrors = {};
$: events = parentProps[propDef.____name];
$: {
events = parentProps[propDef.____name];
}
const addHandler = () => {
const addHandler = () => {
const newHandler = {parameters:{}};
newHandler[EVENT_TYPE_MEMBER_NAME] = "";
events = [...events, newHandler];
onValueChanged(events);
}
}
const onEventHandlerChanged = (oldEvent) => (newEvent) => {
const onEventHandlerChanged = (oldEvent) => (newEvent) => {
const indexOfOldEvent = events.indexOf(oldEvent);
const newEvents = [...events];
newEvents.splice(
@ -34,12 +28,12 @@ const onEventHandlerChanged = (oldEvent) => (newEvent) => {
newEvent);
events = newEvents;
onValueChanged(events);
}
}
const removeHandler = (index) => () => {
const removeHandler = (index) => () => {
events = filter(e => e !== events[index])(events);
onValueChanged(events);
}
}
</script>
@ -67,32 +61,28 @@ const removeHandler = (index) => () => {
<style>
.addelement-container {
.addelement-container {
cursor: pointer;
padding: 3px 0px;
text-align: center;
}
}
.addelement-container:hover {
.addelement-container:hover {
background-color: var(--primary25);
margin-top: 5px;
}
}
.control-container {
.control-container {
padding-left: 3px;
background: var(--secondary10);
}
}
.separator {
.separator {
width: 60%;
margin: 10px auto;
border-style:solid;
border-width: 1px 0 0 0;
border-color: var(--primary25);
}
}
</style>

View File

@ -1,33 +1,30 @@
<script>
import IconButton from "../common/IconButton.svelte";
import StateBindingControl from "./StateBindingControl.svelte";
import {
import IconButton from "../common/IconButton.svelte";
import StateBindingControl from "./StateBindingControl.svelte";
import {
find, map, keys, reduce, keyBy
} from "lodash/fp";
import { pipe, userWithFullAccess } from "../common/core";
import { EVENT_TYPE_MEMBER_NAME, allHandlers } from "../common/eventHandlers";
import { store } from "../builderStore";
} from "lodash/fp";
import { pipe, userWithFullAccess } from "../common/core";
import { EVENT_TYPE_MEMBER_NAME, allHandlers } from "../common/eventHandlers";
import { store } from "../builderStore";
export let event;
export let onChanged;
export let onRemoved;
export let event;
export let onChanged;
export let onRemoved;
let events;
let eventType;
let parameters = [];
let eventType;
let parameters = [];
store.subscribe(s => {
events = allHandlers(
{hierarchy: s.hierarchy},
$: events = allHandlers(
{hierarchy: $store.hierarchy},
userWithFullAccess({
hierarchy: s.hierarchy,
actions: keyBy("name")(s.actions)
actions: keyBy("name")($store.actions)
})
);
});
$: {
if(event) {
$: if(event) {
eventType = event[EVENT_TYPE_MEMBER_NAME];
parameters = pipe(event.parameters, [
keys,
@ -37,9 +34,8 @@ $: {
eventType = "";
parameters = [];
}
}
const eventChanged = (type, parameters) => {
const eventChanged = (type, parameters) => {
const paramsAsObject = reduce(
(obj, p) => {
obj[p.name] = p.value;
@ -53,19 +49,19 @@ const eventChanged = (type, parameters) => {
ev.parameters = paramsAsObject;
onChanged(ev);
}
}
const eventTypeChanged = (ev) => {
const eventTypeChanged = (ev) => {
const eType = find(e => e.name === ev.target.value)(events);
const emptyParameters = map(p => ({name:p, value:""}))(eType.parameters);
eventChanged(eType.name, emptyParameters);
}
}
const onParameterChanged = index => val => {
const onParameterChanged = index => val => {
const newparameters = [...parameters];
newparameters[index].value = val;
eventChanged(eventType, newparameters);
}
}
</script>
@ -84,28 +80,26 @@ const onParameterChanged = index => val => {
</div>
{#if parameters}
{#each parameters as p, index}
{#each parameters as p, index}
<div>
<div>
{p.name}
</div>
<StateBindingControl onChanged={onParameterChanged(index)}
</div>
<StateBindingControl onChanged={onParameterChanged(index)}
value={p.value} />
{/each}
{/each}
{/if}
<style>
.type-selector-container {
.type-selector-container {
display: flex;
}
}
.type-selector {
.type-selector {
border-color: var(--primary50);
border-radius: 2px;
width: 50px;
flex: 1 0 auto;
}
}
</style>

View File

@ -1,13 +1,8 @@
<script>
import InputGroup from '../common/Inputs/InputGroup.svelte';
let grid_values = ['', '', '', ''];
let column_values = ['', ''];
let row_values = ['', ''];
let gap_values = [''];
let margin_values = ['', '', '', ''];
let padding_values = ['', '', '', ''];
let zindex_values = [''];
export let onStyleChanged = () => {};
export let componentInfo;
const tbrl = [
{ placeholder: 'T' },
@ -22,6 +17,27 @@
]
const single = [{ placeholder: '' }];
$: layout = componentInfo._layout;
$: positions = {
gridarea: ['Grid Area', tbrl, 'small'],
column: ['Column', se],
row: ['Row', se],
gap: ['Gap', single],
};
$: spacing = {
margin: ['Margin', tbrl, 'small'],
padding: ['Padding', tbrl, 'small']
};
$: zindex = {
zindex: ['Z-Index', single]
}
const newValue = n => Array(n).fill('');
</script>
@ -30,48 +46,41 @@
<h4>Positioning</h4>
<div class="layout-pos">
{#each Object.entries(positions) as [key, [name, meta, size]]}
<div class="grid">
<h5>Grid Area:</h5>
<InputGroup meta={tbrl} bind:values={grid_values} size="small"/>
</div>
<div class="grid">
<h5>Column:</h5>
<InputGroup meta={se} bind:values={column_values} />
</div>
<div class="grid">
<h5>Row:</h5>
<InputGroup meta={se} bind:values={row_values} />
</div>
<div class="grid">
<h5>Gap:</h5>
<InputGroup meta={single} bind:values={gap_values} />
<InputGroup onStyleChanged={_value => onStyleChanged(key, _value)}
values={layout[key] || newValue(meta.length)}
{meta}
{size} />
</div>
{/each}
</div>
<h4>Spacing</h4>
<div class="layout-spacing">
{#each Object.entries(spacing) as [key, [name, meta, size]]}
<div class="grid">
<h5>Margin:</h5>
<InputGroup meta={tbrl} bind:values={margin_values} size="small"/>
</div>
<div class="grid">
<h5>Padding:</h5>
<InputGroup meta={tbrl} bind:values={padding_values} size="small"/>
<h5>Grid Area:</h5>
<InputGroup onStyleChanged={_value => onStyleChanged(key, _value)}
values={layout[key] || newValue(meta.length)}
{meta}
{size} />
</div>
{/each}
</div>
<h4>Z-Index</h4>
<div class="layout-layer">
{#each Object.entries(zindex) as [key, [name, meta, size]]}
<div class="grid">
<h5>Z-Index:</h5>
<InputGroup meta={single} bind:values={zindex_values}/>
<h5>Grid Area:</h5>
<InputGroup onStyleChanged={_value => onStyleChanged(key, _value)}
values={layout[key] || newValue(meta.length)}
{meta}
{size} />
</div>
{/each}
</div>
<style>
@ -112,5 +121,4 @@
.grid {
grid-template-columns: 70px 1fr;
}
</style>

View File

@ -1,34 +1,33 @@
<script>
import ComponentSelector from "./ComponentSelector.svelte";
import { store } from "../builderStore";
import PropsView from "./PropsView.svelte";
import Textbox from "../common/Textbox.svelte";
import Button from "../common/Button.svelte";
import ButtonGroup from "../common/ButtonGroup.svelte";
import { pipe } from "../common/core";
import UIkit from "uikit";
import { isRootComponent } from "./pagesParsing/searchComponents";
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import ComponentSelector from "./ComponentSelector.svelte";
import { store } from "../builderStore";
import PropsView from "./PropsView.svelte";
import Textbox from "../common/Textbox.svelte";
import Button from "../common/Button.svelte";
import ButtonGroup from "../common/ButtonGroup.svelte";
import { pipe } from "../common/core";
import UIkit from "uikit";
import { isRootComponent } from "./pagesParsing/searchComponents";
import { splitName } from "./pagesParsing/splitRootComponentName.js"
import {
import {
find, filter, some, map, includes
} from "lodash/fp";
import { assign } from "lodash";
} from "lodash/fp";
import { assign } from "lodash";
export const show = () => {
export const show = () => {
UIkit.modal(componentSelectorModal).show();
}
}
let componentSelectorModal;
let layoutComponents;
let layoutComponent;
let screens;
let name="";
let saveAttempted=false;
let componentSelectorModal;
let layoutComponents;
let layoutComponent;
let screens;
let name="";
let saveAttempted=false;
store.subscribe(s => {
store.subscribe(s => {
layoutComponents = pipe(s.components, [
filter(c => c.container),
map(c => ({name:c.name, ...splitName(c.name)}))
@ -39,9 +38,9 @@ store.subscribe(s => {
: layoutComponents[0];
screens = s.screens;
});
});
const save = () => {
const save = () => {
saveAttempted = true;
const isValid = name.length > 0
@ -52,13 +51,13 @@ const save = () => {
store.createScreen(name, layoutComponent.name);
UIkit.modal(componentSelectorModal).hide();
}
}
const cancel = () => {
const cancel = () => {
UIkit.modal(componentSelectorModal).hide();
}
}
const screenNameExists = (name) =>
const screenNameExists = (name) =>
some(s => s.name.toLowerCase() === name.toLowerCase())(screens)
</script>
@ -106,27 +105,7 @@ const screenNameExists = (name) =>
<style>
h1 {
h1 {
font-size:1.2em;
}
.component-option {
border-style: solid;
border-color: var(--slate);
border-width: 0 0 1px 0;
padding: 3px;
}
.component-option:hover {
background-color: var(--lightslate);
}
.component-name {
font-size: 11pt;
}
.lib-name {
font-size: 9pt;
}
}
</style>

View File

@ -1,34 +1,27 @@
<script>
import Textbox from "../common/Textbox.svelte";
import Dropdown from "../common/Dropdown.svelte";
import Button from "../common/Button.svelte";
import { store } from "../builderStore";
import { isRootComponent } from "./pagesParsing/searchComponents";
import { pipe } from "../common/core";
import {
import Textbox from "../common/Textbox.svelte";
import Dropdown from "../common/Dropdown.svelte";
import Button from "../common/Button.svelte";
import { store } from "../builderStore";
import { isRootComponent } from "./pagesParsing/searchComponents";
import { pipe } from "../common/core";
import {
filter, find, concat
} from "lodash/fp";
} from "lodash/fp";
let entryComponent;
let title = "";
let components = [];
let page={};
const notSeletedComponent = {name:"(none selected)"};
const notSeletedComponent = {name:"(none selected)"};
store.subscribe(s => {
page = s.pages[s.currentPageName];
if(!page) return;
title = page.index.title;
components = pipe(s.components, [
filter(s => !isRootComponent(s)),
$: page = $store.pages[$store.currentPageName];
$: title = page.index.title;
$: components = pipe($store.components, [
filter(store => !isRootComponent($store)),
concat([notSeletedComponent])
]);
entryComponent = find(c => c.name === page.appBody)(components);
if(!entryComponent) entryComponent = notSeletedComponent;
});
$: entryComponent = find(c => c.name === page.appBody)(components) || notSeletedComponent;
const save = () => {
const save = () => {
if(!title || !entryComponent || entryComponent === notSeletedComponent) return;
const page = {
index: {
@ -37,8 +30,7 @@ const save = () => {
appBody: entryComponent.name,
}
store.savePage(page);
}
}
</script>
<div class="root">
@ -61,11 +53,11 @@ const save = () => {
</div>
<style>
.root {
.root {
padding: 15px;
}
.help-text {
}
.help-text {
color: var(--slate);
font-size: 10pt;
}
}
</style>

View File

@ -1,22 +1,21 @@
<script>
import { store } from "../builderStore";
import getIcon from "../common/icon";
import { store } from "../builderStore";
import getIcon from "../common/icon";
const getPage = (s, name) => {
const getPage = (s, name) => {
const props = s.pages[name];
return ({name, props});
}
}
const pages = [{
const pages = [{
title: 'Main',
id: 'main'
}, {
}, {
title: 'Login',
id: 'unauthenticated'
}]
store.setCurrentPage('main')
}]
store.setCurrentPage('main')
</script>
<div class="root">
@ -31,17 +30,16 @@ store.setCurrentPage('main')
</div>
<style>
.root {
.root {
padding-bottom: 10px;
font-size: .9rem;
color: var(--secondary50);
font-weight: bold;
position: relative;
}
}
select {
select {
display: block;
font-size: 16px;
font-family: sans-serif;
@ -59,9 +57,9 @@ select {
-webkit-appearance: none;
appearance: none;
background-color: #fafafa;
}
}
.arrow {
.arrow {
position: absolute;
right: 10px;
top: 0;
@ -71,6 +69,5 @@ select {
height: 30px;
pointer-events: none;
color: var(--primary100);
}
}
</style>

View File

@ -1,37 +1,25 @@
<script>
import Checkbox from "../common/Checkbox.svelte";
import Textbox from "../common/Textbox.svelte";
import Dropdown from "../common/Dropdown.svelte";
import StateBindingControl from "./StateBindingControl.svelte";
import Checkbox from "../common/Checkbox.svelte";
import Textbox from "../common/Textbox.svelte";
import Dropdown from "../common/Dropdown.svelte";
import EventListSelector from "./EventListSelector.svelte";
import StateBindingControl from "./StateBindingControl.svelte";
export let setProp = () => {};
export let index;
export let prop_name;
export let prop_value;
export let prop_type = {};
export let setProp = () => {};
export let disabled;
export let index;
export let prop_name;
export let prop_value;
export let prop_type = {};
$: isOdd = (index % 2 !== 0);
$: isOdd = (index % 2 !== 0);
const setComponentProp = (props) => {
const setComponentProp = (props) => {
setProp(propDef.____name, props);
}
}
</script>
<div class="root" >
{#if prop_type === "event"}
<!-- <h5>{prop_name}</h5>
<EventListSelector parentProps={props}
{propDef}
onValueChanged={setComponentProp} /> -->
{:else }
{#if prop_type !== "event" }
<h5>{prop_name}</h5>
<StateBindingControl value={prop_value}
@ -40,21 +28,19 @@ const setComponentProp = (props) => {
onChanged={v => setProp(prop_name, v)}/>
{/if}
</div>
<style>
.root {
.root {
height: 40px;
margin-bottom: 15px;
display: grid;
grid-template-rows: 1fr;
grid-template-columns: 70px 1fr;
grid-gap: 10px;
}
}
h5 {
h5 {
font-size: 12px;
font-weight: 700;
color: #163057;
@ -62,5 +48,4 @@ h5 {
padding-top: 12px;
margin-bottom: 0;
}
</style>

View File

@ -1,44 +1,32 @@
<script>
import { some, includes, filter } from "lodash/fp";
import Textbox from "../common/Textbox.svelte";
import Dropdown from "../common/Dropdown.svelte";
import PropControl from "./PropControl.svelte";
import IconButton from "../common/IconButton.svelte";
import {
keys, map, some, includes,
cloneDeep, isEqual, sortBy,
filter, difference
} from "lodash/fp";
import { pipe } from "../common/core";
import { getInstanceProps } from "./pagesParsing/createProps";
import Checkbox from "../common/Checkbox.svelte";
import Textbox from "../common/Textbox.svelte";
import Dropdown from "../common/Dropdown.svelte";
import PropControl from "./PropControl.svelte";
import IconButton from "../common/IconButton.svelte";
export let componentInfo;
export let onPropChanged = () => {};
export let components;
export let componentInfo;
export let instanceProps = null;
export let onPropsChanged = () => {};
export let components;
let errors = [];
let props = {};
let errors = [];
let props = {};
let propsDefinitions = [];
let isInstance = false;
const props_to_ignore = ['_component','_children', '_layout'];
const props_to_ignore = ['_component','_children', '_layout'];
$: propDefs = componentInfo && Object.entries(componentInfo).filter(([name])=> !props_to_ignore.includes(name));
$: propDefs = componentInfo && Object.entries(componentInfo).filter(([name])=> !props_to_ignore.includes(name));
function find_type(prop_name) {
function find_type(prop_name) {
if(!componentInfo._component) return;
return components.find(({name}) => name === componentInfo._component).props[prop_name];
}
}
let setProp = (name, value) => {
onPropsChanged(name, value);
}
let setProp = (name, value) => {
onPropChanged(name, value);
}
const fieldHasError = (propName) =>
const fieldHasError = (propName) =>
some(e => e.propName === propName)(errors);
</script>
<div class="root">
@ -65,20 +53,18 @@ const fieldHasError = (propName) =>
<style>
.root {
.root {
font-size:10pt;
width: 100%;
}
}
.form-root {
.form-root {
display: flex;
flex-wrap: wrap;
}
}
.prop-container {
.prop-container {
flex: 1 1 auto;
min-width: 250px;
}
}
</style>

View File

@ -1,52 +1,46 @@
<script>
import { store } from "../builderStore";
import Textbox from "../common/Textbox.svelte";
import Button from "../common/Button.svelte";
import IconButton from "../common/IconButton.svelte";
import { libraryDependencies } from "./pagesParsing/findDependencies";
import UIkit from "uikit";
import { store } from "../builderStore";
import Textbox from "../common/Textbox.svelte";
import Button from "../common/Button.svelte";
import IconButton from "../common/IconButton.svelte";
import { libraryDependencies } from "./pagesParsing/findDependencies";
import UIkit from "uikit";
let addNewLib = "";
let addNewStylesheet = "";
let modalElement;
let addNewLib = "";
let addNewStylesheet = "";
let addComponentError = "";
let modalElement;
let components;
$: components = $store.components;
store.subscribe(s => {
components = s.components;
})
const removeLibrary = lib => {
const removeLibrary = lib => {
const dependencies = libraryDependencies(components, lib);
if(dependencies.length > 0) return;
store.removeComponentLibrary(lib);
}
}
const addLib = () => {
const addLib = () => {
store.addComponentLibrary(addNewLib)
.then(() => {
addNewLib = "";
});
}
}
const removeStylesheet = stylesheet => {
const removeStylesheet = stylesheet => {
store.removeStylesheet(stylesheet);
}
}
const addStylesheet = () => {
const addStylesheet = () => {
if(addNewStylesheet)
store.addStylesheet(addNewStylesheet);
}
}
export const close = () => {
export const close = () => {
UIkit.modal(modalElement).hide();
}
}
export const show = () => {
export const show = () => {
UIkit.modal(modalElement).show();
}
}
</script>
<div bind:this={modalElement} id="new-component-modal" uk-modal>
@ -103,43 +97,41 @@ export const show = () => {
</div>
<style>
.section-container {
.section-container {
padding: 15px;
border-style: dotted;
border-width: 1px;
border-color: var(--lightslate);
border-radius: 2px;
}
}
.section-container:nth-child(1) {
.section-container:nth-child(1) {
margin-bottom: 15px;
}
}
.row-text {
.row-text {
margin-right: 15px;
color: var(--primary100);
}
}
input {
input {
margin-right: 15px;
}
}
p > span {
p > span {
margin-left: 30px;
}
}
.header {
.header {
display: grid;
grid-template-columns: [title] 1fr [icon] auto;
}
}
.header > div:nth-child(1) {
.header > div:nth-child(1) {
grid-column-start: title;
}
}
.header > div:nth-child(2) {
.header > div:nth-child(2) {
grid-column-start: icon;
}
}
</style>

View File

@ -1,26 +1,23 @@
<script>
import {
isString
} from "lodash/fp";
import IconButton from "../common/IconButton.svelte";
import {
import IconButton from "../common/IconButton.svelte";
import {
isBinding, getBinding, setBinding
} from "../common/binding";
} from "../common/binding";
export let value="";
export let onChanged= () => {};
export let type="";
export let options=[];
export let value="";
export let onChanged= () => {};
export let type="";
export let options=[];
let isBound=false;
let bindingPath="";
let bindingFallbackValue="";
let bindingSource="store";
let isExpanded = false;
let forceIsBound = false;
let canOnlyBind = false;
let isBound=false;
let bindingPath="";
let bindingFallbackValue="";
let bindingSource="store";
let isExpanded = false;
let forceIsBound = false;
let canOnlyBind = false;
$: {
$: {
canOnlyBind = type === "state";
if(!forceIsBound && canOnlyBind)
forceIsBound = true;
@ -37,44 +34,39 @@ $: {
bindingFallbackValue="";
bindingSource="store";
}
}
}
const clearBinding = () => {
const clearBinding = () => {
forceIsBound = false;
onChanged("");
}
}
const bind = (path, fallback, source) => {
const bind = (path, fallback, source) => {
if(!path) {
clearBinding("");
return;
}
const binding = setBinding({path, fallback, source});
onChanged(binding);
}
}
const setBindingPath = ev => {
const setBindingPath = ev => {
forceIsBound = canOnlyBind;
bind(ev.target.value, bindingFallbackValue, bindingSource)
}
}
const setBindingFallback = ev => {
const setBindingFallback = ev => {
bind(bindingPath, ev.target.value, bindingSource);
}
}
const setBindingSource = ev => {
const setBindingSource = ev => {
bind(bindingPath, bindingFallbackValue, ev.target.value);
}
// const makeBinding = () => {
// forceIsBound=true;
// isExpanded=true;
// }
}
</script>
{#if isBound}
<div>
<div>
<div class="bound-header">
<div>{isExpanded ? "" : bindingPath}</div>
<IconButton icon={isExpanded ? "chevron-up" : "chevron-down"}
@ -108,20 +100,17 @@ const setBindingSource = ev => {
</div>
{/if}
</div>
</div>
{:else}
<div class="unbound-container">
<div class="unbound-container">
{#if type === "bool"}
<div>
<IconButton icon={value == true ? "check-square" : "square"}
size="19"
on:click={() => onChanged(!value)} />
</div>
{:else if type === "options"}
<select class="uk-select uk-form-small"
value={value}
on:change={ev => onChanged(ev.target.value)}>
@ -129,17 +118,13 @@ const setBindingSource = ev => {
<option value={option}>{option}</option>
{/each}
</select>
{:else}
<input on:change={ev => onChanged(ev.target.value)}
bind:value={value}
style="flex: 1 0 auto;" />
{/if}
</div>
</div>
{/if}

View File

@ -1,28 +1,25 @@
<script>
import ComponentsHierarchy from "./ComponentsHierarchy.svelte";
import PagesList from "./PagesList.svelte"
import { store } from "../builderStore";
import IconButton from "../common/IconButton.svelte";
import Modal from "../common/Modal.svelte";
import NewComponent from "./NewComponent.svelte";
import CurrentItemPreview from "./CurrentItemPreview.svelte";
import SettingsView from "./SettingsView.svelte";
import PageView from "./PageView.svelte";
import ComponentsPaneSwitcher from "./ComponentsPaneSwitcher.svelte";
import ComponentsHierarchy from "./ComponentsHierarchy.svelte";
import PagesList from "./PagesList.svelte"
import { store } from "../builderStore";
import getIcon from "../common/icon";
import { isComponent } from "./pagesParsing/searchComponents";
import IconButton from "../common/IconButton.svelte";
import Modal from "../common/Modal.svelte";
import NewComponent from "./NewComponent.svelte";
import CurrentItemPreview from "./CurrentItemPreview.svelte";
import SettingsView from "./SettingsView.svelte";
import PageView from "./PageView.svelte";
import ComponentsPaneSwitcher from "./ComponentsPaneSwitcher.svelte";
let newComponentPicker;
let newComponentPicker;
const newComponent = () => {
const newComponent = () => {
newComponentPicker.show();
}
}
let settingsView;
const settings = () => {
let settingsView;
const settings = () => {
settingsView.show();
}
}
</script>
<div class="root">
@ -44,11 +41,6 @@ const settings = () => {
<span class="components-nav-header">Screens</span>
<div>
<!-- <IconButton icon="settings"
size="14px"
on:click={settings}/> -->
<!-- <IconButton icon="plus"
on:click={newComponent}/> -->
<button on:click={newComponent}>+</button>
</div>
</div>
@ -81,7 +73,7 @@ const settings = () => {
<style>
button {
button {
cursor: pointer;
outline: none;
border: none;
@ -99,91 +91,90 @@ button {
font-size: 1.2rem;
font-weight: 700;
color: var(--button-text);
}
}
.root {
.root {
display: grid;
grid-template-columns: 290px 1fr 300px;
height: 100%;
width: 100%;
background: #fafafa;
}
}
.ui-nav {
.ui-nav {
grid-column: 1;
background-color: var(--secondary5);
height: 100%;
padding: 0 1.5rem 0rem 1.5rem
}
}
.preview-pane {
.preview-pane {
grid-column: 2;
margin: 80px 60px;
background: #fff;
border-radius: 5px;
box-shadow: 0 0px 6px rgba(0,0,0,0.05)
}
}
.components-pane {
.components-pane {
grid-column: 3;
background-color: var(--secondary5);
min-height: 0px;
overflow-y: hidden;
}
}
.components-nav-header {
.components-nav-header {
font-size: 0.75rem;
color: #999;
text-transform: uppercase;
}
}
.nav-group-header {
.nav-group-header {
font-size: .9rem;
padding-left: 1rem;
}
}
.nav-items-container {
.nav-items-container {
padding: 1rem 0rem 0rem 0rem;
}
}
.nav-group-header {
.nav-group-header {
display: flex;
padding: 2rem 0 0 0;
font-size: .9rem;
font-weight: bold;
justify-content: space-between;
align-items: center;
}
}
.nav-group-header>div:nth-child(1) {
.nav-group-header>div:nth-child(1) {
padding: 0rem .5rem 0rem 0rem;
vertical-align: bottom;
grid-column-start: icon;
margin-right: 5px;
}
}
.nav-group-header>span:nth-child(2) {
.nav-group-header>span:nth-child(2) {
margin-left:5px;
vertical-align: bottom;
grid-column-start: title;
margin-top:auto;
}
}
.nav-group-header>div:nth-child(3) {
.nav-group-header>div:nth-child(3) {
vertical-align: bottom;
grid-column-start: button;
cursor: pointer;
color: var(--primary75);
}
}
.nav-group-header>div:nth-child(3):hover {
.nav-group-header>div:nth-child(3):hover {
color: var(--primary75);
}
}
.navigator-title {
.navigator-title {
text-transform: uppercase;
font-weight: 400;
color: #999;
}
}
</style>