Update how screen layout param is handled
This commit is contained in:
parent
99c7859fb2
commit
8879188595
|
@ -126,7 +126,7 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "layout",
|
key: "props.layout",
|
||||||
label: "Layout",
|
label: "Layout",
|
||||||
defaultValue: "flex",
|
defaultValue: "flex",
|
||||||
control: BarButtonList,
|
control: BarButtonList,
|
||||||
|
|
|
@ -71,4 +71,7 @@
|
||||||
div {
|
div {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
div :global(> .component > *) {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,29 +13,10 @@
|
||||||
const onLoadActions = memo()
|
const onLoadActions = memo()
|
||||||
|
|
||||||
// Get the screen definition for the current route
|
// Get the screen definition for the current route
|
||||||
$: screenDefinition = getScreenDefinition($screenStore.activeScreen)
|
$: screenDefinition = $screenStore.activeScreen?.props
|
||||||
$: onLoadActions.set($screenStore.activeScreen?.onLoad)
|
$: onLoadActions.set($screenStore.activeScreen?.onLoad)
|
||||||
$: runOnLoadActions($onLoadActions, params)
|
$: 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.
|
// Enrich and execute any on load actions.
|
||||||
// We manually construct the full context here as this component is the
|
// 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
|
// one that provides the url context, so it is not available in $context yet
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
export let openLogoLinkInNewTab
|
export let openLogoLinkInNewTab
|
||||||
export let textAlign
|
export let textAlign
|
||||||
export let embedded = false
|
export let embedded = false
|
||||||
export let pageLayout = "flex"
|
|
||||||
|
|
||||||
const NavigationClasses = {
|
const NavigationClasses = {
|
||||||
Top: "top",
|
Top: "top",
|
||||||
|
@ -319,7 +318,7 @@
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="main size--{pageWidthClass} layout--{pageLayout}">
|
<div class="main size--{pageWidthClass}">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -481,7 +480,7 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 32px;
|
padding: 32px;
|
||||||
}
|
}
|
||||||
.main.layout--grid {
|
.main:has(> .grid) {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount, onDestroy } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
import Indicator from "./Indicator.svelte"
|
import Indicator from "./Indicator.svelte"
|
||||||
import { builderStore, componentStore } from "stores"
|
import { componentStore } from "stores"
|
||||||
import { memo, Utils } from "@budibase/frontend-core"
|
import { memo, Utils } from "@budibase/frontend-core"
|
||||||
import { writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
|
import { isGridChild } from "utils/grid"
|
||||||
|
|
||||||
export let componentId = null
|
export let componentId = null
|
||||||
export let color = null
|
export let color = null
|
||||||
|
@ -58,15 +59,7 @@
|
||||||
const checkInsideGrid = id => {
|
const checkInsideGrid = id => {
|
||||||
const component = document.getElementsByClassName(id)[0]
|
const component = document.getElementsByClassName(id)[0]
|
||||||
const domNode = component?.children[0]
|
const domNode = component?.children[0]
|
||||||
|
return isGridChild(domNode)
|
||||||
// Ignore grid itself
|
|
||||||
if (domNode?.classList?.contains("grid")) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return component?.parentNode
|
|
||||||
?.closest?.(".component")
|
|
||||||
?.childNodes[0]?.classList?.contains("grid")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const createIntersectionCallback = idx => entries => {
|
const createIntersectionCallback = idx => entries => {
|
||||||
|
|
|
@ -132,7 +132,6 @@ const createScreenStore = () => {
|
||||||
let layoutSettings = {
|
let layoutSettings = {
|
||||||
navigation: "None",
|
navigation: "None",
|
||||||
pageWidth: activeScreen?.width || "Large",
|
pageWidth: activeScreen?.width || "Large",
|
||||||
pageLayout: activeScreen?.layout || "flex",
|
|
||||||
embedded: $appStore.embedded,
|
embedded: $appStore.embedded,
|
||||||
}
|
}
|
||||||
if (activeScreen?.showNavigation) {
|
if (activeScreen?.showNavigation) {
|
||||||
|
|
|
@ -58,6 +58,10 @@ export const isGridEvent = e => {
|
||||||
|
|
||||||
// Determines whether a DOM element is an immediate child of a grid
|
// Determines whether a DOM element is an immediate child of a grid
|
||||||
export const isGridChild = node => {
|
export const isGridChild = node => {
|
||||||
|
// Ignore grid itself
|
||||||
|
if (node?.classList?.contains("grid")) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return node
|
return node
|
||||||
?.closest(".component")
|
?.closest(".component")
|
||||||
?.parentNode.closest(".component")
|
?.parentNode.closest(".component")
|
||||||
|
|
Loading…
Reference in New Issue