Spaces:
Sleeping
Sleeping
Update utils/ui.py
Browse files24 unmodified lines25262728293020 unmodified lines51525354555657585960616263646566672 unmodified lines7071727374757677787980155 unmodified lines2362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792808 unmodified lines2892902912922932942954 unmodified lines30030130230324 unmodified lines--radius-sm:8px;}}/* βββ NUCLEAR CHROME REMOVAL βββ */#MainMenu,footer,header,[data-testid="stToolbar"],20 unmodified lines/* βββ FULL SIZE APP βββ */html, body {{width:100%!important;height:100%!important;overflow:auto!important;background:var(--bg)!important;color:var(--text)!important;font-family:'DM Sans',sans-serif!important;margin:0!important;padding:0!important;}}.stApp,[data-testid="stAppViewContainer"] {{background:var(--bg)!important;color:var(--text)!important;font-family:'DM Sans',sans-serif!important;2 unmodified lines}}/* Remove ALL padding from Streamlit wrapper layers */[data-testid="stAppViewContainer"] > section {{padding-top:0!important;width:100%!important;}}[data-testid="stAppViewContainer"] > section > div.block-container {{max-width:1160px!important;width:100%!important;155 unmodified lines}}</style>"""# JS that runs once after page load to nuke any chrome that CSS missedHIDE_CHROME_JS = """<script>(function() {var HIDE = ['#MainMenu','header','footer','[data-testid="stHeader"]','[data-testid="stToolbar"]','[data-testid="stToolbarActions"]','[data-testid="stDecoration"]','[data-testid="stStatusWidget"]','[data-testid="collapsedControl"]','[data-testid="baseButton-header"]','.stDeployButton','button[kind="header"]'];function nuke() {HIDE.forEach(function(sel) {document.querySelectorAll(sel).forEach(function(el) {el.style.cssText = 'display:none!important;visibility:hidden!important;' +'opacity:0!important;height:0!important;width:0!important;' +'position:absolute!important;pointer-events:none!important;overflow:hidden!important;';});});}nuke();new MutationObserver(nuke).observe(document.documentElement,{childList:true, subtree:true, attributes:false});})();</script>"""def inject_css():import streamlit as stst.markdown(BASE_CSS, unsafe_allow_html=True)st.markdown(HIDE_CHROME_JS, unsafe_allow_html=True)def stat_card(icon, label, value, sub="", accent="var(--accent)"):return f"""<div style="background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);8 unmodified lines{f'<div style="font-size:0.72rem;color:var(--muted2);margin-top:3px">{sub}</div>' if sub else ''}</div>"""def section_header(title, sub=""):return f"""<div style="display:flex;align-items:center;gap:12px;margin:28px 0 16px">4 unmodified linescolor:var(--text)">{title}</div>{f'<div style="font-size:0.75rem;color:var(--muted);margin-top:1px">{sub}</div>' if sub else ''}</div></div>"""24 unmodified lines25262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010120 unmodified lines1221231241251261271281291301311321332 unmodified lines136137138139140141155 unmodified lines2972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863878 unmodified lines3963973983994004014 unmodified lines40640740840924 unmodified lines--radius-sm:8px;}}/* βββ FIXED SCROLLING BEHAVIOR βββ */html {{scroll-behavior: auto !important;overflow-y: scroll !important;overflow-x: hidden !important;height: 100% !important;}}body {{overflow-y: scroll !important;overflow-x: hidden !important;position: relative !important;min-height: 100vh !important;height: 100% !important;margin: 0 !important;padding: 0 !important;}}/* Prevent any overflow shifts */[data-testid="stAppViewContainer"] {{overflow: hidden !important;position: fixed !important;top: 0 !important;left: 0 !important;right: 0 !important;bottom: 0 !important;background: var(--bg) !important;}}[data-testid="stAppViewContainer"] > section {{height: 100vh !important;overflow-y: auto !important;overflow-x: hidden !important;padding-top: 0 !important;}}/* Consistent scrollbar to prevent width shifts */::-webkit-scrollbar {{width: 8px !important;background: #0a0a16 !important;}}::-webkit-scrollbar-thumb {{background: #6366f1 !important;border-radius: 4px !important;}}::-webkit-scrollbar-track {{background: #0a0a16 !important;}}/* Prevent focus outline from causing shifts */*:focus {{outline: none !important;}}/* Stabilize input fields */input, textarea, select, button {{scroll-margin: 0 !important;scroll-snap-margin: 0 !important;}}/* Prevent any transform animations that might cause shifts */* {{-webkit-transform: translateZ(0) !important;transform: translateZ(0) !important;-webkit-backface-visibility: hidden !important;backface-visibility: hidden !important;-webkit-font-smoothing: antialiased !important;}}/* βββ NUCLEAR CHROME REMOVAL βββ */#MainMenu,footer,header,[data-testid="stToolbar"],20 unmodified lines/* βββ FULL SIZE APP βββ */html, body {{width:100%!important;background:var(--bg)!important;color:var(--text)!important;font-family:'DM Sans',sans-serif!important;}}.stApp {{background:var(--bg)!important;color:var(--text)!important;font-family:'DM Sans',sans-serif!important;2 unmodified lines}}/* Remove ALL padding from Streamlit wrapper layers */[data-testid="stAppViewContainer"] > section > div.block-container {{max-width:1160px!important;width:100%!important;155 unmodified lines}}</style>"""def inject_css():import streamlit as st# Inject the base CSSst.markdown(BASE_CSS, unsafe_allow_html=True)# Enhanced JavaScript to prevent keyboard scrolling and nuke chromeHIDE_CHROME_JS = """<script>(function() {// Prevent keyboard from triggering scrolldocument.addEventListener('keydown', function(e) {// Prevent default scrolling behavior for arrow keys, page up/down, home/end, spaceconst keysToPrevent = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight','PageUp', 'PageDown', 'Home', 'End', ' ','Space', 'Spacebar'];if (keysToPrevent.includes(e.key) || e.key === ' ') {e.preventDefault();return false;}}, false);// Also prevent scroll restoration on page loadif ('scrollRestoration' in history) {history.scrollRestoration = 'manual';}// Force scroll to top on page load and prevent any auto-scrollingwindow.scrollTo(0, 0);// Disable any scroll anchoring behaviorif (document.body && typeof document.body.style !== 'undefined') {document.body.style.overflowAnchor = 'none';}// Hide all Streamlit chrome elementsvar HIDE = ['#MainMenu','header','footer','[data-testid="stHeader"]','[data-testid="stToolbar"]','[data-testid="stToolbarActions"]','[data-testid="stDecoration"]','[data-testid="stStatusWidget"]','[data-testid="collapsedControl"]','[data-testid="baseButton-header"]','.stDeployButton','button[kind="header"]','[data-testid="stSidebarNav"]'];function nuke() {HIDE.forEach(function(sel) {document.querySelectorAll(sel).forEach(function(el) {el.style.cssText = 'display:none!important;visibility:hidden!important;' +'opacity:0!important;height:0!important;width:0!important;' +'position:absolute!important;pointer-events:none!important;overflow:hidden!important;';});});}nuke();new MutationObserver(nuke).observe(document.documentElement,{childList: true, subtree: true, attributes: false});// Additional fix: prevent any element from receiving focus that might cause scrolldocument.addEventListener('focusin', function(e) {// Don't prevent default focus behavior, just ensure no scroll happensif (e.target) {// Temporarily disable scroll restorationvar currentScroll = window.scrollY;setTimeout(function() {window.scrollTo(0, currentScroll);}, 0);}}, false);})();</script>"""st.markdown(HIDE_CHROME_JS, unsafe_allow_html=True)def stat_card(icon, label, value, sub="", accent="var(--accent)"):return f"""<div style="background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);8 unmodified lines{f'<div style="font-size:0.72rem;color:var(--muted2);margin-top:3px">{sub}</div>' if sub else ''}</div>"""def section_header(title, sub=""):return f"""<div style="display:flex;align-items:center;gap:12px;margin:28px 0 16px">4 unmodified linescolor:var(--text)">{title}</div>{f'<div style="font-size:0.75rem;color:var(--muted);margin-top:1px">{sub}</div>' if sub else ''}</div></div>"""
utils/ui.py+153-47