Skip to content

Commit

Permalink
fix: enable rowspan for section widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Sep 9, 2024
1 parent 7be8e20 commit 7961a10
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dev/dashboard-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</vaadin-dashboard-widget>

<vaadin-dashboard-section section-title="Section">
<vaadin-dashboard-widget widget-title="Sales closed this month">
<vaadin-dashboard-widget style="--vaadin-dashboard-item-rowspan: 2" widget-title="Sales closed this month">
<div class="kpi-number">54 000€</div>
</vaadin-dashboard-widget>

Expand Down
1 change: 1 addition & 0 deletions dev/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
items: [
{
title: 'Sales closed this month',
rowspan: 2,
content: '54 000€',
type: 'kpi',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/dashboard/src/vaadin-dashboard-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class DashboardSection extends ControllerMixin(ElementMixin(PolylitMixin(LitElem
);
grid-column: var(--_vaadin-dashboard-item-column);
--_vaadin-dashboard-item-row: span var(--vaadin-dashboard-item-rowspan, 1);
grid-row: var(--_vaadin-dashboard-item-row);
}
header {
Expand Down
15 changes: 15 additions & 0 deletions packages/dashboard/test/dashboard-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ describe('dashboard layout', () => {

describe('row span', () => {
it('should span multiple rows', async () => {
setMinimumRowHeight(dashboard, 100);
setRowspan(childElements[0], 2);
await nextFrame();

Expand All @@ -275,6 +276,7 @@ describe('dashboard layout', () => {
});

it('should span multiple rows on a single column', async () => {
setMinimumRowHeight(dashboard, 100);
setRowspan(childElements[0], 2);
await nextFrame();

Expand Down Expand Up @@ -457,6 +459,19 @@ describe('dashboard layout', () => {
]);
});

it('should span multiple rows inside a section', async () => {
setMinimumRowHeight(dashboard, 100);
setRowspan(childElements[2], 2);
await nextFrame();

/* prettier-ignore */
expectLayout(dashboard, [
[0, 1],
[2, 3],
[2, null]
]);
});

it('should use minimum row height for all section rows', async () => {
dashboard.style.width = `${columnWidth}px`;
setMinimumRowHeight(dashboard, 300);
Expand Down

0 comments on commit 7961a10

Please sign in to comment.