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

refactor: add default min row height to dashboard #8099

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/dashboard/src/vaadin-dashboard-item-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const DashboardItemMixin = (superClass) =>

/** @private */
__renderResizeControls() {
const hasMinRowHeight = getComputedStyle(this).getPropertyValue('--vaadin-dashboard-row-min-height');
const hasMinRowHeight = getComputedStyle(this).getPropertyValue('--_vaadin-dashboard-row-min-height') !== 'auto';

return html`<div
id="resize-controls"
Expand Down
9 changes: 8 additions & 1 deletion packages/dashboard/src/vaadin-dashboard-layout-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ export const DashboardLayoutMixin = (superClass) =>
var(--_vaadin-dashboard-col-max-count)
);

/* Default row min height */
--_vaadin-dashboard-default-row-min-height: 12rem;
/* Effective row min height */
--_vaadin-dashboard-row-min-height: var(
--vaadin-dashboard-row-min-height,
var(--_vaadin-dashboard-default-row-min-height)
);
/* Effective row height */
--_vaadin-dashboard-row-height: minmax(var(--vaadin-dashboard-row-min-height, auto), auto);
--_vaadin-dashboard-row-height: minmax(var(--_vaadin-dashboard-row-min-height, auto), auto);

display: grid;
overflow: auto;
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/widget-resize-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class WidgetResizeController {
}

const gridStyle = getComputedStyle(this.host.$.grid);
if (rowspanDelta && !gridStyle.getPropertyValue('--vaadin-dashboard-row-min-height')) {
if (rowspanDelta && gridStyle.getPropertyValue('--_vaadin-dashboard-row-min-height') === 'auto') {
// Do not resize vertically if the min row height is not set
return;
}
Expand Down
1 change: 1 addition & 0 deletions packages/dashboard/test/dashboard-keyboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('dashboard - keyboard interaction', () => {
dashboard.addEventListener('keydown', keydownSpy);
setMinimumColumnWidth(dashboard, columnWidth);
setMaximumColumnWidth(dashboard, columnWidth);
setMinimumRowHeight(dashboard, undefined);
setSpacing(dashboard, 0);

dashboard.items = [{ id: 0 }, { id: 1 }, { items: [{ id: 2 }, { id: 3 }] }];
Expand Down
1 change: 1 addition & 0 deletions packages/dashboard/test/dashboard-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('dashboard layout', () => {
// Set the column width to a fixed value
setMinimumColumnWidth(dashboard, columnWidth);
setMaximumColumnWidth(dashboard, columnWidth);
setMinimumRowHeight(dashboard, undefined);
// Make the dashboard wide enough to fit all items on a single row
dashboard.style.width = `${columnWidth * dashboard.childElementCount}px`;

Expand Down
2 changes: 2 additions & 0 deletions packages/dashboard/test/dashboard-widget-reordering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
resetReorderTimeout,
setMaximumColumnWidth,
setMinimumColumnWidth,
setMinimumRowHeight,
setSpacing,
} from './helpers.js';

Expand All @@ -34,6 +35,7 @@ describe('dashboard - widget reordering', () => {

setMinimumColumnWidth(dashboard, columnWidth);
setMaximumColumnWidth(dashboard, columnWidth);
setMinimumRowHeight(dashboard, undefined);
setSpacing(dashboard, 0);

dashboard.editable = true;
Expand Down
2 changes: 2 additions & 0 deletions packages/dashboard/test/dashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
onceResized,
setMaximumColumnWidth,
setMinimumColumnWidth,
setMinimumRowHeight,
setSpacing,
} from './helpers.js';

Expand All @@ -34,6 +35,7 @@ describe('dashboard', () => {
dashboard.style.width = `${columnWidth * 2}px`;
setMinimumColumnWidth(dashboard, columnWidth);
setMaximumColumnWidth(dashboard, columnWidth);
setMinimumRowHeight(dashboard, undefined);
setSpacing(dashboard, 0);

dashboard.items = [{ id: '0' }, { id: '1' }];
Expand Down
6 changes: 5 additions & 1 deletion packages/dashboard/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export function setMaximumColumnCount(dashboard: HTMLElement, count?: number): v
* Sets the minimum row height of the dashboard.
*/
export function setMinimumRowHeight(dashboard: HTMLElement, height?: number): void {
dashboard.style.setProperty('--vaadin-dashboard-row-min-height', height !== undefined ? `${height}px` : null);
if (height === undefined) {
dashboard.style.setProperty('--vaadin-dashboard-row-min-height', 'auto');
} else {
dashboard.style.setProperty('--vaadin-dashboard-row-min-height', height !== undefined ? `${height}px` : null);
}
}

/**
Expand Down