diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 19987764e5..f195ea4d99 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -285,6 +285,7 @@ export const getFrontendStore = () => { _id: uuid(), _component: definition.component, _styles: { normal: {}, hover: {}, active: {} }, + _transition: "", _instanceName: `New ${definition.name}`, ...cloneDeep(props), ...extras, @@ -487,6 +488,15 @@ export const getFrontendStore = () => { selected._styles = { normal: {}, hover: {}, active: {} } await store.actions.preview.saveSelected() }, + updateTransition: async (transition) => { + const selected = get(selectedComponent) + if (transition == null || transition === "") { + selected = "" + } else { + selected._transition = transition + } + await store.actions.preview.saveSelected() + }, updateProp: async (name, value) => { let component = get(selectedComponent) if (!name || !component) { diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js b/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js index 182736a1d5..c4085e483c 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/Component.js @@ -14,6 +14,7 @@ export class Component extends BaseStructure { active: {}, selected: {}, }, + _transition: "", _instanceName: "", _children: [], } @@ -39,6 +40,11 @@ export class Component extends BaseStructure { return this } + transition(transition) { + this._json._transition = transition + return this + } + // Shorthand for custom props "type" type(type) { this._json.type = type diff --git a/packages/builder/src/components/design/PropertiesPanel/DesignView.svelte b/packages/builder/src/components/design/PropertiesPanel/DesignView.svelte index dee6595ed5..d40fe7c8e7 100644 --- a/packages/builder/src/components/design/PropertiesPanel/DesignView.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/DesignView.svelte @@ -1,5 +1,5 @@ -
-
+
+
-
+
{#if groups.length > 0} {#each groups as groupName}
+ {#if componentDefinition?.transitionable} +
+ +
+ {/if}
diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertiesPanel.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertiesPanel.svelte index 6291917cd0..9980b6712a 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertiesPanel.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertiesPanel.svelte @@ -24,29 +24,9 @@ const onStyleChanged = store.actions.components.updateStyle const onCustomStyleChanged = store.actions.components.updateCustomStyle + const onUpdateTransition = store.actions.components.updateTransition const onResetStyles = store.actions.components.resetStyles - function walkProps(component, action) { - action(component) - if (component.children) { - for (let child of component.children) { - walkProps(child, action) - } - } - } - - function flattenComponents(props) { - const components = [] - props.forEach(comp => - walkProps(comp, c => { - if ("_component" in c) { - components.push(c) - } - }) - ) - return components - } - function setAssetProps(name, value) { const selectedAsset = get(currentAsset) store.update(state => { @@ -62,10 +42,6 @@ }) store.actions.preview.saveSelected() } - - function getProps(obj, keys) { - return keys.map((key, i) => [key, obj[key], obj.props._id + i]) - } {:else if selectedCategory.value === 'settings'} import { getContext } from "svelte" - const { styleable, transition } = getContext("sdk") + const { styleable } = getContext("sdk") const component = getContext("component") export let className = "" @@ -9,7 +9,6 @@ export let description = "" export let height export let width - export let transitionType = "" {description} + in:transition={{type: $component.transition}} />