From bbceb4c6798d43f4b32e73f38fc4907e00733244 Mon Sep 17 00:00:00 2001 From: Tyler Date: Sat, 16 May 2026 01:40:02 -0700 Subject: Rewrite watchlist as custom HTML component with proper styling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces st.button rows with a components.html iframe that renders sym·price·Δ% in a 3-column grid with hairline dividers, monospace fonts, and colored change percentages. Adds hidden text_input click receiver so row clicks update session state. Fixes toggle button to show toast when watchlist cap is hit and removes now-redundant psm-watch-toggle CSS. Co-Authored-By: Claude Sonnet 4.6 --- app.py | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index b0a9453..f8acd3c 100644 --- a/app.py +++ b/app.py @@ -404,29 +404,9 @@ hr { ::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 3px; } ::-webkit-scrollbar-thumb:hover { background: var(--ink-4); } -/* ── Watch toggle button ────────────────────────────────────────────────── */ -[data-testid="stSidebar"] .psm-watch-toggle button { - background: var(--ink-2) !important; - color: var(--fg-3) !important; - border: 1px solid var(--line-2) !important; - border-radius: 2px !important; - font-family: var(--font-sans) !important; - font-size: 0.6875rem !important; - font-weight: 500 !important; - letter-spacing: 0.06em !important; - text-transform: uppercase !important; - padding: 3px 8px !important; - margin-top: 6px !important; -} - -[data-testid="stSidebar"] .psm-watch-toggle button:hover { - background: var(--ink-3) !important; - border-color: var(--line-3) !important; - color: var(--fg-1) !important; -} - -[data-testid="stSidebar"] .psm-watch-toggle button p { - color: inherit !important; +/* Hide the watchlist click receiver input */ +[data-testid="stSidebar"] [data-testid="stTextInput"]:has(input[aria-label="wl_click_receiver"]) { + display: none !important; } /* ── Ticker Header Band ──────────────────────────────────────────────────── */ @@ -762,18 +742,15 @@ with st.sidebar: if ticker: in_watch = ticker in st.session_state["watchlist"] label = "— Remove from watchlist" if in_watch else "+ Save to watchlist" - st.markdown('
', unsafe_allow_html=True) if st.button(label, key="watch_toggle", use_container_width=True): if in_watch: st.session_state["watchlist"].remove(ticker) else: - if ( - ticker not in st.session_state["watchlist"] - and len(st.session_state["watchlist"]) < 10 - ): + if len(st.session_state["watchlist"]) >= 10: + st.toast("Watchlist full — 10 tickers maximum") + else: st.session_state["watchlist"].append(ticker) st.rerun() - st.markdown("
", unsafe_allow_html=True) # ── Watchlist ────────────────────────────────────────────────────────── render_watchlist() -- cgit v1.3-2-g0d8e