Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ml_peg/app/build_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions ml_peg/app/utils/build_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
Loading