Skip to content

Commit 59e8bd8

Browse files
author
Yuma Ichikawa
committed
fix(app): put Problem above Solve by replacing Streamlit auto-nav with manual page_links
Previously the auto-generated Streamlit multipage nav (Solve / Visualize / Compare) sat *above* the brand block and the manual "Problem" link sat *below* it, so Problem appeared after Solve in the sidebar — the opposite of the natural workflow order. Now we hide the entire ``stSidebarNav`` block in CSS (both light and dark themes) and emit four explicit ``st.page_link`` calls inside ``sidebar_brand()`` in workflow order: Problem → Solve → Visualize → Compare with proper labels and emoji icons. Same destination, clearer ordering, no more "streamlit app" jargon anywhere in the sidebar.
1 parent a8ca352 commit 59e8bd8

1 file changed

Lines changed: 32 additions & 25 deletions

File tree

app/_common.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -326,21 +326,11 @@ def apply_theme() -> None:
326326
background: {p["bg_sidebar"]};
327327
border-right: 1px solid var(--qqa-border);
328328
}}
329-
/* Hide the auto-generated multipage heading ("streamlit app")
330-
rendered above our brand block, AND hide the entry-page
331-
navigation link itself (the brand logo above is the home
332-
anchor; an extra "streamlit app" link is just noise). */
333-
[data-testid="stSidebarNav"]::before {{ display: none; }}
334-
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] > div:first-child,
335-
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] > ul + div:has(>h1),
336-
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] h1:first-of-type,
337-
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] h2:first-of-type {{
338-
display: none !important;
339-
}}
340-
/* Drop the first <li> in the nav list — that is the entry page
341-
link Streamlit derives from the file name (here: "streamlit
342-
app"). The brand block + the page list under it is enough. */
343-
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] ul li:first-child {{
329+
/* Hide Streamlit's entire auto-generated multipage navigator.
330+
We render our own labelled nav (Problem → Solve → Visualize
331+
→ Compare) inside ``sidebar_brand()`` so the workflow order
332+
reads naturally and the entry page has a sensible label. */
333+
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] {{
344334
display: none !important;
345335
}}
346336
[data-testid="stSidebarNav"] a {{
@@ -562,9 +552,8 @@ def apply_theme() -> None:
562552
backdrop-filter: blur(14px);
563553
border-right: 1px solid var(--qqa-border);
564554
}}
565-
/* Same nav-header suppression as in light theme. */
566-
[data-testid="stSidebarNav"]::before {{ display: none; }}
567-
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] ul li:first-child {{
555+
/* Same auto-nav suppression as in light theme. */
556+
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] {{
568557
display: none !important;
569558
}}
570559
section[data-testid="stSidebar"] [data-testid="stSidebarNav"] > div:first-child,
@@ -759,16 +748,34 @@ def sidebar_brand() -> None:
759748
""",
760749
unsafe_allow_html=True,
761750
)
762-
# The auto-generated entry-page link in Streamlit's multipage
763-
# navigator gets its label from the file basename ("streamlit
764-
# app"), which is jargony and confused users into thinking the
765-
# page wasn't clickable. We hide that auto link in CSS and
766-
# instead emit our own properly labelled link here so the user
767-
# always has a discoverable way back to the problem-selection
768-
# page.
751+
# We hide Streamlit's auto-generated multipage navigator with
752+
# CSS (see ``apply_theme``) and replace it with a manual
753+
# ``page_link`` block here. Two reasons:
754+
# 1. The auto navigator labels the entry page by file basename
755+
# ("streamlit app"), which is jargony.
756+
# 2. The auto navigator places itself *above* the brand
757+
# block, so the entry-page link sits below the
758+
# sub-pages — confusing because the entry page is
759+
# conceptually the *first* step (problem selection).
760+
# The manual block lives directly under the brand and lists
761+
# pages in the natural left-to-right workflow order:
762+
# **Problem → Solve → Visualize → Compare**.
769763
if hasattr(st, "page_link"):
770764
with contextlib.suppress(Exception):
765+
st.markdown(
766+
"<div class='qqa-nav' "
767+
"style='margin-top:0.25rem;margin-bottom:0.5rem;'></div>",
768+
unsafe_allow_html=True,
769+
)
771770
st.page_link("streamlit_app.py", label="Problem", icon="🧩")
771+
st.page_link("pages/1_Solve.py", label="Solve", icon="▶️")
772+
st.page_link("pages/2_Visualize.py", label="Visualize", icon="📊")
773+
st.page_link("pages/3_Compare.py", label="Compare", icon="🔬")
774+
st.markdown(
775+
"<div style='border-bottom:1px solid rgba(148,163,184,0.2);"
776+
"margin:0.55rem 0 0.4rem 0;'></div>",
777+
unsafe_allow_html=True,
778+
)
772779

773780

774781
def empty_state_card(

0 commit comments

Comments
 (0)