Spaces:
Runtime error
Runtime error
File size: 1,506 Bytes
79682b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import streamlit as st
if 'primaryColor' not in st.session_state:
st.session_state['primaryColor'] = "#F63366"
if 'backgroundColor' not in st.session_state:
st.session_state['backgroundColor'] = "#FFFFFF"
if 'secondaryBackgroundColor' not in st.session_state:
st.session_state['secondaryBackgroundColor'] = "#F0F2F6"
if 'textColor' not in st.session_state:
st.session_state['textColor'] = "#262730"
def reconcile_theme_config():
keys = ['primaryColor', 'backgroundColor', 'secondaryBackgroundColor', 'textColor']
has_changed = False
for key in keys:
if st._config.get_option(f'theme.{key}') != st.session_state[key]:
st._config.set_option(f'theme.{key}', st.session_state[key])
has_changed = True
if has_changed:
st.experimental_rerun()
primary_color = st.color_picker('Primary color', key="primaryColor")
background_color = st.color_picker('Background color', key="backgroundColor")
secondary_background_color = st.color_picker('Secondary background color', key="secondaryBackgroundColor")
text_color = st.color_picker('Text color', key="textColor")
reconcile_theme_config()
st.code("""
primaryColor="{primaryColor}"
backgroundColor="{backgroundColor}"
secondaryBackgroundColor="{secondaryBackgroundColor}}"
textColor="{textColor}}"
""")
def sample_components(key: str):
st.slider("Slider", min_value=0, max_value=100, key=f"{key}:slider")
sample_components("body")
with st.sidebar:
sample_components("sidebar")
|