Create config/pagesetup.py
Browse files- config/pagesetup.py +90 -0
config/pagesetup.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as c
|
| 3 |
+
from streamlit_elements import elements, mui, html
|
| 4 |
+
import hydralit_components as hc
|
| 5 |
+
import extra_streamlit_components as stx
|
| 6 |
+
from streamlit_extras.metric_cards import style_metric_cards
|
| 7 |
+
|
| 8 |
+
### 1. TITLE and SUBTITLE
|
| 9 |
+
def set_title(varTitle, varSubtitle):
|
| 10 |
+
st.markdown(f"""<span style="font-weight: bold; font-size: 2em; color:#00b084;">{varTitle} </span> <span style="font-weight: bold; color:#0096D7; font-size:1.3em;">{varSubtitle}</span>""", unsafe_allow_html=True)
|
| 11 |
+
st.divider()
|
| 12 |
+
|
| 13 |
+
def set_title_nodiv(varTitle, varSubtitle):
|
| 14 |
+
st.markdown(f"""<span style="font-weight: bold; font-size: 2em; color:#00b084;">{varTitle} </span> <span style="font-weight: bold; color:#0096D7; font-size:1.3em;">{varSubtitle}</span>""", unsafe_allow_html=True)
|
| 15 |
+
#st.divider()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
### 2. Wording
|
| 19 |
+
def set_blue_header(varSubtitle):
|
| 20 |
+
st.markdown(f"""<span style="font-weight: bold; color:#0096D7; font-size:1.3em;">{varSubtitle}</span>""", unsafe_allow_html=True)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def set_green_header(varSubtitle):
|
| 24 |
+
st.markdown(f"""<span style="font-weight: bold; color:#00b084; font-size:1.3em;">{varSubtitle}</span>""", unsafe_allow_html=True)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
### 3. PAGE OVERVIEW
|
| 28 |
+
def set_page_overview(varHeader, varText):
|
| 29 |
+
set_blue_header(varHeader)
|
| 30 |
+
st.markdown(f"{varText}")
|
| 31 |
+
st.divider()
|
| 32 |
+
|
| 33 |
+
### 4. HYDRALIT NAVBAR
|
| 34 |
+
|
| 35 |
+
def set_nav_bar():
|
| 36 |
+
navbar_menu_items = [
|
| 37 |
+
{'icon': "far fa-chart-bar", 'label':"Item1", 'ttip': "tooltip"},
|
| 38 |
+
{'icon': "fas fa-tachometer-alt", 'label':"Item2",'ttip':"tooltip"},
|
| 39 |
+
{'icon': "far fa-copy", 'label':"Item3", 'ttip': "Tooltip", 'submenu': [{'icon': "fa fa-paperclip", 'label': "Subitem1"}, {'icon': "fa fa-database", 'label': "subitem2"}, {'icon': "far fa-copy", 'label': "Subitem3"}]}
|
| 40 |
+
]
|
| 41 |
+
over_theme = {'txc_inactive': '#FFFFFF'}
|
| 42 |
+
menu_id = hc.nav_bar(
|
| 43 |
+
menu_definition = navbar_menu_items,
|
| 44 |
+
override_theme = over_theme,
|
| 45 |
+
home_name = "Home",
|
| 46 |
+
login_name = "Logout",
|
| 47 |
+
hide_streamlit_markers=False,
|
| 48 |
+
sticky_nav = True,
|
| 49 |
+
sticky_mode = "pinned"
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
### 5. TITLE + PAGE OVERVIEW
|
| 53 |
+
def set_title_pageoverview(varTitle, varSubtitle, varHeader, varSubheader):
|
| 54 |
+
container0 = st.container()
|
| 55 |
+
with container0:
|
| 56 |
+
set_title(varTitle, varSubtitle)
|
| 57 |
+
|
| 58 |
+
container1=st.container()
|
| 59 |
+
with container1:
|
| 60 |
+
set_page_overview(varHeader, varSubheader)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
# 1. KPI METRIC STYLING - Create container with # of columns = to # of metrics in a metrics dictionary
|
| 65 |
+
def get_metric_container(varMetrics):
|
| 66 |
+
metrics = varMetrics #array of metrics dictionary {"lablel": "", "id": "", "value": #, "delta": #}
|
| 67 |
+
lenMetrics = len(metrics)
|
| 68 |
+
cols = st.columns(lenMetrics)
|
| 69 |
+
|
| 70 |
+
for idx, metric in enumerate(metrics):
|
| 71 |
+
cols[idx].metric(label=metric["label"], value=metric["value"], delta=metric["delta"])
|
| 72 |
+
style_metric_cards(
|
| 73 |
+
border_left_color="#0096D7",
|
| 74 |
+
border_color="#0096D7",
|
| 75 |
+
box_shadow=True
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
#"""
|
| 79 |
+
# Applies a custom style to st.metrics in the page
|
| 80 |
+
|
| 81 |
+
# Args:
|
| 82 |
+
# background_color (str, optional): Background color. Defaults to "#FFF".
|
| 83 |
+
# border_size_px (int, optional): Border size in pixels. Defaults to 1.
|
| 84 |
+
# border_color (str, optional): Border color. Defaults to "#CCC".
|
| 85 |
+
# border_radius_px (int, optional): Border radius in pixels. Defaults to 5.
|
| 86 |
+
# border_left_color (str, optional): Borfer left color. Defaults to "#9AD8E1".
|
| 87 |
+
# box_shadow (bool, optional): Whether a box shadow is applied. Defaults to True.
|
| 88 |
+
# """
|
| 89 |
+
|
| 90 |
+
#https://arnaudmiribel.github.io/streamlit-extras/extras/metric_cards/
|