From 1c8038fbcbbc88118aef3e08b2784c7a6e4da104 Mon Sep 17 00:00:00 2001
From: Xavier Carron <33637571+xav-car@users.noreply.github.com>
Date: Thu, 6 Mar 2025 14:00:23 +0100
Subject: [PATCH 1/3] tech(pix-table): allow td to has scope "row"
---
addon/components/pix-table-column.hbs | 12 +++++--
app/stories/pix-table-column.stories.js | 11 ++++++-
.../components/pix-table-column-test.js | 32 +++++++++++++++++++
3 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/addon/components/pix-table-column.hbs b/addon/components/pix-table-column.hbs
index dbff02b4e..8b1dec243 100644
--- a/addon/components/pix-table-column.hbs
+++ b/addon/components/pix-table-column.hbs
@@ -13,7 +13,13 @@
{{else}}
-
- {{yield to="cell"}}
- |
+ {{#if @isMainRow}}
+
+ {{yield to="cell"}}
+ |
+ {{else}}
+
+ {{yield to="cell"}}
+ |
+ {{/if}}
{{/if}}
\ No newline at end of file
diff --git a/app/stories/pix-table-column.stories.js b/app/stories/pix-table-column.stories.js
index 19e880079..a2cb237ec 100644
--- a/app/stories/pix-table-column.stories.js
+++ b/app/stories/pix-table-column.stories.js
@@ -58,6 +58,15 @@ export default {
description: 'Defini le style avec lequel nous afficherons la colonne',
},
},
+ isMainRow: {
+ name: 'isMainRow',
+ description:
+ 'Permet de définir la cellule qui portera la valeur principale de la ligne entière',
+ type: {
+ name: 'boolean',
+ required: false,
+ },
+ },
header: {
name: '<:header>',
description: 'En-tête de la colonne',
@@ -75,7 +84,7 @@ const Template = (args) => {
return {
template: hbs`
<:columns as |row context|>
-
+
<:header>
Nom
diff --git a/tests/integration/components/pix-table-column-test.js b/tests/integration/components/pix-table-column-test.js
index 934fd0a38..d7c4c5bd8 100644
--- a/tests/integration/components/pix-table-column-test.js
+++ b/tests/integration/components/pix-table-column-test.js
@@ -110,4 +110,36 @@ module('Integration | Component | table-column', function (hooks) {
assert.strictEqual(textAlign, 'right');
});
});
+
+ module('when isMainRow defined', function () {
+ test('it renders a defined row title', async function (assert) {
+ // when
+ const screen = await render(
+ hbs`
+ <:columns as |row context|>
+
+ <:header>
+ Nom
+
+ <:cell>
+ {{row.name}}
+
+
+
+ <:header>
+ Âge
+
+ <:cell>
+ {{row.age}}
+
+
+
+`,
+ );
+
+ // then
+ const row = screen.getByRole('row', { name: 'jean 15' });
+ assert.ok(row);
+ });
+ });
});
From 72af9ed8816e55891c438190c8c63cd5a551e709 Mon Sep 17 00:00:00 2001
From: Xavier Carron <33637571+xav-car@users.noreply.github.com>
Date: Thu, 6 Mar 2025 15:00:19 +0100
Subject: [PATCH 2/3] fix(pix-table): change font on row th
---
addon/styles/_pix-table.scss | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/addon/styles/_pix-table.scss b/addon/styles/_pix-table.scss
index 37a821efb..9a8939795 100644
--- a/addon/styles/_pix-table.scss
+++ b/addon/styles/_pix-table.scss
@@ -59,11 +59,17 @@
align-items: center;
}
- th {
+ th[scope='col'] {
+ font-weight: var(--pix-font-bold);
text-align: start;
vertical-align: middle;
}
+ th[scope='row'] {
+ font-weight: var(--pix-font-normal);
+ }
+
+
td, th {
padding: var(--pix-spacing-6x) var(--pix-spacing-4x);
From 9e0aea841fab9820356affa778148d29f189f801 Mon Sep 17 00:00:00 2001
From: Xavier Carron <33637571+xav-car@users.noreply.github.com>
Date: Thu, 6 Mar 2025 15:41:00 +0100
Subject: [PATCH 3/3] fix(pix-table) : keep number align to left
---
addon/styles/_pix-table-column.scss | 2 +-
tests/integration/components/pix-table-column-test.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/addon/styles/_pix-table-column.scss b/addon/styles/_pix-table-column.scss
index 80167f631..e6d91f7e7 100644
--- a/addon/styles/_pix-table-column.scss
+++ b/addon/styles/_pix-table-column.scss
@@ -1,5 +1,5 @@
.pix-table-column {
&--number{
- text-align: right;
+ text-align: left;
}
}
diff --git a/tests/integration/components/pix-table-column-test.js b/tests/integration/components/pix-table-column-test.js
index d7c4c5bd8..351c9a382 100644
--- a/tests/integration/components/pix-table-column-test.js
+++ b/tests/integration/components/pix-table-column-test.js
@@ -107,7 +107,7 @@ module('Integration | Component | table-column', function (hooks) {
const cell = screen.queryByRole('cell', { name: '15' });
assert.dom(cell).exists();
const textAlign = window.getComputedStyle(cell).getPropertyValue('text-align');
- assert.strictEqual(textAlign, 'right');
+ assert.strictEqual(textAlign, 'left');
});
});