whitphx HF staff commited on
Commit
ca2a055
1 Parent(s): 3dc326b

Refactoring

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -1,17 +1,33 @@
1
  import re
 
2
 
3
  import streamlit as st
4
 
5
  import fragments
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  if 'primaryColor' not in st.session_state:
8
- st.session_state['primaryColor'] = st._config.get_option(f'theme.primaryColor') or "#ff4b4b"
9
  if 'backgroundColor' not in st.session_state:
10
- st.session_state['backgroundColor'] = st._config.get_option(f'theme.backgroundColor') or "#ffffff"
11
  if 'secondaryBackgroundColor' not in st.session_state:
12
- st.session_state['secondaryBackgroundColor'] = st._config.get_option(f'theme.secondaryBackgroundColor') or "#f0f2f6"
13
  if 'textColor' not in st.session_state:
14
- st.session_state['textColor'] = st._config.get_option(f'theme.textColor') or "#31333F"
15
 
16
 
17
  primary_color = st.color_picker('Primary color', key="primaryColor")
 
1
  import re
2
+ from typing import NamedTuple
3
 
4
  import streamlit as st
5
 
6
  import fragments
7
 
8
+ class ThemeColor(NamedTuple):
9
+ primaryColor: str
10
+ backgroundColor: str
11
+ secondaryBackgroundColor: str
12
+ textColor: str
13
+
14
+
15
+ default_color = ThemeColor(
16
+ primaryColor="#ff4b4b",
17
+ backgroundColor="#ffffff",
18
+ secondaryBackgroundColor="#f0f2f6",
19
+ textColor="#31333F",
20
+ )
21
+
22
+
23
  if 'primaryColor' not in st.session_state:
24
+ st.session_state['primaryColor'] = st._config.get_option(f'theme.primaryColor') or default_color.primaryColor
25
  if 'backgroundColor' not in st.session_state:
26
+ st.session_state['backgroundColor'] = st._config.get_option(f'theme.backgroundColor') or default_color.backgroundColor
27
  if 'secondaryBackgroundColor' not in st.session_state:
28
+ st.session_state['secondaryBackgroundColor'] = st._config.get_option(f'theme.secondaryBackgroundColor') or default_color.secondaryBackgroundColor
29
  if 'textColor' not in st.session_state:
30
+ st.session_state['textColor'] = st._config.get_option(f'theme.textColor') or default_color.textColor
31
 
32
 
33
  primary_color = st.color_picker('Primary color', key="primaryColor")