diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js
index 7d0b9d0547..603fa88b09 100644
--- a/packages/builder/src/builderStore/store/frontend.js
+++ b/packages/builder/src/builderStore/store/frontend.js
@@ -43,6 +43,7 @@ const INITIAL_FRONTEND_STATE = {
deviceAwareness: false,
state: false,
customThemes: false,
+ devicePreview: false,
},
currentFrontEndType: "none",
selectedScreenId: "",
@@ -56,6 +57,7 @@ const INITIAL_FRONTEND_STATE = {
clientLibPath: "",
theme: "",
customTheme: {},
+ previewDevice: "desktop",
}
export const getFrontendStore = () => {
@@ -230,6 +232,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/ComponentSelectionList.svelte b/packages/builder/src/components/design/AppPreview/ComponentSelectionList.svelte
index 9893b07404..a968effaf5 100644
--- a/packages/builder/src/components/design/AppPreview/ComponentSelectionList.svelte
+++ b/packages/builder/src/components/design/AppPreview/ComponentSelectionList.svelte
@@ -83,10 +83,11 @@
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
- margin-top: -10px;
}
.components :global(> *) {
- margin-top: 10px;
+ height: 32px;
+ display: grid;
+ place-items: center;
}
.buttonContent {
diff --git a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte
index 85fb086b59..494050f690 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..d992be8cd7 100644
--- a/packages/builder/src/components/design/AppPreview/iframeTemplate.js
+++ b/packages/builder/src/components/design/AppPreview/iframeTemplate.js
@@ -17,18 +17,14 @@ export default `
margin: 0;
}
html {
- height: calc(100% - 16px);
- width: calc(100% - 16px);
+ height: 100%;
+ width: 100%;
overflow: hidden;
- margin: 8px;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
- html.loaded {
- box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.1);
- }
body {
flex: 1 1 auto;
overflow: hidden;
@@ -67,7 +63,8 @@ export default `
previewType,
appId,
theme,
- customTheme
+ customTheme,
+ previewDevice
} = parsed
// Set some flags so the app knows we're in the builder
@@ -80,6 +77,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..d3e5d5d2d0 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,9 @@
{#if $currentAsset}