From ee6c579ee95fc27cde5d7f9576cd239e730bf1d1 Mon Sep 17 00:00:00 2001 From: Sartxi Date: Mon, 28 Oct 2024 14:55:22 -0600 Subject: [PATCH 1/4] handle dynamic price in addon labels --- libs/blocks/table/table.css | 3 +-- libs/blocks/table/table.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/blocks/table/table.css b/libs/blocks/table/table.css index 04fbd77a37..6fd62b3ee0 100644 --- a/libs/blocks/table/table.css +++ b/libs/blocks/table/table.css @@ -485,7 +485,6 @@ text-align: start; font-style: normal; font-weight: 400; - gap: var(--spacing-xxs); color: black; padding: 5px 10px; box-sizing: border-box; @@ -495,7 +494,7 @@ background-color: var(--color-gray-300); } -.table.has-addon .addon-label :first-child { +.table.has-addon .addon-label .icon { display: flex; align-self: center; } diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 5346d6d99e..e5309fc26e 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -129,14 +129,21 @@ function handleAddOnContent(table) { const [position, order, style] = addOn.innerText.split('-') .filter((key) => key.toUpperCase() !== addOnKey).map((key) => key.toLowerCase()); if (!position || !order) return; - const indexAttr = 'data-col-index'; + const dataIndex = 'data-col-index'; [...table.querySelector('.row-heading').children].forEach((headCol) => { headCol.querySelector('.heading-content')?.classList.add('content'); - const colIndex = headCol.getAttribute(indexAttr); + const colIndex = headCol.getAttribute(dataIndex); if (colIndex <= 1) return; // skip the key column const tagName = `${position}-${order}`; - const content = [...addOnRow.children] - .find((col) => col.getAttribute(indexAttr) === colIndex).childNodes; + const column = [...addOnRow.children].find((el) => el.getAttribute(dataIndex) === colIndex); + let content = column.childNodes; + if (style === 'label' && column.querySelector('.icon')) { + const textContent = [...content].filter((node) => !node.classList?.contains('icon')); + content = [ + createTag('span', null, textContent.map((node) => node)), + column.querySelector('.icon'), + ]; + } const tag = createTag('div', { class: tagName }, [...content].map((node) => node)); if (style) tag.classList.add(`addon-${style}`); const el = headCol.querySelector(`.${position}`); From 7e9b4cc5733e18b2a613d321b042192bbde97ab9 Mon Sep 17 00:00:00 2001 From: Sartxi Date: Mon, 28 Oct 2024 15:14:28 -0600 Subject: [PATCH 2/4] code cov --- test/blocks/table/mocks/body.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/blocks/table/mocks/body.html b/test/blocks/table/mocks/body.html index 3ff68f3860..6fb93feb80 100644 --- a/test/blocks/table/mocks/body.html +++ b/test/blocks/table/mocks/body.html @@ -460,6 +460,13 @@
test
test
+
+
ADDON-CONTENT-AFTER-LABEL
+
test | test
+
test | test
+
test | test
+
test | test
+

From c1e148b1b09ebf45b202351b79ef19f891e2bd0f Mon Sep 17 00:00:00 2001 From: Sartxi Date: Tue, 29 Oct 2024 12:42:41 -0600 Subject: [PATCH 3/4] reduce queries and remove uneeded mapping --- libs/blocks/table/table.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index e5309fc26e..ab0d1ce3da 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -137,12 +137,10 @@ function handleAddOnContent(table) { const tagName = `${position}-${order}`; const column = [...addOnRow.children].find((el) => el.getAttribute(dataIndex) === colIndex); let content = column.childNodes; - if (style === 'label' && column.querySelector('.icon')) { - const textContent = [...content].filter((node) => !node.classList?.contains('icon')); - content = [ - createTag('span', null, textContent.map((node) => node)), - column.querySelector('.icon'), - ]; + const icon = column.querySelector('.icon'); + if (style === 'label' && icon) { + const text = [...content].filter((node) => !node.classList?.contains('icon')); + content = [createTag('span', null, text), icon]; } const tag = createTag('div', { class: tagName }, [...content].map((node) => node)); if (style) tag.classList.add(`addon-${style}`); From e1cee368587cd45c77227f58fecfcf759143a728 Mon Sep 17 00:00:00 2001 From: Sartxi Date: Tue, 5 Nov 2024 11:25:08 -0700 Subject: [PATCH 4/4] uneeded style that was causing some issues --- libs/blocks/table/table.css | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/blocks/table/table.css b/libs/blocks/table/table.css index 6fd62b3ee0..1cb0ae4d1f 100644 --- a/libs/blocks/table/table.css +++ b/libs/blocks/table/table.css @@ -466,7 +466,6 @@ .table.has-addon .row-heading .col.col-heading:not(.col-1) .buttons-wrapper { align-items: flex-end; - height: 100%; } .table.has-addon p.body {