Update how screen layout param is handled

This commit is contained in:
Andrew Kingston 2024-08-01 11:40:16 +01:00
parent 99c7859fb2
commit 8879188595
No known key found for this signature in database
7 changed files with 14 additions and 35 deletions

View File

@ -126,7 +126,7 @@
},
},
{
key: "layout",
key: "props.layout",
label: "Layout",
defaultValue: "flex",
control: BarButtonList,

View File

@ -71,4 +71,7 @@
div {
position: relative;
}
div :global(> .component > *) {
flex: 1 1 auto;
}
</style>

View File

@ -13,29 +13,10 @@
const onLoadActions = memo()
// Get the screen definition for the current route
$: screenDefinition = getScreenDefinition($screenStore.activeScreen)
$: screenDefinition = $screenStore.activeScreen?.props
$: onLoadActions.set($screenStore.activeScreen?.onLoad)
$: runOnLoadActions($onLoadActions, params)
const getScreenDefinition = activeScreen => {
if (!activeScreen) {
return null
}
// Enrich screen definition with some builder screen props and styles
return {
...activeScreen.props,
layout: activeScreen.layout,
_styles: {
...activeScreen.props._styles,
normal: {
...activeScreen.props._styles?.normal,
flex: "1 1 auto",
},
},
}
}
// Enrich and execute any on load actions.
// We manually construct the full context here as this component is the
// one that provides the url context, so it is not available in $context yet

View File

@ -37,7 +37,6 @@
export let openLogoLinkInNewTab
export let textAlign
export let embedded = false
export let pageLayout = "flex"
const NavigationClasses = {
Top: "top",
@ -319,7 +318,7 @@
}
}}
>
<div class="main size--{pageWidthClass} layout--{pageLayout}">
<div class="main size--{pageWidthClass}">
<slot />
</div>
</div>
@ -481,7 +480,7 @@
position: relative;
padding: 32px;
}
.main.layout--grid {
.main:has(> .grid) {
padding-top: 0;
padding-bottom: 0;
}

View File

@ -1,9 +1,10 @@
<script>
import { onMount, onDestroy } from "svelte"
import Indicator from "./Indicator.svelte"
import { builderStore, componentStore } from "stores"
import { componentStore } from "stores"
import { memo, Utils } from "@budibase/frontend-core"
import { writable } from "svelte/store"
import { isGridChild } from "utils/grid"
export let componentId = null
export let color = null
@ -58,15 +59,7 @@
const checkInsideGrid = id => {
const component = document.getElementsByClassName(id)[0]
const domNode = component?.children[0]
// Ignore grid itself
if (domNode?.classList?.contains("grid")) {
return false
}
return component?.parentNode
?.closest?.(".component")
?.childNodes[0]?.classList?.contains("grid")
return isGridChild(domNode)
}
const createIntersectionCallback = idx => entries => {

View File

@ -132,7 +132,6 @@ const createScreenStore = () => {
let layoutSettings = {
navigation: "None",
pageWidth: activeScreen?.width || "Large",
pageLayout: activeScreen?.layout || "flex",
embedded: $appStore.embedded,
}
if (activeScreen?.showNavigation) {

View File

@ -58,6 +58,10 @@ export const isGridEvent = e => {
// Determines whether a DOM element is an immediate child of a grid
export const isGridChild = node => {
// Ignore grid itself
if (node?.classList?.contains("grid")) {
return false
}
return node
?.closest(".component")
?.parentNode.closest(".component")