# utils/branding.py """ Logo and branding helpers for the ECG Dashboard. Renders the SCAI Lab sidebar logo and the institutional footer logos. All logo file reads are cached so they only happen once. """ import os import base64 import streamlit as st _ASSET_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets") @st.cache_data(show_spinner=False) def _load_logo_b64(filename: str) -> str | None: """Load a logo file as base64 string. Cached per filename.""" filepath = os.path.join(_ASSET_DIR, filename) if os.path.exists(filepath): with open(filepath, "rb") as f: return base64.b64encode(f.read()).decode() return None def render_sidebar_logo(): """Render the SCAI Lab logo above the dashboard title in the sidebar.""" b64 = _load_logo_b64("scai_lab_logo.svg") if b64: st.sidebar.markdown( f'
' f'SCAI Lab' f'
', unsafe_allow_html=True ) def render_logo_footer(): """ Render institutional logos as a footer bar at the bottom of each page. Order: ETH Zürich → EOC → USI → Vanvitelli (per user preference). """ # Ordered list: (filename, alt-text, height) logos = [ ("ETH_Zürich_Logo_black.svg.png", "ETH Zürich", "32px"), ("eoc_logo.png", "Istituto Cardiocentro Ticino (EOC)", "38px"), ("usi_logo.png", "USI", "38px"), ("Logo_Vanvitelli_university.svg.png", "Università della Campania Luigi Vanvitelli", "38px"), ] logo_html_items = [] for filename, alt, height in logos: b64 = _load_logo_b64(filename) if b64: logo_html_items.append( f'{alt}' ) if logo_html_items: logos_row = "".join(logo_html_items) st.markdown("---") st.markdown( f'
' f'{logos_row}
', unsafe_allow_html=True )