From c045f4f2490912eb09cc8bc8754a35e6f9def28f Mon Sep 17 00:00:00 2001 From: "m.novikov" Date: Mon, 21 Dec 2020 19:32:58 +0300 Subject: [PATCH 01/12] fix when cell larger than maxWidth prop --- .../QTable/src/components/QTableRow/index.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qComponents/QTable/src/components/QTableRow/index.vue b/src/qComponents/QTable/src/components/QTableRow/index.vue index e0bc7e8b..266ce912 100644 --- a/src/qComponents/QTable/src/components/QTableRow/index.vue +++ b/src/qComponents/QTable/src/components/QTableRow/index.vue @@ -24,6 +24,7 @@
Date: Thu, 24 Dec 2020 17:49:33 +0300 Subject: [PATCH 02/12] add fixed table --- src/qComponents/QTable/src/QTable.vue | 57 ++++++----- .../QTable/src/components/QTableRow/index.vue | 99 +++++++------------ src/qComponents/QTable/src/q-table.scss | 7 +- 3 files changed, 70 insertions(+), 93 deletions(-) diff --git a/src/qComponents/QTable/src/QTable.vue b/src/qComponents/QTable/src/QTable.vue index 3405f90b..5d5b85b3 100644 --- a/src/qComponents/QTable/src/QTable.vue +++ b/src/qComponents/QTable/src/QTable.vue @@ -3,7 +3,7 @@
+ + + + + @@ -199,7 +210,6 @@ :columns="columns" :class="levelClass(row.indent)" :fixed-column="fixedColumn" - :fixed-column-width="fixedColumnWidth" :expandable="expandable" :indent-size="indentSize" :indent="row.indent" @@ -269,6 +279,20 @@ export default { }, props: { + /** + * Whether width of columns automatically fits its container + */ + fixedLayout: { + type: Boolean, + default: true + }, + /** + * Default columns width, required `fixedLayout: true` + */ + defaultColWidth: { + type: String, + default: '150px' + }, isLoading: { type: Boolean, default: false @@ -329,11 +353,11 @@ export default { default: 'children' }, /** - * Width of fixed column + * Width of fixed column. If `fixedLayout: true`, width is equal to `defaultColWidth` prop. */ fixedColumnWidth: { type: Number, - default: 200 + default: null }, expandable: { type: Boolean, @@ -784,25 +808,14 @@ export default { return sortableClass; }, - getCellWidth(column) { - const style = {}; - - if (column.width) { - style.width = `${column.width}px`; - } - - if (column.minWidth) { - style.minWidth = `${column.minWidth}px`; - } - if (column.maxWidth) { - style.maxWidth = `${column.maxWidth}px`; - } + getColWidth(column) { if (this.fixedColumn !== column.key && column.key !== 'shadow') - return style; + return { + width: column.width ? `${column.width}px` : this.defaultColWidth + }; return { - minWidth: `${this.fixedColumnWidth}px`, - maxWidth: `${this.fixedColumnWidth}px` + width: `${this.fixedColumnWidth ?? this.defaultColWidth}px` }; }, diff --git a/src/qComponents/QTable/src/components/QTableRow/index.vue b/src/qComponents/QTable/src/components/QTableRow/index.vue index 266ce912..2177fe69 100644 --- a/src/qComponents/QTable/src/components/QTableRow/index.vue +++ b/src/qComponents/QTable/src/components/QTableRow/index.vue @@ -24,54 +24,48 @@
-
- -
+ +
-
- +
+ - -
+ +
- @@ -103,10 +97,6 @@ export default { type: String, default: '' }, - fixedColumnWidth: { - type: Number, - default: 250 - }, expandable: { type: Boolean, default: false @@ -239,24 +229,9 @@ export default { paddingLeft: `${Number(paddingLeft) + this.indent}px` }; }, - getCellWrapperStyle({ width, minWidth, maxWidth }, columnIndex) { - return { - width: width ? `${width}px` : '', - minWidth: minWidth ? `${minWidth}px` : '', - maxWidth: maxWidth ? this.getCellMaxWidth(maxWidth, columnIndex) : '' - }; - }, - getCellMaxWidth(maxWidth, columnIndex) { - const tdWidth = this.$refs[`td${columnIndex}`]?.[0].offsetWidth ?? 0; - return Math.max(tdWidth, maxWidth); - }, - getCellStyle(key, columnIndex, width) { + getCellStyle(key, columnIndex) { const style = {}; - if (width) { - style.width = `${width}px`; - } - if ( columnIndex === 0 && !this.selectable && @@ -274,13 +249,7 @@ export default { } } - if (this.fixedColumn !== key && key !== 'shadow') return style; - - return { - ...style, - minWidth: `${this.fixedColumnWidth}px`, - maxWidth: `${this.fixedColumnWidth}px` - }; + return style; }, getFixedColumnClass(key) { return this.fixedColumn && this.fixedColumn === key diff --git a/src/qComponents/QTable/src/q-table.scss b/src/qComponents/QTable/src/q-table.scss index db7dd09e..ca20c4bf 100644 --- a/src/qComponents/QTable/src/q-table.scss +++ b/src/qComponents/QTable/src/q-table.scss @@ -271,6 +271,7 @@ } &__cell { + height: 64px; padding: 12px 24px; overflow: hidden; font-weight: var(--font-weight-base); @@ -278,12 +279,6 @@ background-color: var(--color-tertiary-gray-light); box-shadow: var(--custom-box-shadow); - &-wrapper { - display: flex; - align-items: center; - min-height: 40px; - } - &:first-child { padding-left: 16px; } From 7cfb13aa62c13dea2d025d69ca2976a1aaaa64ff Mon Sep 17 00:00:00 2001 From: "m.novikov" Date: Thu, 24 Dec 2020 18:51:25 +0300 Subject: [PATCH 03/12] refactoring --- src/qComponents/QTable/src/QTable.vue | 93 ++++++++++++------------- src/qComponents/QTable/src/q-table.scss | 4 ++ stories/components/QTable.stories.js | 10 ++- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/qComponents/QTable/src/QTable.vue b/src/qComponents/QTable/src/QTable.vue index 5d5b85b3..c5bbf7b2 100644 --- a/src/qComponents/QTable/src/QTable.vue +++ b/src/qComponents/QTable/src/QTable.vue @@ -47,7 +47,6 @@ v-if="rows.length" ref="QTable" class="q-table__table" - :style="{ 'table-layout': fixedLayout && 'fixed' }" :class="tableClasses" cellspacing="0" cellpadding="0" @@ -201,47 +200,45 @@ -