Spaces:
Sleeping
Sleeping
Updating
Browse files
styles.py
CHANGED
|
@@ -1,58 +1,78 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
| 2 |
return {
|
| 3 |
-
"BG": "#0f1620" if
|
| 4 |
-
"PANEL_BG": "#1c2330" if
|
| 5 |
-
"TEXT": "#e3e8f1" if
|
| 6 |
"ACCENT": "#ff5252",
|
| 7 |
-
"BORDER": "#2a3240" if
|
| 8 |
-
"SHADOW": "rgba(0,0,0,0.3)" if
|
| 9 |
-
"ACE_THEME": "monokai" if
|
| 10 |
}
|
| 11 |
|
| 12 |
-
def inject_global_css(colors):
|
| 13 |
-
|
| 14 |
st.markdown(f"""
|
| 15 |
<style>
|
| 16 |
-
.stApp {{
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
.ace_editor, .ace_scroller {{
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
}}
|
| 23 |
textarea, input, .stTextArea textarea {{
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
}}
|
| 29 |
button, .stDownloadButton > button {{
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 34 |
}}
|
| 35 |
-
button:hover {{ transform: scale(1.02) !important; }}
|
| 36 |
.chat-container {{
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
}}
|
| 44 |
-
.chat-message {{
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
pre code {{
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
}}
|
| 54 |
label[data-testid="stMarkdownContainer"] > div > div {{
|
| 55 |
-
|
| 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)
|