import streamlit as st from components.connexion import connexion, bouton_deconnexion import streamlit.components.v1 as components from utils.translations import _ def afficher_menu(): with st.sidebar: st.markdown(f""" """, unsafe_allow_html=True) # === GESTION DU THÈME === # # Le changement de thème induit un st.rerun qui vide les formula # Pour éviter de perdre les informations dans les formulaires, # le changement de thème n'est proposé que si l'utilisateur est sur l'onglet "Instructions" # if st.session_state.onglet == instructions_text: if "theme_mode" not in st.session_state: st.session_state.theme_mode = str(_("sidebar.theme_light")) theme_title = str(_("sidebar.theme")) st.markdown(f"""

{theme_title}

""", unsafe_allow_html=True) theme_options = [ str(_("sidebar.theme_light")), str(_("sidebar.theme_dark")) ] theme = st.radio( str(_("sidebar.theme")), theme_options, index=theme_options.index(st.session_state.theme_mode), horizontal=True, label_visibility="hidden" ) st.markdown("""
""", unsafe_allow_html=True) else : theme_title = str(_("sidebar.theme")) st.markdown(f"""

{theme_title}

""", unsafe_allow_html=True) st.info(str(_("sidebar.theme_instructions_only"))) st.markdown("""
""", unsafe_allow_html=True) theme = st.session_state.theme_mode connexion() if st.session_state.get("logged_in", False): bouton_deconnexion() # === RERUN SI BESOIN === if (onglet_choisi and onglet_choisi != st.session_state.onglet) or (theme != st.session_state.theme_mode): if onglet_choisi: # Ne met à jour que si on a cliqué st.session_state.onglet = onglet_choisi st.session_state.theme_mode = theme st.rerun() def afficher_impact(total_bytes): impact_label = str(_("sidebar.impact")) loading_text = str(_("sidebar.loading")) with st.sidebar: components.html(f""" Impact Environnemental

{impact_label}

{loading_text}

""") st.markdown("""
This website runs on green hosting - verified by thegreenwebfoundation.org
""", unsafe_allow_html=True)