Skip to content

Commit ef99066

Browse files
committed
Adds background-color to umb-table header
Fixes #16467
1 parent dc27f58 commit ef99066

File tree

1 file changed

+59
-48
lines changed

1 file changed

+59
-48
lines changed

src/packages/core/components/table/table.element.ts

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { UmbUfmRenderElement } from '../../../ufm/components/ufm-render/index.js';
2-
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
31
import {
42
css,
53
customElement,
@@ -11,6 +9,8 @@ import {
119
when,
1210
LitElement,
1311
} from '@umbraco-cms/backoffice/external/lit';
12+
import type { UmbUfmRenderElement } from '../../../ufm/components/ufm-render/index.js';
13+
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
1414

1515
// TODO: move to UI Library - entity actions should NOT be moved to UI Library but stay in an UmbTable element
1616
export interface UmbTableItem {
@@ -163,17 +163,19 @@ export class UmbTableElement extends LitElement {
163163
}
164164

165165
override render() {
166-
return html`<uui-table class="uui-text">
167-
<uui-table-column
168-
.style=${when(
169-
!(this.config.allowSelection === false && this.config.hideIcon === true),
170-
() => 'width: 60px',
171-
)}></uui-table-column>
172-
<uui-table-head>
173-
${this._renderHeaderCheckboxCell()} ${this.columns.map((column) => this._renderHeaderCell(column))}
174-
</uui-table-head>
175-
${repeat(this.items, (item) => item.id, this._renderRow)}
176-
</uui-table>`;
166+
return html`
167+
<uui-table class="uui-text">
168+
<uui-table-column
169+
.style=${when(
170+
!(this.config.allowSelection === false && this.config.hideIcon === true),
171+
() => 'width: 60px',
172+
)}></uui-table-column>
173+
<uui-table-head>
174+
${this._renderHeaderCheckboxCell()} ${this.columns.map((column) => this._renderHeaderCell(column))}
175+
</uui-table-head>
176+
${repeat(this.items, (item) => item.id, this._renderRow)}
177+
</uui-table>
178+
`;
177179
}
178180

179181
private _renderHeaderCell(column: UmbTableColumn) {
@@ -201,48 +203,54 @@ export class UmbTableElement extends LitElement {
201203
private _renderHeaderCheckboxCell() {
202204
if (this.config.hideIcon && !this.config.allowSelection) return;
203205

204-
return html` <uui-table-head-cell style="--uui-table-cell-padding: 0">
205-
${when(
206-
this.config.allowSelection,
207-
() =>
208-
html` <uui-checkbox
209-
label="Select All"
210-
style="padding: var(--uui-size-4) var(--uui-size-5);"
211-
@change="${this._handleAllRowsCheckboxChange}"
212-
?checked="${this.selection.length === this.items.length}">
213-
</uui-checkbox>`,
214-
)}
215-
</uui-table-head-cell>`;
206+
return html`
207+
<uui-table-head-cell style="--uui-table-cell-padding: 0">
208+
${when(
209+
this.config.allowSelection,
210+
() =>
211+
html` <uui-checkbox
212+
label="Select All"
213+
style="padding: var(--uui-size-4) var(--uui-size-5);"
214+
@change="${this._handleAllRowsCheckboxChange}"
215+
?checked="${this.selection.length === this.items.length}">
216+
</uui-checkbox>`,
217+
)}
218+
</uui-table-head-cell>
219+
`;
216220
}
217221

218222
private _renderRow = (item: UmbTableItem) => {
219-
return html`<uui-table-row
220-
?selectable="${this.config.allowSelection}"
221-
?select-only=${this._selectionMode}
222-
?selected=${this._isSelected(item.id)}
223-
@selected=${() => this._selectRow(item.id)}
224-
@deselected=${() => this._deselectRow(item.id)}>
225-
${this._renderRowCheckboxCell(item)} ${this.columns.map((column) => this._renderRowCell(column, item))}
226-
</uui-table-row>`;
223+
return html`
224+
<uui-table-row
225+
?selectable="${this.config.allowSelection}"
226+
?select-only=${this._selectionMode}
227+
?selected=${this._isSelected(item.id)}
228+
@selected=${() => this._selectRow(item.id)}
229+
@deselected=${() => this._deselectRow(item.id)}>
230+
${this._renderRowCheckboxCell(item)} ${this.columns.map((column) => this._renderRowCell(column, item))}
231+
</uui-table-row>
232+
`;
227233
};
228234

229235
private _renderRowCheckboxCell(item: UmbTableItem) {
230236
if (this.config.hideIcon && !this.config.allowSelection) return;
231237

232-
return html`<uui-table-cell>
233-
${when(!this.config.hideIcon, () => html`<umb-icon name="${ifDefined(item.icon ?? undefined)}"></umb-icon>`)}
234-
${when(
235-
this.config.allowSelection,
236-
() => html`
237-
<uui-checkbox
238-
label="Select Row"
239-
@click=${(e: PointerEvent) => e.stopPropagation()}
240-
@change=${(event: Event) => this._handleRowCheckboxChange(event, item)}
241-
?checked="${this._isSelected(item.id)}">
242-
</uui-checkbox>
243-
`,
244-
)}
245-
</uui-table-cell>`;
238+
return html`
239+
<uui-table-cell>
240+
${when(!this.config.hideIcon, () => html`<umb-icon name="${ifDefined(item.icon ?? undefined)}"></umb-icon>`)}
241+
${when(
242+
this.config.allowSelection,
243+
() => html`
244+
<uui-checkbox
245+
label="Select Row"
246+
@click=${(e: PointerEvent) => e.stopPropagation()}
247+
@change=${(event: Event) => this._handleRowCheckboxChange(event, item)}
248+
?checked="${this._isSelected(item.id)}">
249+
</uui-checkbox>
250+
`,
251+
)}
252+
</uui-table-cell>
253+
`;
246254
}
247255

248256
private _renderRowCell(column: UmbTableColumn, item: UmbTableItem) {
@@ -251,7 +259,8 @@ export class UmbTableElement extends LitElement {
251259
style="--uui-table-cell-padding: 0 var(--uui-size-5); text-align:${column.align ?? 'left'}; width: ${column.width || 'auto'};">
252260
${this._renderCellContent(column, item)}
253261
</uui-table-cell>
254-
</uui-table-cell>`;
262+
</uui-table-cell>
263+
`;
255264
}
256265

257266
private _renderCellContent(column: UmbTableColumn, item: UmbTableItem) {
@@ -292,6 +301,7 @@ export class UmbTableElement extends LitElement {
292301
position: sticky;
293302
top: 0;
294303
z-index: 1;
304+
background-color: var(--uui-color-surface, #fff);
295305
}
296306
297307
uui-table-row uui-checkbox {
@@ -331,6 +341,7 @@ export class UmbTableElement extends LitElement {
331341
justify-content: space-between;
332342
width: 100%;
333343
}
344+
334345
uui-table-head-cell button > span {
335346
flex: 1 0 auto;
336347
}

0 commit comments

Comments
 (0)