From bd149ff11faa0f081b719d171639132f924c874c Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Sat, 31 Jan 2026 01:27:59 +0100 Subject: [PATCH] Meilleure gestion des styles dans les tableaux --- src/figures.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/figures.py b/src/figures.py index a505576..0fd9210 100644 --- a/src/figures.py +++ b/src/figures.py @@ -258,10 +258,12 @@ class DataTable(dash_table.DataTable): page_action: Literal["native", "custom", "none"] = "native", sort_action: Literal["native", "custom", "none"] = "native", filter_action: Literal["native", "custom", "none"] = "native", + style_cell_conditional: list | None = None, + style_cell: dict | None = None, **kwargs, ): # Styles de base - style_cell_conditional = [ + style_cell_conditional_common = [ { "if": {"column_id": "objet"}, "minWidth": "350px", @@ -291,6 +293,8 @@ class DataTable(dash_table.DataTable): }, ] + style_cell_common = {"fontFamily": "Inter", "fontSize": "16px"} + for key in data_schema.keys(): field = data_schema[key] if field["type"] in ["number", "integer"]: @@ -299,7 +303,15 @@ class DataTable(dash_table.DataTable): "textAlign": "right", # "fontFamily": "Fira Code", } - style_cell_conditional.append(rule) + style_cell_conditional_common.append(rule) + + style_cell_conditional = ( + style_cell_conditional or [] + ) + style_cell_conditional_common + style_cell.update(style_cell_common) if isinstance( + style_cell, dict + ) else style_cell_common + style_header = style_cell # Initialisation de la classe parente avec les arguments super().__init__( @@ -322,8 +334,8 @@ class DataTable(dash_table.DataTable): style_cell_conditional=style_cell_conditional, data_timestamp=0, markdown_options={"html": True}, - style_header={"fontFamily": "Inter", "fontSize": "16px"}, - style_cell={"fontFamily": "Inter", "fontSize": "16px"}, + style_header=style_header, + style_cell=style_cell, tooltip_duration=8000, tooltip_delay=350, hidden_columns=hidden_columns,