"""Functions for the layout of the Streamlit app, including the sidebar.""" import json import os from typing import Literal import streamlit as st from src import hf_utils from src.config_parameters import params def get_aoi_id_from_selector_preview(all_aois, name): for aoi_id, aoi in all_aois.items(): if aoi["name"] == name: return aoi_id # Check if app is deployed def is_app_on_streamlit(): """Check whether the app is on streamlit or runs locally.""" return "HOSTNAME" in os.environ and os.environ["HOSTNAME"] == "streamlit" # General layout def toggle_menu_button(): """If app is on streamlit, hide menu button.""" if is_app_on_streamlit(): st.markdown( """ """, unsafe_allow_html=True, ) # Home page def set_home_page_style(): """Set style home page.""" st.markdown( """ """ % params["docs_fontsize"], unsafe_allow_html=True, ) # Documentation page def set_doc_page_style(): """Set style documentation page.""" st.markdown( """ """ % params["docs_fontsize"], unsafe_allow_html=True, ) # Tool page def set_tool_page_style(): """Set style tool page.""" st.markdown( """ """ % ( params["expander_header_fontsize"], params["widget_header_fontsize"], params["widget_header_fontsize"], params["widget_header_fontsize"], params["button_text_fontsize"], params["button_text_fontweight"], params["button_background_color"], ), unsafe_allow_html=True, ) # Sidebar def add_about(): """ Add about and contacts to sidebar. Inputs: None Returns: None """ # About textbox st.sidebar.markdown("## Source Code") st.sidebar.markdown( f"""
""", unsafe_allow_html=True, ) st.sidebar.markdown("## Feedback") st.sidebar.markdown( """ Were you able to find a useful flood map or experiencing a bug? Please leave any feedback through [this quick form](https://ee.ifrc.org/x/ZeCPlh7W). """ ) # Contacts textbox st.sidebar.markdown(" ") st.sidebar.markdown("## Contacts") # Add data scientists and emails contacts_text = "" for ds, email in params["data_scientists"].items(): contacts_text += ds + ( "" "%s%s