Spaces:
Sleeping
Sleeping
Nacho commited on
Commit ·
1eb293c
1
Parent(s): 841050d
Fix footer bar alignment via anchor positioning
Browse files445 unmodified lines44644744844945045148 unmodified lines5005015025035045055065075085099 unmodified lines5195205215225235245255265272 unmodified lines530531532533534535536537538539540541542543544545546547445 unmodified linesfooter = st.container()with footer:# Tightened columns to group elements togetherc_mic, c_plus, c_input, c_send = st.columns([0.8, 0.6, 9.5, 0.6], vertical_alignment="center")48 unmodified linesst.session_state.last_voice_text = ""st.rerun()# FLOAT THE BAR# Light Mode: white background with light borderfooter.float("position: fixed !important; bottom: 0 !important; left: 0 !important; width: 100% !important; background-color: #ffffff !important; border-top: none !important; padding: 8px var(--footer-pad-right, 25px) 15px var(--footer-pad-left, 25px) !important; z-index: 999999 !important; box-sizing: border-box !important;")# Tag the "+" button so CSS can target it reliablyst.components.v1.html("""9 unmodified lines});};let lastPadLeft = null;let lastPadRight = null;const syncFooterBounds = () => {const block = doc.querySelector('[data-testid="stAppViewContainer"] .main .block-container');if (!block) return;const rect = block.getBoundingClientRect();2 unmodified linesconst padR = parseFloat(styles.paddingRight) || 0;const leftEdge = rect.left + padL;const rightEdge = rect.right - padR;const padLeft = Math.max(0, leftEdge);const padRight = Math.max(0, win.innerWidth - rightEdge);if (padLeft !== lastPadLeft || padRight !== lastPadRight) {doc.documentElement.style.setProperty('--footer-pad-left', `${padLeft}px`);doc.documentElement.style.setProperty('--footer-pad-right', `${padRight}px`);lastPadLeft = padLeft;lastPadRight = padRight;}};setTimeout(tagPlusButton, 50);setTimeout(tagPlusButton, 300);setTimeout(syncFooterBounds, 50);setTimeout(syncFooterBounds, 300);win.addEventListener('resize', syncFooterBounds);445 unmodified lines44644744844945045145248 unmodified lines5015025035045055069 unmodified lines5165175185195205215225235245255265275285295305315325335345355365375382 unmodified lines541542543544545546547548549550551552553554555556557558559445 unmodified linesfooter = st.container()with footer:st.markdown("<div id='footer-anchor' style='height:0;'></div>", unsafe_allow_html=True)# Tightened columns to group elements togetherc_mic, c_plus, c_input, c_send = st.columns([0.8, 0.6, 9.5, 0.6], vertical_alignment="center")48 unmodified linesst.session_state.last_voice_text = ""st.rerun()# Tag the "+" button so CSS can target it reliablyst.components.v1.html("""9 unmodified lines});};const footerAnchor = doc.getElementById('footer-anchor');const footerBlock = footerAnchor ? footerAnchor.closest('[data-testid="stVerticalBlock"]') : null;let lastLeft = null;let lastWidth = null;const applyFooterBaseStyles = () => {if (!footerBlock) return;footerBlock.style.position = 'fixed';footerBlock.style.bottom = '0';footerBlock.style.background = '#ffffff';footerBlock.style.zIndex = '999999';footerBlock.style.boxSizing = 'border-box';footerBlock.style.padding = '8px 0 15px 0';};const syncFooterBounds = () => {if (!footerBlock) return;const block = doc.querySelector('[data-testid="stAppViewContainer"] .main .block-container');if (!block) return;const rect = block.getBoundingClientRect();2 unmodified linesconst padR = parseFloat(styles.paddingRight) || 0;const leftEdge = rect.left + padL;const rightEdge = rect.right - padR;const width = Math.max(0, rightEdge - leftEdge);if (leftEdge !== lastLeft || width !== lastWidth) {footerBlock.style.left = `${leftEdge}px`;footerBlock.style.width = `${width}px`;lastLeft = leftEdge;lastWidth = width;}};setTimeout(tagPlusButton, 50);setTimeout(tagPlusButton, 300);setTimeout(applyFooterBaseStyles, 50);setTimeout(applyFooterBaseStyles, 300);setTimeout(syncFooterBounds, 50);setTimeout(syncFooterBounds, 300);win.addEventListener('resize', syncFooterBounds);
app.py+25-13