diff --git a/ml_peg/app/build_app.py b/ml_peg/app/build_app.py index 85c91f12b..6a29a58a7 100644 --- a/ml_peg/app/build_app.py +++ b/ml_peg/app/build_app.py @@ -20,6 +20,7 @@ register_element_filter_callbacks, ) from ml_peg.app.utils.build_components import ( + LINK_COLUMN_WIDTH, build_download_controls, build_faqs, build_footer, @@ -814,9 +815,9 @@ def build_summary_table( style_cell_conditional.append( { "if": {"column_id": "link"}, - "width": "36px", - "minWidth": "36px", - "maxWidth": "36px", + "width": f"{LINK_COLUMN_WIDTH}px", + "minWidth": f"{LINK_COLUMN_WIDTH}px", + "maxWidth": f"{LINK_COLUMN_WIDTH}px", "textAlign": "left", "padding": "0", "borderLeft": "none", diff --git a/ml_peg/app/utils/build_components.py b/ml_peg/app/utils/build_components.py index db549eec6..93181b023 100644 --- a/ml_peg/app/utils/build_components.py +++ b/ml_peg/app/utils/build_components.py @@ -29,6 +29,10 @@ get_threshold_colours, ) +# Width (px) of the docs-link column of the summary table (see build_app.py). +# kept so the weights row can be translated to align with cols +LINK_COLUMN_WIDTH = 36 + def grid_template_from_widths( widths: dict[str, int], @@ -189,6 +193,16 @@ def build_weight_components( widths = calculate_column_widths(columns, column_widths) grid_template = grid_template_from_widths(widths, columns) + # The overall summary table has a "link" column inserted after MLIP. Reserve + # a matching spacer track (and grid cell) so the weight boxes stay aligned. + has_link_column = any(col.get("id") == "link" for col in table.columns) + link_spacer: list[Div] = [] + if has_link_column: + tracks = grid_template.split(" ") + tracks.insert(1, f"{LINK_COLUMN_WIDTH}px") + grid_template = " ".join(tracks) + link_spacer = [Div(style={"border": "1px solid transparent"})] + weight_inputs = [ build_weight_input( input_id=f"{input_id}-input", @@ -253,6 +267,7 @@ def build_weight_components( "border": "1px solid transparent", # #dee2e6 or transparent }, ), + *link_spacer, build_download_controls(table.id) if include_download_controls else Div(