Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(util): Added support for rows in the wrapPanels function #215

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions custom/util/grid.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ local panelUtil = import './panel.libsonnet';
function(acc, panel)
if panel.type == 'row'
then
// when type=row, start new row immediatly and shift Y of new row by max height recorded
// when type=row, start new row immediately and shift Y of new row by max height recorded
local wrappedPanels = if std.objectHas(panel, 'panels') then root.wrapPanels(panel.panels, panelWidth, panelHeight, acc.cursor.y + acc.cursor.maxH + 1) else [];
local maxWrappedY = std.foldl(function(maxY, p) if p.gridPos.y + p.gridPos.h > maxY then p.gridPos.y + p.gridPos.h else maxY, wrappedPanels, 0);
acc + {
panels+: [
panel + {
Expand All @@ -105,11 +107,12 @@ local panelUtil = import './panel.libsonnet';
w: 0,
h: 1,
},
panels: wrappedPanels,
},
],
cursor:: {
cursor+:: {
x: 0,
y: acc.cursor.y + acc.cursor.maxH + 1,
y: acc.cursor.y + acc.cursor.maxH + 1 + maxWrappedY,
maxH: 0,
},
}
Expand All @@ -127,16 +130,16 @@ local panelUtil = import './panel.libsonnet';
gridPos+:
{
x: 0,
y: acc.cursor.y + height,
y: acc.cursor.y + acc.cursor.maxH,
w: width,
h: height,
},
},
],
cursor+:: {
x: 0 + width,
y: acc.cursor.y + height,
maxH: if height > super.maxH then height else super.maxH,
y: acc.cursor.y + acc.cursor.maxH,
maxH: height,
},
}
else
Expand All @@ -156,7 +159,7 @@ local panelUtil = import './panel.libsonnet';
cursor+:: {
x: acc.cursor.x + width,
y: acc.cursor.y,
maxH: if height > super.maxH then height else super.maxH,
maxH: if height > acc.cursor.maxH then height else acc.cursor.maxH,
},
},
panels,
Expand Down