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

Removed dynamic stylesheet and migrated to CSS vars #2854

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
7 changes: 6 additions & 1 deletion src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,12 @@ export class GridStack {
if ((!n._moving && !n._resizing) || this._placeholder === el) {
// Set inline style, refer CSS variables
lmartorella marked this conversation as resolved.
Show resolved Hide resolved
el.style.top = `calc(${n.y} * var(--gs-cell-height))`;
el.style.height = `calc(${n.h} * var(--gs-cell-height))`;
if (n.h !== 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n.h > 1 ? el.style.height = calc(${n.h} * var(--gs-cell-height)) : delete el.style.height; // default h=1 set globally

to match above case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will trigger the

Extract the assignment of "el.style.height" from this expression.sonarlint(typescript:S1121)

sonar lint issue, part of the recommended TS set.
I quite agree to that, being a "delete" part of else branch as well.
A better way is probably trying to assign an empty string to height, or undefined.

el.style.height = `calc(${n.h} * var(--gs-cell-height))`;
} else {
// height is set to --gs-cell-height by default
delete el.style.height;
}
}
return this;
}
Expand Down