From 3b78d4773b6d4b58b320266d2d481aa4b1b90240 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Mon, 22 Aug 2022 16:45:59 +0100 Subject: [PATCH 1/3] Update CSS conditional UI --- .../_components/settings/ConditionalUIDrawer.svelte | 6 +++++- packages/client/src/components/Component.svelte | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte index c386a52cb7..9f4dbbbde5 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte @@ -56,7 +56,11 @@ ] let dragDisabled = true - $: settings = getComponentSettings($selectedComponent?._component) + $: settings = getComponentSettings($selectedComponent?._component)?.concat({ + label: "CSS", + key: "css", + type: "text", + }) $: settingOptions = settings.map(setting => ({ label: setting.label, value: setting.key, diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index a7f506a387..f72f989920 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -379,6 +379,9 @@ // initial props are up to date. By setting it this way rather than // setting it on initialSettings directly, we avoid a double render. cachedSettings[key] = allSettings[key] + if (key === "css") { + instance._styles.custom = cachedSettings[key] + } if (ref?.$$set) { // Programmatically set the prop to avoid svelte reactive statements From 178dc26c1686b5a4deed1429d30e72190ce2f0ab Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 5 Sep 2022 16:35:25 +0100 Subject: [PATCH 2/3] Allow custom CSS to be bindable and allow overriding via conditional UI --- .../settings/ConditionalUIDrawer.svelte | 4 +- .../settings/CustomStylesSection.svelte | 56 ++++++++++--------- .../client/src/components/Component.svelte | 25 +++++++-- 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte index 9f4dbbbde5..74f0c930cd 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte @@ -57,8 +57,8 @@ let dragDisabled = true $: settings = getComponentSettings($selectedComponent?._component)?.concat({ - label: "CSS", - key: "css", + label: "Custom CSS", + key: "_css", type: "text", }) $: settingOptions = settings.map(setting => ({ diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/CustomStylesSection.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/CustomStylesSection.svelte index 187d9ff760..1c7eddc476 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/CustomStylesSection.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/CustomStylesSection.svelte @@ -1,30 +1,41 @@