Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Ajout de la gestion d'une classe specifique pour les cellule TD des Tableau #278

Merged
merged 3 commits into from
Oct 26, 2022

Conversation

CyrilBillon
Copy link
Contributor

Bonjour,

L'objectif de ce besoin est de pouvoir conditionner le style de la cellule en fonction de son contenu, notamment la couleur de fond.
Merci d'avance pour la prise en compte de cette demande.
Cordialement,

@CyrilBillon CyrilBillon changed the title Ajout de la gestion d'une classe specifique pour les cellule TD des Tableau feat: Ajout de la gestion d'une classe specifique pour les cellule TD des Tableau Oct 19, 2022
@@ -136,7 +136,7 @@ const Table = ({
.map((row) => (
<tr key={getRowKey(row)}>
{columns.map((column) => (
<td key={column.name}>
<td key={column.name} className={column.columnClassName || undefined}>
Copy link
Collaborator

@desoindx desoindx Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior is not managed by the dsfr i guess ?
What prevent you to do that in your own code like

<div className="myclass">
  <Table .../>
</div>

.my-class {
  td {
    ...
  }
}

Copy link
Contributor Author

@CyrilBillon CyrilBillon Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our client, "Ministère de la transition écologique et de la cohésion des territoires" ask us to change td background color depending on cell value.
For example, my request is to set green background color to the td if the state value is "VALIDEE"

For your solution, i agree with you if i have to set class to all td cell (I already do that depending on my table struct to set width or other stuff).

@dataesr dataesr deleted a comment from CyrilBillon Oct 24, 2022
@dataesr dataesr deleted a comment from CyrilBillon Oct 24, 2022
@CyrilBillon
Copy link
Contributor Author

L'ajout d'une fonction pour la gestion des classes CSS d'une cellule d'un tableau est fait.
Cordialement,

<td key={column.name}>
<td
key={column.name}
className={column.cellClassRender ? column.cellClassRender(row) : null}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep undefined ? to be consistend with the rest ?
or laybe this should work ?

Suggested change
className={column.cellClassRender ? column.cellClassRender(row) : null}
className={column.cellClassRender && column.cellClassRender(row)}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works perfectly so i did the update.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add the cellClassRenderin the TS declaration and we'll be good :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to, but i didn't find the TS declaration for columns... I only have:

...
export interface TableProps {
columns: Object[];
data: any[];
...

in Table.d.ts...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok :/

@desoindx desoindx merged commit 3d914e0 into dataesr:master Oct 26, 2022
github-actions bot pushed a commit that referenced this pull request Oct 26, 2022
# [3.3.0](v3.2.0...v3.3.0) (2022-10-26)

### Features

* Ajout de la gestion d'une classe specifique pour les cellule TD des Tableau ([#278](#278)) ([3d914e0](3d914e0))
@github-actions
Copy link

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants