Skip to content

Commit

Permalink
refactor(ui5-table): width property of column is removed (#784)
Browse files Browse the repository at this point in the history
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">...`
  • Loading branch information
MapTo0 committed Sep 25, 2019
1 parent 2f8a3ea commit dedb51e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 35 deletions.
16 changes: 0 additions & 16 deletions packages/main/src/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,29 +253,13 @@ class Table extends UI5Element {
return this.columns.map((column, index) => {
return {
index,
width: column.width,
minWidth: column.minWidth,
demandPopin: column.demandPopin,
popinText: column.popinText,
visible: !this._hiddenColumns[index],
};
}, this);
}

get styles() {
const gridTemplateColumns = this.visibleColumns.reduce((acc, column) => {
return `${acc}minmax(0, ${column.width || "1fr"}) `;
}, "");

return {
main: {
"grid-template-columns": gridTemplateColumns,
position: this.stickyColumnHeader ? "sticky" : "",
top: this.stickyColumnHeader ? "0px" : "",
"z-index": this.stickyColumnHeader ? "1" : "",
},
};
}
}

Table.define();
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TableColumn.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<th scope="col" style="width: {{width}}">
<th scope="col">
<div class="ui5-table-column-root">
<slot></slot>
</div>
Expand Down
12 changes: 0 additions & 12 deletions packages/main/src/TableColumn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
import CSSSize from "@ui5/webcomponents-base/dist/types/CSSSize.js";
import TableColumnTemplate from "./generated/templates/TableColumnTemplate.lit.js";

// Styles
Expand Down Expand Up @@ -66,17 +65,6 @@ const metadata = {
type: Boolean,
},

/**
* Defines the width of the column. If you leave it empty, then this column covers the remaining space.
*
* @type {CSSSize}
* @public
*/
width: {
type: CSSSize,
defaultValue: "auto",
},

/**
* @protected
*/
Expand Down
11 changes: 9 additions & 2 deletions packages/main/src/themes/TableCell.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
:host {
display: contents;
font-family: var(--sapUiFontFamily,var(--sapFontFamily,"72","72full",Arial,Helvetica,sans-serif));
font-size: 0.875rem;
height: 100%;
box-sizing: border-box;
overflow: hidden;
color: var(--sapUiContentLabelColor);
}

td {
padding: 0.25rem;
vertical-align: middle;
padding: .5rem .25rem;
box-sizing: border-box;
}

:host([first-in-row]) td,
.ui5-table-popin-row td {
padding-left: 1rem;

}

:host([first-in-row]) td {
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/TableColumn.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ th {
background: var(--sapUiListHeaderBackground);
border-bottom: 1px solid var(--sapUiListBorderColor);
border: none;
width: inherit;
font-weight: normal;
}

.ui5-table-column-root {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h3>Basic Table</h3>

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

Expand Down Expand Up @@ -95,7 +95,7 @@ <h3>Basic Table</h3>

<ui5-table class="demo-table" id="table">
<!-- Columns -->
<ui5-table-column slot="columns" width="12em">
<ui5-table-column slot="columns" style="width: 12rem">
<span style="line-height: 1.4rem">Product</span>
</ui5-table-column>

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

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

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

Expand Down

0 comments on commit dedb51e

Please sign in to comment.