Fix sidebar parameter action alignment and PDF report print rendering#48
Fix sidebar parameter action alignment and PDF report print rendering#48EddW1219 wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR addresses UI layout issues in the sidebar parameter actions and improves PDF/print rendering for the report view to prevent chart/text overlap and math rendering artifacts.
Changes:
- Adds scoped CSS to align “Reset Parameters” and “Save Parameters” controls consistently in the sidebar action row.
- Consolidates print-only CSS rules to improve chart spacing, heading separation, and formula rendering in exported PDFs.
- Adjusts a report model snippet to wrap a LaTeX block with centered HTML.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/epicc/main.py | Adds CSS for action-row alignment and print/PDF rendering; refactors parameter action buttons into a keyed container for styling. |
| src/epicc/model/models/tb_isolation.yaml | Wraps a display-math block in a centered HTML div and tweaks the LaTeX test string. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| button_col2.button( | ||
| "Save Parameters", | ||
| disabled=True, | ||
| width="stretch", | ||
| help="Fix parameter errors first", | ||
| ) |
There was a problem hiding this comment.
@EddW1219, please resolve this if this is a non-issue with our post-August 2025 version of Streamlit. Make sure to check this against the version of Stlite we're running as well. Thanks.
| st.markdown( | ||
| """ | ||
| <style> | ||
| /* Action row wrapper */ | ||
| .st-key-param-actions-row [data-testid="stHorizontalBlock"] { | ||
| align-items: flex-start !important; | ||
| } | ||
|
|
||
| /* Normalize column internal spacing */ | ||
| .st-key-param-actions-row [data-testid="column"] > div { | ||
| padding-top: 0 !important; | ||
| } | ||
| .st-key-param-actions-row [data-testid="stElementContainer"] { | ||
| margin-top: 0 !important; | ||
| margin-bottom: 0 !important; | ||
| } | ||
|
|
||
| /* Make trigger controls fill width and remove extra top offset */ | ||
| .st-key-param-actions-row [data-testid="stButton"], | ||
| .st-key-param-actions-row [data-testid="stPopover"] { | ||
| width: 100%; | ||
| margin-top: 0 !important; | ||
| padding-top: 0 !important; | ||
| } | ||
| .st-key-param-actions-row [data-testid="stButton"] > button, | ||
| .st-key-param-actions-row [data-testid="stPopover"] > button { | ||
| width: 100%; | ||
| } | ||
|
|
||
| /* Report spacing: keep headings away from charts */ | ||
| .st-key-results-report [data-testid="stPlotlyChart"], | ||
| .st-key-results-report [data-testid="stVegaLiteChart"], | ||
| .st-key-results-report [data-testid="stPyplot"] { | ||
| margin-bottom: 2rem !important; | ||
| } | ||
|
|
||
| .st-key-results-report [data-testid="stMarkdownContainer"] h1, | ||
| .st-key-results-report [data-testid="stMarkdownContainer"] h2, | ||
| .st-key-results-report [data-testid="stMarkdownContainer"] h3 { | ||
| margin-top: 1.25rem !important; | ||
| } | ||
|
|
||
| /* -------- Print/PDF display fixes only (SINGLE CONSOLIDATED BLOCK) -------- */ | ||
| @media print { | ||
| /* Scope strictly to report area */ | ||
| .st-key-results-report { | ||
| overflow: visible !important; | ||
| } | ||
|
|
||
| /* 1) Keep chart block in flow + reserve vertical space below chart */ | ||
| .st-key-results-report [data-testid="stPlotlyChart"], | ||
| .st-key-results-report [data-testid="stVegaLiteChart"], | ||
| .st-key-results-report [data-testid="stPyplot"] { | ||
| display: block !important; | ||
| position: static !important; | ||
| clear: both !important; | ||
| overflow: visible !important; | ||
| break-inside: avoid !important; | ||
| page-break-inside: avoid !important; | ||
| margin: 0 0 2.8rem 0 !important; | ||
| padding-bottom: 1.2rem !important; | ||
| } | ||
|
|
||
| /* Prevent Plotly print-height collapse */ | ||
| .st-key-results-report [data-testid="stPlotlyChart"] .js-plotly-plot { | ||
| min-height: 520px !important; | ||
| } | ||
|
|
||
| /* 2) Ensure headings/text start after chart and have breathing room */ | ||
| .st-key-results-report h1, | ||
| .st-key-results-report h2, | ||
| .st-key-results-report h3, | ||
| .st-key-results-report h4, | ||
| .st-key-results-report p, | ||
| .st-key-results-report [data-testid="stMarkdownContainer"] { | ||
| clear: both !important; | ||
| position: static !important; | ||
| z-index: auto !important; | ||
| margin-top: 1.5rem !important; | ||
| } | ||
|
|
||
| .st-key-results-report [data-testid="stMarkdownContainer"] h1, | ||
| .st-key-results-report [data-testid="stMarkdownContainer"] h2, | ||
| .st-key-results-report [data-testid="stMarkdownContainer"] h3 { | ||
| margin-top: 1.5rem !important; | ||
| clear: both !important; | ||
| } | ||
|
|
||
| /* 3) Formula print fix: show only visual layer, hide assistive MathML */ | ||
| .st-key-results-report .katex, | ||
| .st-key-results-report .katex-display, | ||
| .st-key-results-report mjx-container, | ||
| .st-key-results-report .MathJax { | ||
| visibility: visible !important; | ||
| opacity: 1 !important; | ||
| } | ||
|
|
||
| .st-key-results-report .katex .katex-mathml, | ||
| .st-key-results-report mjx-assistive-mml { | ||
| display: none !important; | ||
| } | ||
| } | ||
| </style> | ||
| """, | ||
| unsafe_allow_html=True, | ||
| ) |
There was a problem hiding this comment.
I'm in agreement with Copilot here, @EddW1219. Take a look at how we handle sidebar.css in src/epicc/web/ and src/epicc/ui/styles.py.
| <div style="text-align: center;"> | ||
|
|
||
| $$ | ||
| \LaTeX \text{ test.} | ||
| \text{LaTeX test.} | ||
| $$ | ||
|
|
||
| </div> |
There was a problem hiding this comment.
@EddW1219 Please remove the text-align div here. If this results in a bad look, the style should be globally applied in a css file instead of requiring a div for every $$ block.
|
@EddW1219, looks good to merge after you resolve the outstanding conversations :) |
- move injected inline CSS from app wiring into shared stylesheet - remove inline centered div wrapper around display math in tb_isolation model - update report chart rendering to use container width and theme-aware Plotly text/axis styling - refine PDF/print spacing, formula rendering, and chart contrast behavior
|
@EddW1219 Just a comment; it looks like you're including JS inline in |
Just fix that part:) |
As an FYI, if the stylistic changes that code produced were beneficial, there's a way to include the Javascript and get around their sanitizer. We do this in another place in the codebase which could be helpful, if extremely hacky: with importlib.resources.files("epicc").joinpath("js/print_results.js").open("rb") as f:
js = f.read().decode()
js64 = base64.b64encode(js.encode()).decode()
# ...
looks_malicious = f"eval(atob('{js64}'))"
# ...
st.html(
f"<script>{looks_malicious}</script>",
unsafe_allow_javascript=True,
) |
|
Hi @EddW1219, this looks great to me. Would you mind resolving the extant conversations, and if there are none left it looks good to merge to me :) |
Fix Reset/Save parameter button alignment
Aligns Reset Parameters and Save Parameters buttons consistently in the sidebar.
Fix PDF print layout (report view).
Improves print-only chart/text flow to prevent overlap in exported PDF.
Consolidates print CSS behavior for chart spacing and heading separation.
Fixes formula rendering in PDF by preserving visual math output and suppressing assistive MathML in print.