Skip to content

Commit dedb51e

Browse files
authored
refactor(ui5-table): width property of column is removed (#784)
BREAKING CHANGE: width property of the ui5-table-column has been removed. Use CSS to give width to the columns. E.g. `<ui5-table-column style="width: 100px">...`
1 parent 2f8a3ea commit dedb51e

File tree

6 files changed

+16
-35
lines changed

6 files changed

+16
-35
lines changed

packages/main/src/Table.js

-16
Original file line numberDiff line numberDiff line change
@@ -253,29 +253,13 @@ class Table extends UI5Element {
253253
return this.columns.map((column, index) => {
254254
return {
255255
index,
256-
width: column.width,
257256
minWidth: column.minWidth,
258257
demandPopin: column.demandPopin,
259258
popinText: column.popinText,
260259
visible: !this._hiddenColumns[index],
261260
};
262261
}, this);
263262
}
264-
265-
get styles() {
266-
const gridTemplateColumns = this.visibleColumns.reduce((acc, column) => {
267-
return `${acc}minmax(0, ${column.width || "1fr"}) `;
268-
}, "");
269-
270-
return {
271-
main: {
272-
"grid-template-columns": gridTemplateColumns,
273-
position: this.stickyColumnHeader ? "sticky" : "",
274-
top: this.stickyColumnHeader ? "0px" : "",
275-
"z-index": this.stickyColumnHeader ? "1" : "",
276-
},
277-
};
278-
}
279263
}
280264

281265
Table.define();

packages/main/src/TableColumn.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<th scope="col" style="width: {{width}}">
1+
<th scope="col">
22
<div class="ui5-table-column-root">
33
<slot></slot>
44
</div>

packages/main/src/TableColumn.js

-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
33
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
4-
import CSSSize from "@ui5/webcomponents-base/dist/types/CSSSize.js";
54
import TableColumnTemplate from "./generated/templates/TableColumnTemplate.lit.js";
65

76
// Styles
@@ -66,17 +65,6 @@ const metadata = {
6665
type: Boolean,
6766
},
6867

69-
/**
70-
* Defines the width of the column. If you leave it empty, then this column covers the remaining space.
71-
*
72-
* @type {CSSSize}
73-
* @public
74-
*/
75-
width: {
76-
type: CSSSize,
77-
defaultValue: "auto",
78-
},
79-
8068
/**
8169
* @protected
8270
*/

packages/main/src/themes/TableCell.css

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
:host {
22
display: contents;
3+
font-family: var(--sapUiFontFamily,var(--sapFontFamily,"72","72full",Arial,Helvetica,sans-serif));
4+
font-size: 0.875rem;
5+
height: 100%;
6+
box-sizing: border-box;
7+
overflow: hidden;
8+
color: var(--sapUiContentLabelColor);
39
}
410

511
td {
6-
padding: 0.25rem;
7-
vertical-align: middle;
12+
padding: .5rem .25rem;
13+
box-sizing: border-box;
814
}
915

1016
:host([first-in-row]) td,
1117
.ui5-table-popin-row td {
1218
padding-left: 1rem;
19+
1320
}
1421

1522
:host([first-in-row]) td {

packages/main/src/themes/TableColumn.css

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ th {
1111
background: var(--sapUiListHeaderBackground);
1212
border-bottom: 1px solid var(--sapUiListBorderColor);
1313
border: none;
14+
width: inherit;
15+
font-weight: normal;
1416
}
1517

1618
.ui5-table-column-root {

packages/main/test/sap/ui/webcomponents/main/samples/Table.sample.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ <h3>Basic Table</h3>
6363

6464
<ui5-table class="demo-table" id="tbl">
6565
<!-- Columns -->
66-
<ui5-table-column slot="columns" width="12em">
66+
<ui5-table-column slot="columns" style="width: 12rem">
6767
<span style="line-height: 1.4rem">Product</span>
6868
</ui5-table-column>
6969

@@ -95,7 +95,7 @@ <h3>Basic Table</h3>
9595

9696
<ui5-table class="demo-table" id="table">
9797
<!-- Columns -->
98-
<ui5-table-column slot="columns" width="12em">
98+
<ui5-table-column slot="columns" style="width: 12rem">
9999
<span style="line-height: 1.4rem">Product</span>
100100
</ui5-table-column>
101101

@@ -124,7 +124,7 @@ <h3>Table with No Data</h3>
124124
<div class="snippet flex-column">
125125
<ui5-table class="demo-table" no-data-text="No Data" show-no-data>
126126
<!-- Columns -->
127-
<ui5-table-column slot="columns" width="12em">
127+
<ui5-table-column slot="columns" style="width: 12rem">
128128
<span style="line-height: 1.4rem">Product</span>
129129
</ui5-table-column>
130130

@@ -148,7 +148,7 @@ <h3>Table with No Data</h3>
148148

149149
<pre class="prettyprint lang-html"><xmp>
150150
<ui5-table class="demo-table" no-data-text="No Data" show-no-data>
151-
<ui5-table-column slot="columns" width="12em">
151+
<ui5-table-column slot="columns" style="width: 12rem">
152152
<span style="line-height: 1.4rem">Product</span>
153153
</ui5-table-column>
154154

0 commit comments

Comments
 (0)