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}
diff --git a/packages/builder/src/components/design/AppPreview/DevicePreviewSelect.svelte b/packages/builder/src/components/design/AppPreview/DevicePreviewSelect.svelte
new file mode 100644
index 0000000000..9f9447daee
--- /dev/null
+++ b/packages/builder/src/components/design/AppPreview/DevicePreviewSelect.svelte
@@ -0,0 +1,22 @@
+
+
+
+ store.actions.preview.setDevice("desktop")}
+ />
+ store.actions.preview.setDevice("tablet")}
+ />
+ store.actions.preview.setDevice("mobile")}
+ />
+
diff --git a/packages/builder/src/components/design/AppPreview/iframeTemplate.js b/packages/builder/src/components/design/AppPreview/iframeTemplate.js
index 85f008df08..97f3c472e1 100644
--- a/packages/builder/src/components/design/AppPreview/iframeTemplate.js
+++ b/packages/builder/src/components/design/AppPreview/iframeTemplate.js
@@ -67,7 +67,8 @@ export default `
previewType,
appId,
theme,
- customTheme
+ customTheme,
+ previewDevice
} = parsed
// Set some flags so the app knows we're in the builder
@@ -80,6 +81,7 @@ export default `
window["##BUDIBASE_PREVIEW_TYPE##"] = previewType
window["##BUDIBASE_PREVIEW_THEME##"] = theme
window["##BUDIBASE_PREVIEW_CUSTOM_THEME##"] = customTheme
+ window["##BUDIBASE_PREVIEW_DEVICE##"] = previewDevice
// Initialise app
try {
diff --git a/packages/builder/src/pages/builder/app/[application]/design/[assetType]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[assetType]/_layout.svelte
index fb9cdf885c..ac9bf7e700 100644
--- a/packages/builder/src/pages/builder/app/[application]/design/[assetType]/_layout.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/design/[assetType]/_layout.svelte
@@ -15,6 +15,7 @@
import { get } from "svelte/store"
import AppThemeSelect from "components/design/AppPreview/AppThemeSelect.svelte"
import ThemeEditor from "components/design/AppPreview/ThemeEditor.svelte"
+ import DevicePreviewSelect from "components/design/AppPreview/DevicePreviewSelect.svelte"
// Cache previous values so we don't update the URL more than necessary
let previousType
@@ -151,6 +152,7 @@
{#if $currentAsset}