Skip to content

Commit 8d05f2d

Browse files
committed
wip
1 parent efd8755 commit 8d05f2d

File tree

3 files changed

+126
-50
lines changed

3 files changed

+126
-50
lines changed

packages/grid/src/styles/vaadin-grid-base-styles.js

Lines changed: 84 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -121,35 +121,66 @@ export const gridStyles = css`
121121
[part~='reorder-ghost'] {
122122
font-size: var(--vaadin-grid-header-font-size, 1em);
123123
font-weight: var(--vaadin-grid-header-font-weight, 500);
124-
color: var(--vaadin-grid-text-header-color, var(--vaadin-text-color));
124+
color: var(--vaadin-grid-header-text-color, var(--vaadin-text-color));
125125
}
126126
127127
[part~='row'] {
128-
display: flex;
128+
--_row-background-color: var(--vaadin-grid-row-background-color, var(--vaadin-background-color));
129+
display: grid;
130+
grid-template-columns: var(--_template-columns);
131+
grid-template-rows: min-content 4px;
129132
width: 100%;
130133
box-sizing: border-box;
131134
margin: 0;
132135
position: relative;
133-
}
134136
135-
[part~='row']:empty {
136-
height: 100%;
137-
}
137+
&::before {
138+
content: '';
139+
display: none;
140+
position: absolute;
141+
box-sizing: border-box;
142+
grid-row: 1 / -1;
143+
grid-column: 1 / -1;
144+
inset: calc(var(--_row-border-width) * -1) 0 0 0;
145+
background-image: var(--_selected-background-image);
146+
background-color: var(--_row-background-color);
147+
border-block: var(--_row-border-width) solid var(--_border-color);
148+
}
138149
139-
[part~='row'][loading] [part~='body-cell'] ::slotted(vaadin-grid-cell-content) {
140-
visibility: hidden;
150+
&:empty {
151+
height: 100%;
152+
}
141153
}
142154
143-
[column-rendering='lazy'] [part~='body-cell']:not([frozen]):not([frozen-to-end]) {
144-
transform: translateX(var(--_grid-lazy-columns-start));
155+
[part~='body-row'] {
156+
&::before {
157+
display: block;
158+
}
159+
160+
&:focus,
161+
&:focus-within {
162+
z-index: 4;
163+
164+
&:not([part~='selected-row'])::before {
165+
border-color: transparent;
166+
background-clip: padding-box;
167+
}
168+
}
169+
170+
&[selected] {
171+
z-index: 3;
172+
}
173+
174+
&[loading] [part~='body-cell'] ::slotted(vaadin-grid-cell-content) {
175+
visibility: hidden;
176+
}
145177
}
146178
147179
[part~='cell'] {
148-
--vaadin-grid-cell-background-color: yellow;
180+
grid-row-start: 1;
149181
padding: 0;
150182
box-sizing: border-box;
151183
background: var(--vaadin-grid-cell-background, var(--vaadin-background-color));
152-
border-block: var(--_row-border-width) var(--_border-color);
153184
}
154185
155186
[part~='body-cell'],
@@ -162,7 +193,13 @@ export const gridStyles = css`
162193
position: relative;
163194
align-items: center;
164195
white-space: nowrap;
196+
z-index: 1;
165197
border-inline: var(--_column-border-width) var(--_border-color);
198+
border-block: var(--_row-border-width) var(--_border-color);
199+
200+
&:focus {
201+
z-index: 4;
202+
}
166203
}
167204
168205
/* Column borders */
@@ -179,32 +216,49 @@ export const gridStyles = css`
179216
}
180217
181218
/* Row borders */
219+
/* #table {
220+
background: var(--_border-color);
221+
} */
222+
223+
/* [part~='cell'] {
224+
225+
} */
226+
182227
#header {
183-
padding-bottom: var(--_row-border-width);
184-
margin-bottom: calc(var(--_row-border-width) * -1);
228+
/* padding-bottom: var(--_row-border-width);
229+
margin-bottom: calc(var(--_row-border-width) * -1); */
185230
}
186231
187-
[part~='header-cell']:not([part~='last-header-row-cell']),
188-
[part~='footer-cell']:not([part~='last-footer-row-cell']) {
189-
border-bottom-style: solid;
232+
#header [part~='row'],
233+
#footer [part~='row'] {
234+
&::before {
235+
display: block;
236+
}
237+
}
238+
239+
[part~='first-row-cell'] {
240+
margin-top: 0;
241+
}
242+
[part~='last-header-row-cell'] {
243+
border-bottom: 0;
190244
}
191245
192246
[part~='body-cell']:not([part~='last-row-cell']),
193247
[part~='body-cell']:not([part~='last-row-cell']) + [part~='details-cell'] {
194-
border-bottom-style: solid;
248+
/* padding-bottom: var(--_row-border-width); */
195249
}
196250
197251
/* Grid with header */
198252
#table:has(#header > tr:not([hidden])) {
199253
[part~='first-row-cell'] {
200-
border-block-start-style: solid;
254+
/* padding-top: var(--_row-border-width); */
201255
}
202256
}
203257
204258
/* Grid with footer */
205259
#table:has(#footer > tr:not([hidden])) {
206260
[part~='last-row-cell'] {
207-
border-block-end-style: solid;
261+
/* padding-bottom: var(--_row-border-width); */
208262
}
209263
}
210264
@@ -229,7 +283,11 @@ export const gridStyles = css`
229283
var(--_hover-background-image, none) padding-box,
230284
var(--_selected-background-image, none) border-box,
231285
var(--_highlight-background-image) padding-box,
232-
var(--vaadin-grid-cell-background-color) border-box;
286+
var(--vaadin-grid-cell-background-color, var(--_row-background-color)) border-box;
287+
}
288+
289+
[column-rendering='lazy'] [part~='body-cell']:not([frozen]):not([frozen-to-end]) {
290+
transform: translateX(var(--_grid-lazy-columns-start));
233291
}
234292
235293
/* Variant: wrap cell contents */
@@ -240,31 +298,18 @@ export const gridStyles = css`
240298
241299
/* Variant: row stripes */
242300
[part~='odd-row'] {
243-
--vaadin-grid-cell-background-color: var(--vaadin-grid-row-odd-background-color, var(--vaadin-background-color));
301+
--vaadin-grid-cell-background-color: var(--vaadin-grid-row-odd-background-color, var(--_row-background-color));
244302
}
245303
246304
:host([theme~='row-stripes']) [part~='odd-row'] {
247305
--vaadin-grid-cell-background-color: var(
248306
--vaadin-grid-row-odd-background-color,
249-
color-mix(in srgb, var(--vaadin-text-color) 4%, var(--vaadin-background-color))
307+
color-mix(in srgb, var(--vaadin-text-color) 4%, var(--_row-background-color))
250308
);
251309
}
252310
253311
/* Raise highlighted rows above others */
254312
255-
[part~='selected-row'] {
256-
z-index: 3;
257-
}
258-
259-
[part~='row']:focus,
260-
[part~='row']:focus-within {
261-
z-index: 4;
262-
263-
[part~='cell']:not([part~='selected-row-cell']) {
264-
border-top-color: transparent;
265-
}
266-
}
267-
268313
/* @container style(--vaadin-grid-row-odd-background-color) {
269314
[part~='odd-row'] {
270315
z-index: 1;
@@ -317,11 +362,11 @@ export const gridStyles = css`
317362
}
318363
319364
[part~='selected-row-cell'] {
320-
border-top-style: solid;
365+
/* border-top-style: solid; */
321366
}
322367
323368
[part~='selected-row-cell']:not([part~='first-row-cell']) {
324-
margin-top: calc(var(--_row-border-width) * -1);
369+
/* margin-top: calc(var(--_row-border-width) * -1); */
325370
}
326371
327372
/* Empty state */
@@ -601,9 +646,9 @@ export const gridStyles = css`
601646
602647
/* Sizer styles */
603648
#sizer {
604-
display: flex;
605649
visibility: hidden;
606650
border: none !important;
651+
grid-template-rows: none !important;
607652
}
608653
609654
#sizer [part~='details-cell'],

packages/grid/src/vaadin-grid-column-mixin.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -374,32 +374,44 @@ export const ColumnBaseMixin = (superClass) =>
374374
}
375375

376376
/** @private */
377-
_flexGrowChanged(flexGrow) {
377+
_flexGrowChanged(_flexGrow) {
378378
if (this.parentElement && this.parentElement._columnPropChanged) {
379379
this.parentElement._columnPropChanged('flexGrow');
380380
}
381381

382-
this._allCells.forEach((cell) => {
383-
cell.style.flexGrow = flexGrow;
384-
});
382+
if (this._grid && this._grid.__updateCSSGridTemplateColumns) {
383+
this._grid.__updateCSSGridTemplateColumns();
384+
}
385+
386+
// this._allCells.forEach((cell) => {
387+
// cell.style.flexGrow = flexGrow;
388+
// });
385389
}
386390

387391
/** @private */
388392
_orderChanged(order) {
389393
this._allCells.forEach((cell) => {
390394
cell.style.order = order;
391395
});
396+
397+
if (this._grid && this._grid._cellOrderChanged) {
398+
this._grid._cellOrderChanged();
399+
}
392400
}
393401

394402
/** @private */
395-
_widthChanged(width) {
403+
_widthChanged(_width) {
396404
if (this.parentElement && this.parentElement._columnPropChanged) {
397405
this.parentElement._columnPropChanged('width');
398406
}
399407

400-
this._allCells.forEach((cell) => {
401-
cell.style.width = width;
402-
});
408+
// this._allCells.forEach((cell) => {
409+
// cell.style.width = width;
410+
// });
411+
412+
if (this._grid && this._grid.__updateCSSGridTemplateColumns) {
413+
this._grid.__updateCSSGridTemplateColumns();
414+
}
403415
}
404416

405417
/** @private */
@@ -419,9 +431,9 @@ export const ColumnBaseMixin = (superClass) =>
419431

420432
/** @private */
421433
_frozenToEndChanged(frozenToEnd) {
422-
if (this.parentElement && this.parentElement._columnPropChanged) {
423-
this.parentElement._columnPropChanged('frozenToEnd', frozenToEnd);
424-
}
434+
// if (this.parentElement && this.parentElement._columnPropChanged) {
435+
// this.parentElement._columnPropChanged('frozenToEnd', frozenToEnd);
436+
// }
425437

426438
this._allCells.forEach((cell) => {
427439
// Skip sizer cells to keep correct scrollWidth.

packages/grid/src/vaadin-grid-mixin.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,24 @@ export const GridMixin = (superClass) =>
585585
this._updateFirstAndLastColumnForRow(row);
586586
}
587587

588+
/** @private */
589+
__updateCSSGridTemplateColumns() {
590+
if (!this._columnTree) {
591+
return;
592+
}
593+
594+
const templateColumns = this._columnTree[this._columnTree.length - 1]
595+
.map((column) => {
596+
if (column.flexGrow > 0) {
597+
return `minmax(${column.width}, ${column.flexGrow}fr)`;
598+
}
599+
return column.width;
600+
})
601+
.join(' ');
602+
603+
this.$.table.style.setProperty('--_template-columns', templateColumns);
604+
}
605+
588606
/**
589607
* @param {HTMLTableRowElement} row
590608
* @protected
@@ -746,6 +764,7 @@ export const GridMixin = (superClass) =>
746764
// Sizer rows
747765
this.__initRow(this.$.sizer, columnTree[columnTree.length - 1]);
748766

767+
this.__updateCSSGridTemplateColumns();
749768
this._resizeHandler();
750769
this._frozenCellsChanged();
751770
this._updateFirstAndLastColumn();

0 commit comments

Comments
 (0)