diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index e40470d78d..0975671073 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -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; + }) } diff --git a/packages/builder/src/common/Icons/ArrowDown.svelte b/packages/builder/src/common/Icons/ArrowDown.svelte new file mode 100644 index 0000000000..a710c8ae84 --- /dev/null +++ b/packages/builder/src/common/Icons/ArrowDown.svelte @@ -0,0 +1,4 @@ + diff --git a/packages/builder/src/common/Icons/index.js b/packages/builder/src/common/Icons/index.js index 7ab39dfdd0..2e2ffc2010 100644 --- a/packages/builder/src/common/Icons/index.js +++ b/packages/builder/src/common/Icons/index.js @@ -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'; diff --git a/packages/builder/src/common/Inputs/InputGroup.svelte b/packages/builder/src/common/Inputs/InputGroup.svelte index 09ed8298b7..55bede83f2 100644 --- a/packages/builder/src/common/Inputs/InputGroup.svelte +++ b/packages/builder/src/common/Inputs/InputGroup.svelte @@ -2,11 +2,19 @@ export let meta = []; export let size = ''; export let values = []; + export let onStyleChanged = () => {}; + + let _values = values.map(v => v); + + $: onStyleChanged(_values);
Component Libraries - + @@ -73,17 +67,17 @@ export const show = () => { {#each $store.pages.componentLibraries as lib}
Stylesheets - + @@ -91,55 +85,53 @@ export const show = () => { {#each $store.pages.stylesheets as stylesheet}