Update some component manifest styles and fix issue with default grid vars
This commit is contained in:
parent
4e9e644e13
commit
9906ea96a9
|
@ -114,13 +114,12 @@
|
||||||
"icon": "Selection",
|
"icon": "Selection",
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 500,
|
||||||
"height": 200
|
"height": 200
|
||||||
},
|
},
|
||||||
"grid": {
|
"grid": {
|
||||||
"hAlign": "stretch",
|
"hAlign": "stretch",
|
||||||
"vAlign": "stretch",
|
"vAlign": "stretch"
|
||||||
"showControls": false
|
|
||||||
},
|
},
|
||||||
"styles": ["padding", "size", "background", "border", "shadow"],
|
"styles": ["padding", "size", "background", "border", "shadow"],
|
||||||
"settings": [
|
"settings": [
|
||||||
|
@ -363,8 +362,12 @@
|
||||||
"illegalChildren": ["section"],
|
"illegalChildren": ["section"],
|
||||||
"showEmptyState": false,
|
"showEmptyState": false,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 600,
|
||||||
"height": 100
|
"height": 200
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "stretch"
|
||||||
},
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -735,8 +738,12 @@
|
||||||
"illegalChildren": ["section"],
|
"illegalChildren": ["section"],
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 500,
|
||||||
"height": 100
|
"height": 200
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "stretch"
|
||||||
},
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -4963,8 +4970,12 @@
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"actions": ["RefreshDatasource"],
|
"actions": ["RefreshDatasource"],
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 500,
|
||||||
"height": 100
|
"height": 200
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "stretch"
|
||||||
},
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -5281,6 +5292,10 @@
|
||||||
"width": 100,
|
"width": 100,
|
||||||
"height": 35
|
"height": 35
|
||||||
},
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "center",
|
||||||
|
"vAlign": "center"
|
||||||
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"type": "dataProvider",
|
"type": "dataProvider",
|
||||||
|
@ -5327,6 +5342,14 @@
|
||||||
"name": "Chart Block",
|
"name": "Chart Block",
|
||||||
"icon": "GraphPie",
|
"icon": "GraphPie",
|
||||||
"hasChildren": false,
|
"hasChildren": false,
|
||||||
|
"size": {
|
||||||
|
"width": 600,
|
||||||
|
"height": 400
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "stretch"
|
||||||
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"type": "select",
|
"type": "select",
|
||||||
|
@ -6250,6 +6273,10 @@
|
||||||
"width": 600,
|
"width": 600,
|
||||||
"height": 400
|
"height": 400
|
||||||
},
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "stretch"
|
||||||
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -6459,8 +6486,12 @@
|
||||||
"illegalChildren": ["section", "rowexplorer"],
|
"illegalChildren": ["section", "rowexplorer"],
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 500,
|
||||||
"height": 100
|
"height": 200
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "stretch"
|
||||||
},
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -6731,9 +6762,13 @@
|
||||||
"hasChildren": false,
|
"hasChildren": false,
|
||||||
"ejectable": false,
|
"ejectable": false,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 600,
|
||||||
"height": 400
|
"height": 400
|
||||||
},
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "start"
|
||||||
|
},
|
||||||
"styles": ["size"],
|
"styles": ["size"],
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -6922,7 +6957,7 @@
|
||||||
"block": true,
|
"block": true,
|
||||||
"info": "Form blocks are only compatible with internal or SQL tables",
|
"info": "Form blocks are only compatible with internal or SQL tables",
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 600,
|
||||||
"height": 400
|
"height": 400
|
||||||
},
|
},
|
||||||
"grid": {
|
"grid": {
|
||||||
|
@ -7147,8 +7182,12 @@
|
||||||
"name": "Row Explorer Block",
|
"name": "Row Explorer Block",
|
||||||
"icon": "PersonalizationField",
|
"icon": "PersonalizationField",
|
||||||
"size": {
|
"size": {
|
||||||
"width": 600,
|
"width": 800,
|
||||||
"height": 400
|
"height": 426
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"hAlign": "stretch",
|
||||||
|
"vAlign": "start"
|
||||||
},
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -7272,8 +7311,7 @@
|
||||||
},
|
},
|
||||||
"grid": {
|
"grid": {
|
||||||
"hAlign": "stretch",
|
"hAlign": "stretch",
|
||||||
"vAlign": "stretch",
|
"vAlign": "stretch"
|
||||||
"showControls": false
|
|
||||||
},
|
},
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -634,6 +634,8 @@
|
||||||
// Generates any required base styles based on the component definition
|
// Generates any required base styles based on the component definition
|
||||||
const getBaseStyles = definition => {
|
const getBaseStyles = definition => {
|
||||||
return {
|
return {
|
||||||
|
"--default-width": definition.size?.width || 100,
|
||||||
|
"--default-height": definition.size?.height || 100,
|
||||||
...getBaseGridVars(definition),
|
...getBaseGridVars(definition),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
...$component.styles?.normal,
|
...$component.styles?.normal,
|
||||||
"--cols": cols,
|
"--cols": cols,
|
||||||
"--rows": rows,
|
"--rows": rows,
|
||||||
"--col-size": `${colSize}px`,
|
"--col-size": colSize,
|
||||||
"--row-size": `${rowSize}px`,
|
"--row-size": rowSize,
|
||||||
},
|
},
|
||||||
empty: false,
|
empty: false,
|
||||||
}}
|
}}
|
||||||
|
@ -70,14 +70,14 @@
|
||||||
gap: 0;
|
gap: 0;
|
||||||
|
|
||||||
/* Prevent cross-grid variable inheritance */
|
/* Prevent cross-grid variable inheritance */
|
||||||
--grid-desktop-col-start: initial;
|
/* --grid-desktop-col-start: initial;
|
||||||
--grid-desktop-col-end: initial;
|
--grid-desktop-col-end: initial;
|
||||||
--grid-desktop-row-start: initial;
|
--grid-desktop-row-start: initial;
|
||||||
--grid-desktop-row-end: initial;
|
--grid-desktop-row-end: initial;
|
||||||
--grid-mobile-col-start: initial;
|
--grid-mobile-col-start: initial;
|
||||||
--grid-mobile-col-end: initial;
|
--grid-mobile-col-end: initial;
|
||||||
--grid-mobile-row-start: initial;
|
--grid-mobile-row-start: initial;
|
||||||
--grid-mobile-row-end: initial;
|
--grid-mobile-row-end: initial;*/
|
||||||
}
|
}
|
||||||
.grid,
|
.grid,
|
||||||
.underlay {
|
.underlay {
|
||||||
|
@ -111,9 +111,22 @@
|
||||||
/* On desktop, use desktop metadata and fall back to mobile */
|
/* On desktop, use desktop metadata and fall back to mobile */
|
||||||
/* Position vars */
|
/* Position vars */
|
||||||
--col-start: var(--grid-desktop-col-start, var(--grid-mobile-col-start, 1));
|
--col-start: var(--grid-desktop-col-start, var(--grid-mobile-col-start, 1));
|
||||||
--col-end: var(--grid-desktop-col-end, var(--grid-mobile-col-end, 2));
|
--col-end: var(
|
||||||
|
--grid-desktop-col-end,
|
||||||
|
var(
|
||||||
|
--grid-mobile-col-end,
|
||||||
|
/* Our final*/
|
||||||
|
round(up, calc(var(--default-width) / var(--col-size) + 1))
|
||||||
|
)
|
||||||
|
);
|
||||||
--row-start: var(--grid-desktop-row-start, var(--grid-mobile-row-start, 1));
|
--row-start: var(--grid-desktop-row-start, var(--grid-mobile-row-start, 1));
|
||||||
--row-end: var(--grid-desktop-row-end, var(--grid-mobile-row-end, 2));
|
--row-end: var(
|
||||||
|
--grid-desktop-row-end,
|
||||||
|
var(
|
||||||
|
--grid-mobile-row-end,
|
||||||
|
round(up, calc(var(--default-height) / var(--row-size) + 1))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
/* Flex vars */
|
/* Flex vars */
|
||||||
--h-align: var(--grid-desktop-h-align, var(--grid-mobile-h-align, stretch));
|
--h-align: var(--grid-desktop-h-align, var(--grid-mobile-h-align, stretch));
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount, onDestroy } from "svelte"
|
import { onMount, onDestroy } from "svelte"
|
||||||
import { get } from "svelte/store"
|
|
||||||
import { builderStore, componentStore } from "stores"
|
import { builderStore, componentStore } from "stores"
|
||||||
import { Utils, memo } from "@budibase/frontend-core"
|
import { Utils, memo } from "@budibase/frontend-core"
|
||||||
import {
|
import { isGridEvent, getGridParentID, getGridVar } from "utils/grid"
|
||||||
isGridEvent,
|
|
||||||
getGridParentID,
|
|
||||||
getGridVar,
|
|
||||||
getGridVarValue,
|
|
||||||
} from "utils/grid"
|
|
||||||
|
|
||||||
// Smallest possible 1x1 transparent GIF
|
// Smallest possible 1x1 transparent GIF
|
||||||
const ghost = new Image(1, 1)
|
const ghost = new Image(1, 1)
|
||||||
|
@ -166,24 +160,21 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id, gridId } = dragInfo
|
const { id, gridId } = dragInfo
|
||||||
|
const domComponent = getDOMNode(id)
|
||||||
const domGrid = getDOMNode(gridId)
|
const domGrid = getDOMNode(gridId)
|
||||||
const gridCols = parseInt(domGrid.dataset.cols)
|
const gridCols = parseInt(domGrid.dataset.cols)
|
||||||
const gridRows = parseInt(domGrid.dataset.rows)
|
const gridRows = parseInt(domGrid.dataset.rows)
|
||||||
const instance = get(componentStore.actions.getComponentInstance(id))
|
const styles = getComputedStyle(domComponent.parentNode)
|
||||||
if (!instance) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const styles = get(instance.state).styles
|
|
||||||
if (domGrid) {
|
if (domGrid) {
|
||||||
dragInfo.grid = {
|
dragInfo.grid = {
|
||||||
startX: e.clientX,
|
startX: e.clientX,
|
||||||
startY: e.clientY,
|
startY: e.clientY,
|
||||||
|
|
||||||
// Ensure things are within limits
|
// Ensure things are within limits
|
||||||
rowStart: minMax(getGridVarValue(styles, vars.rowStart), 1, gridRows),
|
rowStart: minMax(styles["grid-row-start"], 1, gridRows),
|
||||||
rowEnd: minMax(getGridVarValue(styles, vars.rowEnd), 2, gridRows + 1),
|
rowEnd: minMax(styles["grid-row-end"], 2, gridRows + 1),
|
||||||
colStart: minMax(getGridVarValue(styles, vars.colStart), 1, gridCols),
|
colStart: minMax(styles["grid-column-start"], 1, gridCols),
|
||||||
colEnd: minMax(getGridVarValue(styles, vars.colEnd), 2, gridCols + 1),
|
colEnd: minMax(styles["grid-column-end"], 2, gridCols + 1),
|
||||||
}
|
}
|
||||||
handleEvent(e)
|
handleEvent(e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
export let componentId
|
export let componentId
|
||||||
|
|
||||||
$: currentValue = getGridVarValue(gridStyles, style)
|
$: currentValue = getGridVarValue(gridStyles, style)
|
||||||
|
$: console.log(style, currentValue, value)
|
||||||
$: active = currentValue === value
|
$: active = currentValue === value
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,10 @@
|
||||||
$: isRoot = componentId === $builderStore.screen?.props?._id
|
$: isRoot = componentId === $builderStore.screen?.props?._id
|
||||||
$: insideGrid =
|
$: insideGrid =
|
||||||
parent?._component.endsWith("/container") && parent.layout === "grid"
|
parent?._component.endsWith("/container") && parent.layout === "grid"
|
||||||
$: showGridStyles = insideGrid && definition?.grid?.showControls !== false
|
$: showGridStyles =
|
||||||
|
insideGrid &&
|
||||||
|
(definition?.grid?.hAlign !== "stretch" ||
|
||||||
|
definition?.grid?.vAlign !== "stretch")
|
||||||
$: gridHAlignVar = $getGridVar("h-align")
|
$: gridHAlignVar = $getGridVar("h-align")
|
||||||
$: gridVAlignVar = $getGridVar("v-align")
|
$: gridVAlignVar = $getGridVar("v-align")
|
||||||
$: gridStyles = $state?.styles
|
$: gridStyles = $state?.styles
|
||||||
|
|
|
@ -70,23 +70,17 @@ export const getGridParentID = node => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates the base set of grid CSS vars from a component definition
|
// Generates the base set of grid CSS vars from a component definition
|
||||||
const alignmentToStyleMap = {
|
|
||||||
start: "flex-start",
|
|
||||||
center: "center",
|
|
||||||
end: "flex-end",
|
|
||||||
stretch: "stretch",
|
|
||||||
}
|
|
||||||
export const getBaseGridVars = definition => {
|
export const getBaseGridVars = definition => {
|
||||||
const gridHAlign = definition?.grid?.hAlign || "stretch"
|
const gridHAlign = definition?.grid?.hAlign || "stretch"
|
||||||
const gridVAlign = definition?.grid?.vAlign || "center"
|
const gridVAlign = definition?.grid?.vAlign || "center"
|
||||||
const flexStyles = gridVAlign === "stretch" ? "1 1 0" : "0 0 auto"
|
const flexStyles = gridVAlign === "stretch" ? "1 1 0" : "0 0 auto"
|
||||||
return {
|
return {
|
||||||
["--grid-desktop-h-align"]: alignmentToStyleMap[gridHAlign],
|
"--grid-desktop-h-align": gridHAlign,
|
||||||
["--grid-mobile-h-align"]: alignmentToStyleMap[gridHAlign],
|
"--grid-mobile-h-align": gridHAlign,
|
||||||
["--grid-desktop-v-align"]: alignmentToStyleMap[gridVAlign],
|
"--grid-desktop-v-align": gridVAlign,
|
||||||
["--grid-mobile-v-align"]: alignmentToStyleMap[gridVAlign],
|
"--grid-mobile-v-align": gridVAlign,
|
||||||
["--grid-desktop-child-flex"]: flexStyles,
|
"--grid-desktop-child-flex": flexStyles,
|
||||||
["--grid-mobile-child-flex"]: flexStyles,
|
"--grid-mobile-child-flex": flexStyles,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue