From 5b8d1cead7bfbcc1a884d3dafb59c6f479df0f46 Mon Sep 17 00:00:00 2001 From: Conor_Mack Date: Mon, 18 May 2020 16:32:00 +0100 Subject: [PATCH] Testing Complete - Resolve Post Issue --- .../builder/src/builderStore/generate_css.js | 35 ++-- .../builder/src/builderStore/store/index.js | 9 +- .../common/Inputs/InputGroup.svelte | 54 ++++--- .../AppPreview/CurrentItemPreview.svelte | 4 +- .../AppPreview/iframeTemplate.js | 2 +- .../ComponentPropertiesPanel.svelte | 32 ++-- .../userInterface/DesignView.svelte | 9 +- .../userInterface/PropertyControl.svelte | 2 + .../userInterface/PropertyGroup.svelte | 22 +-- .../userInterface/SettingsView.svelte | 35 ++++ .../userInterface/pagesParsing/createProps.js | 4 +- .../userInterface/propertyCategories.js | 145 +++++++++-------- .../userInterface/temporaryPanelStructure.js | 152 ++++++++++-------- packages/client/src/render/attachChildren.js | 2 +- .../src/render/prepareRenderComponent.js | 2 +- 15 files changed, 294 insertions(+), 215 deletions(-) create mode 100644 packages/builder/src/components/userInterface/SettingsView.svelte diff --git a/packages/builder/src/builderStore/generate_css.js b/packages/builder/src/builderStore/generate_css.js index 4326e7cb0f..4311950a58 100644 --- a/packages/builder/src/builderStore/generate_css.js +++ b/packages/builder/src/builderStore/generate_css.js @@ -110,33 +110,36 @@ const object_to_css_string = [ join_with("\n"), ] -export const generate_css = ({ layout, position }) => { - let _layout = pipe(layout, object_to_css_string) - if (_layout.length) { - _layout += `\ndisplay: ${_layout.includes("flex") ? "flex" : "grid"};` - } +export const generate_css = style => { + // let cssString = pipe(style, object_to_css_string) + let cssString = Object.entries(style).reduce((str, [key, value]) => { + //TODO Handle arrays and objects here also + if (typeof value === "string") { + if (value) { + return (str += `${key}: ${value};\n`) + } + } else if (Array.isArray(value)) { + return (str += `${key}: ${value.map(v => `${v}px`).join(" ")};\n`) + } + }, "") - return { - layout: _layout, - position: pipe(position, object_to_css_string), - } + return (cssString || "").trim() } const apply_class = (id, name, styles) => `.${name}-${id} {\n${styles}\n}` export const generate_screen_css = component_array => { let styles = "" - let emptyStyles = { layout: {}, position: {} } - + let emptyStyles = {} for (let i = 0; i < component_array.length; i += 1) { const { _styles, _id, _children } = component_array[i] - const { layout, position } = generate_css(_styles || emptyStyles) - - styles += apply_class(_id, "pos", position) + "\n" - styles += apply_class(_id, "lay", layout) + "\n" + const cssString = generate_css(_styles || emptyStyles) || "" + if (cssString) { + styles += apply_class(_id, "element", cssString) + } if (_children && _children.length) { styles += generate_screen_css(_children) + "\n" } } return styles.trim() -} +} \ No newline at end of file diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index a8315918ba..7e108bbe09 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -140,10 +140,12 @@ const _saveScreen = async (store, s, screen) => { return s } -const _saveScreenApi = (screen, s) => +const _saveScreenApi = (screen, s) => { + api .post(`/_builder/api/${s.appId}/pages/${s.currentPageName}/screen`, screen) .then(() => _savePage(s)) +} const createScreen = store => (screenName, route, layoutComponentName) => { store.update(state => { @@ -278,7 +280,6 @@ const removeStylesheet = store => stylesheet => { const _savePage = async s => { const page = s.pages[s.currentPageName] - await api.post(`/_builder/api/${s.appId}/pages/${s.currentPageName}`, { page: { componentLibraries: s.pages.componentLibraries, ...page }, uiFunctions: s.currentPageFunctions, @@ -426,7 +427,9 @@ const setComponentStyle = store => (type, name, value) => { if (!state.currentComponentInfo._styles) { state.currentComponentInfo._styles = {} } - state.currentComponentInfo._styles[type][name] = value + // state.currentComponentInfo._styles[type][name] = value + state.currentComponentInfo._styles[name] = value + state.currentPreviewItem._css = generate_screen_css([ state.currentPreviewItem.props, ]) diff --git a/packages/builder/src/components/common/Inputs/InputGroup.svelte b/packages/builder/src/components/common/Inputs/InputGroup.svelte index 078edea28f..7976cabd55 100644 --- a/packages/builder/src/components/common/Inputs/InputGroup.svelte +++ b/packages/builder/src/components/common/Inputs/InputGroup.svelte @@ -2,36 +2,50 @@ import { onMount } from "svelte" export let meta = [] - export let size = "" + export let label = "" export let values = [] export let type = "number" - export let onStyleChanged = () => {} + export let onChange = () => {} let _values = values.map(v => v) - $: onStyleChanged(_values) + // $: onChange(_values) -
- {#each meta as { placeholder }, i} - (_values[i] = e.target.value)} /> - {/each} +
+
{label}
+
+ {#each meta as { placeholder }, i} + (_values[i] = e.target.value)} /> + {/each} +
diff --git a/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte index 02aa072910..18afb123ef 100644 --- a/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte +++ b/packages/builder/src/components/userInterface/AppPreview/CurrentItemPreview.svelte @@ -60,7 +60,7 @@ _children: [ { _component: "@budibase/standard-components/container", - _styles: { position: {}, layout: {} }, + _styles: {}, _id: "__screenslot__text", _code: "", className: "", @@ -69,7 +69,7 @@ _children: [ { _component: "@budibase/standard-components/text", - _styles: { position: {}, layout: {} }, + _styles: {}, _id: "__screenslot__text_2", _code: "", text: "content", diff --git a/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js b/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js index 3c774cc4b8..c1cf4aab1f 100644 --- a/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js +++ b/packages/builder/src/components/userInterface/AppPreview/iframeTemplate.js @@ -11,7 +11,7 @@ export default ({