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