From 1a1aa5963d76e14b420aa08ec1da39227624d45b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 4 Jan 2021 18:39:17 +0000 Subject: [PATCH] Add ability to enter custom component CSS --- .../src/builderStore/store/frontend.js | 26 +++++++++---------- .../ComponentPropertiesPanel.svelte | 7 ++++- .../userInterface/DesignView.svelte | 20 +++++++++++++- packages/client/src/utils/styleable.js | 16 +++++++----- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 263041aadd..a12e3a4538 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -366,20 +366,20 @@ export const getFrontendStore = () => { await Promise.all(promises) }, updateStyle: async (type, name, value) => { - let promises = [] const selected = get(selectedComponent) - - store.update(state => { - if (!selected._styles) { - selected._styles = {} - } - selected._styles[type][name] = value - - // save without messing with the store - promises.push(store.actions.preview.saveSelected()) - return state - }) - await Promise.all(promises) + if (!selected._styles) { + selected._styles = {} + } + selected._styles[type][name] = value + await store.actions.preview.saveSelected() + }, + updateCustomStyle: async style => { + const selected = get(selectedComponent) + if (!selected._styles) { + selected._styles = {} + } + selected._styles.custom = style + await store.actions.preview.saveSelected() }, updateProp: (name, value) => { store.update(state => { diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 4699a8e415..422dcca85c 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -31,6 +31,7 @@ componentPropDefinition.properties[selectedCategory.value] const onStyleChanged = store.actions.components.updateStyle + const onCustomStyleChanged = store.actions.components.updateCustomStyle $: isComponentOrScreen = $store.currentView === "component" || @@ -93,7 +94,11 @@
{#if selectedCategory.value === 'design'} - + {:else if selectedCategory.value === 'settings'} - import { onMount } from "svelte" + import { TextArea, DetailSummary } from "@budibase/bbui" import PropertyGroup from "./PropertyGroup.svelte" import FlatButtonGroup from "./FlatButtonGroup.svelte" @@ -7,6 +7,7 @@ export let componentInstance = {} export let componentDefinition = {} export let onStyleChanged = () => {} + export let onCustomStyleChanged = () => {} let selectedCategory = "normal" let propGroup = null @@ -44,6 +45,17 @@ open={currentGroup === groupName} on:open={() => (currentGroup = groupName)} /> {/each} + (currentGroup = 'custom')} + show={currentGroup === 'custom'} + thin> +
+