From fbbeccc0a10712badf1ea127501980153f6e274b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 7 Sep 2021 16:02:11 +0100 Subject: [PATCH] Add preview device selection buttons and pass device preview down to client app --- .../src/builderStore/store/frontend.js | 7 ++++++ .../AppPreview/CurrentItemPreview.svelte | 22 ++++++++++++++++++- .../AppPreview/DevicePreviewSelect.svelte | 22 +++++++++++++++++++ .../design/AppPreview/iframeTemplate.js | 4 +++- .../design/[assetType]/_layout.svelte | 3 +++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 packages/builder/src/components/design/AppPreview/DevicePreviewSelect.svelte diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 7d0b9d0547..8189a28250 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -56,6 +56,7 @@ const INITIAL_FRONTEND_STATE = { clientLibPath: "", theme: "", customTheme: {}, + previewDevice: "desktop", } export const getFrontendStore = () => { @@ -230,6 +231,12 @@ export const getFrontendStore = () => { await store.actions.layouts.save(selectedAsset) } }, + setDevice: device => { + store.update(state => { + state.previewDevice = device + return state + }) + }, }, layouts: { select: layoutId => { diff --git a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte index 85fb086b59..e646fb86e9 100644 --- a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte +++ b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte @@ -50,6 +50,7 @@ previewType: $store.currentFrontEndType, theme: $store.theme, customTheme: $store.customTheme, + previewDevice: $store.previewDevice, } // Saving pages and screens to the DB causes them to have _revs. @@ -140,11 +141,12 @@ {/if}