vsj0702 commited on
Commit
9fbd263
·
verified ·
1 Parent(s): 23c1a37
Files changed (1) hide show
  1. styles.py +59 -39
styles.py CHANGED
@@ -1,58 +1,78 @@
1
- def get_theme_colors(dm):
 
 
 
2
  return {
3
- "BG": "#0f1620" if dm else "#f5f5f5",
4
- "PANEL_BG": "#1c2330" if dm else "#ffffff",
5
- "TEXT": "#e3e8f1" if dm else "#1a1a1a",
6
  "ACCENT": "#ff5252",
7
- "BORDER": "#2a3240" if dm else "#dddddd",
8
- "SHADOW": "rgba(0,0,0,0.3)" if dm else "rgba(0,0,0,0.1)",
9
- "ACE_THEME": "monokai" if dm else "chrome",
10
  }
11
 
12
- def inject_global_css(colors):
13
- import streamlit as st
14
  st.markdown(f"""
15
  <style>
16
- .stApp {{ background-color: {colors["BG"]}; color: {colors["TEXT"]}; }}
17
- [data-testid="stSidebar"] {{ background-color: {colors["PANEL_BG"]} !important; }}
 
 
 
 
 
18
  .ace_editor, .ace_scroller {{
19
- background: {colors["PANEL_BG"]} !important;
20
- box-shadow: 0 4px 8px {colors["SHADOW"]} !important;
21
- border-radius: 8px !important;
22
  }}
23
  textarea, input, .stTextArea textarea {{
24
- background: {colors["PANEL_BG"]} !important;
25
- color: {colors["TEXT"]} !important;
26
- border: 1px solid {colors["BORDER"]} !important;
27
- border-radius: 4px !important;
28
  }}
29
  button, .stDownloadButton > button {{
30
- background-color: {colors["ACCENT"]} !important;
31
- color: #fff !important;
32
- border-radius: 6px !important;
33
- transition: transform 0.1s;
 
 
 
34
  }}
35
- button:hover {{ transform: scale(1.02) !important; }}
36
  .chat-container {{
37
- background: {colors["PANEL_BG"]} !important;
38
- border: 1px solid {colors["BORDER"]} !important;
39
- border-radius: 8px !important;
40
- padding: 1rem;
41
- max-height: 480px;
42
- overflow-y: auto;
43
- }}
44
- .chat-message {{ margin-bottom: 1rem; padding: 0.75rem 1rem; border-radius: 12px; }}
45
- .user-message {{ background: rgba(100,149,237,0.2); align-self: flex-end; }}
46
- .bot-message {{ background: rgba(200,200,200,0.2); align-self: flex-start; }}
 
 
 
 
 
 
 
 
 
 
47
  pre code {{
48
- display: block;
49
- padding: 0.5rem;
50
- background: rgba(0,0,0,0.1);
51
- border-radius: 4px;
52
- overflow-x: auto;
53
  }}
54
  label[data-testid="stMarkdownContainer"] > div > div {{
55
- color: {colors["TEXT"]} !important;
56
  }}
57
  </style>
58
  """, unsafe_allow_html=True)
 
1
+ import streamlit as st
2
+
3
+ def get_theme_colors(dark_mode: bool) -> dict:
4
+ """Return a color palette based on dark mode preference."""
5
  return {
6
+ "BG": "#0f1620" if dark_mode else "#f5f5f5",
7
+ "PANEL_BG": "#1c2330" if dark_mode else "#ffffff",
8
+ "TEXT": "#e3e8f1" if dark_mode else "#1a1a1a",
9
  "ACCENT": "#ff5252",
10
+ "BORDER": "#2a3240" if dark_mode else "#dddddd",
11
+ "SHADOW": "rgba(0,0,0,0.3)" if dark_mode else "rgba(0,0,0,0.1)",
12
+ "ACE_THEME": "monokai" if dark_mode else "chrome",
13
  }
14
 
15
+ def inject_global_css(colors: dict) -> None:
16
+ """Inject global styling overrides into the Streamlit app based on theme colors."""
17
  st.markdown(f"""
18
  <style>
19
+ .stApp {{
20
+ background-color: {colors["BG"]};
21
+ color: {colors["TEXT"]};
22
+ }}
23
+ [data-testid="stSidebar"] {{
24
+ background-color: {colors["PANEL_BG"]} !important;
25
+ }}
26
  .ace_editor, .ace_scroller {{
27
+ background: {colors["PANEL_BG"]} !important;
28
+ box-shadow: 0 4px 8px {colors["SHADOW"]} !important;
29
+ border-radius: 8px !important;
30
  }}
31
  textarea, input, .stTextArea textarea {{
32
+ background: {colors["PANEL_BG"]} !important;
33
+ color: {colors["TEXT"]} !important;
34
+ border: 1px solid {colors["BORDER"]} !important;
35
+ border-radius: 4px !important;
36
  }}
37
  button, .stDownloadButton > button {{
38
+ background-color: {colors["ACCENT"]} !important;
39
+ color: #fff !important;
40
+ border-radius: 6px !important;
41
+ transition: transform 0.1s;
42
+ }}
43
+ button:hover {{
44
+ transform: scale(1.02) !important;
45
  }}
 
46
  .chat-container {{
47
+ background: {colors["PANEL_BG"]} !important;
48
+ border: 1px solid {colors["BORDER"]} !important;
49
+ border-radius: 8px !important;
50
+ padding: 1rem;
51
+ max-height: 480px;
52
+ overflow-y: auto;
53
+ }}
54
+ .chat-message {{
55
+ margin-bottom: 1rem;
56
+ padding: 0.75rem 1rem;
57
+ border-radius: 12px;
58
+ }}
59
+ .user-message {{
60
+ background: rgba(100,149,237,0.2);
61
+ align-self: flex-end;
62
+ }}
63
+ .bot-message {{
64
+ background: rgba(200,200,200,0.2);
65
+ align-self: flex-start;
66
+ }}
67
  pre code {{
68
+ display: block;
69
+ padding: 0.5rem;
70
+ background: rgba(0,0,0,0.1);
71
+ border-radius: 4px;
72
+ overflow-x: auto;
73
  }}
74
  label[data-testid="stMarkdownContainer"] > div > div {{
75
+ color: {colors["TEXT"]} !important;
76
  }}
77
  </style>
78
  """, unsafe_allow_html=True)