Spaces:
Runtime error
Runtime error
Refactoring
Browse files
app.py
CHANGED
|
@@ -32,21 +32,20 @@ secondary_background_color_rgb = parse_hex(secondary_background_color)
|
|
| 32 |
|
| 33 |
st.header("WCAG contrast ratio")
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
col1, col2, col3 = st.columns(3)
|
| 36 |
with col2:
|
| 37 |
-
|
| 38 |
-
st.session_state["backgroundColor"] = st.session_state["backgroundColor2"]
|
| 39 |
-
st.color_picker("Background color", value=background_color, key="backgroundColor2", on_change=on_change)
|
| 40 |
with col3:
|
| 41 |
-
|
| 42 |
-
st.session_state["secondaryBackgroundColor"] = st.session_state["secondaryBackgroundColor2"]
|
| 43 |
-
st.color_picker("Secondary background color", value=secondary_background_color, key="secondaryBackgroundColor2", on_change=on_change)
|
| 44 |
|
| 45 |
col1, col2, col3 = st.columns(3)
|
| 46 |
with col1:
|
| 47 |
-
|
| 48 |
-
st.session_state["primaryColor"] = st.session_state["primaryColor2"]
|
| 49 |
-
st.color_picker("Primary color", value=primary_color, key="primaryColor2", on_change=on_change)
|
| 50 |
with col2:
|
| 51 |
fragments.contrast_summary(primary_color_rgb, background_color_rgb)
|
| 52 |
with col3:
|
|
@@ -54,9 +53,7 @@ with col3:
|
|
| 54 |
|
| 55 |
col1, col2, col3 = st.columns(3)
|
| 56 |
with col1:
|
| 57 |
-
|
| 58 |
-
st.session_state["textColor"] = st.session_state["textColor2"]
|
| 59 |
-
st.color_picker("Text color", value=text_color, key="textColor2", on_change=on_change)
|
| 60 |
with col2:
|
| 61 |
fragments.contrast_summary(text_color_rgb, background_color_rgb)
|
| 62 |
with col3:
|
|
|
|
| 32 |
|
| 33 |
st.header("WCAG contrast ratio")
|
| 34 |
|
| 35 |
+
def synced_color_picker(label: str, value: str, key: str):
|
| 36 |
+
def on_change():
|
| 37 |
+
st.session_state[key] = st.session_state[key + "2"]
|
| 38 |
+
st.color_picker(label, value=value, key=key + "2", on_change=on_change)
|
| 39 |
+
|
| 40 |
col1, col2, col3 = st.columns(3)
|
| 41 |
with col2:
|
| 42 |
+
synced_color_picker("Background color", value=background_color, key="backgroundColor")
|
|
|
|
|
|
|
| 43 |
with col3:
|
| 44 |
+
synced_color_picker("Secondary background color", value=secondary_background_color, key="secondaryBackgroundColor")
|
|
|
|
|
|
|
| 45 |
|
| 46 |
col1, col2, col3 = st.columns(3)
|
| 47 |
with col1:
|
| 48 |
+
synced_color_picker("Primary color", value=primary_color, key="primaryColor")
|
|
|
|
|
|
|
| 49 |
with col2:
|
| 50 |
fragments.contrast_summary(primary_color_rgb, background_color_rgb)
|
| 51 |
with col3:
|
|
|
|
| 53 |
|
| 54 |
col1, col2, col3 = st.columns(3)
|
| 55 |
with col1:
|
| 56 |
+
synced_color_picker("Text color", value=text_color, key="textColor")
|
|
|
|
|
|
|
| 57 |
with col2:
|
| 58 |
fragments.contrast_summary(text_color_rgb, background_color_rgb)
|
| 59 |
with col3:
|