Spaces:
Running
Running
feat: Revamp UI theme and styling for improved dark mode experience
Browse files- Updated the custom theme to utilize a dark base with a cohesive color palette, enhancing visual appeal.
- Adjusted tab and button styles for better contrast and readability in dark mode.
- Refined sidebar and expander header styles to align with the new theme.
- Added a footer for consistent branding and information display.
app.py
CHANGED
@@ -26,10 +26,11 @@ def create_custom_theme():
|
|
26 |
f.write(
|
27 |
"""
|
28 |
[theme]
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
font = "sans serif"
|
34 |
"""
|
35 |
)
|
@@ -79,73 +80,78 @@ hide_st_style = """
|
|
79 |
#MainMenu {visibility: hidden;}
|
80 |
footer {visibility: hidden;}
|
81 |
header {visibility: hidden;}
|
82 |
-
/* Body background */
|
83 |
-
.stApp {
|
84 |
-
background-color: #
|
85 |
-
}
|
86 |
/* Tab styling */
|
87 |
.stTabs [data-baseweb="tab-list"] {
|
88 |
gap: 8px; /* Slightly reduced gap */
|
89 |
-
border-bottom: 1px solid #
|
90 |
}
|
91 |
.stTabs [data-baseweb="tab"] {
|
92 |
background-color: transparent; /* Make tabs transparent */
|
93 |
border-radius: 0; /* Remove border radius */
|
94 |
padding: 10px 15px;
|
95 |
-
color: #
|
96 |
border-bottom: 2px solid transparent; /* Prepare for selected indicator */
|
97 |
transition: all 0.3s ease;
|
98 |
}
|
99 |
.stTabs [data-baseweb="tab"]:hover {
|
100 |
-
background-color: #
|
101 |
-
color: #
|
102 |
}
|
103 |
.stTabs [aria-selected="true"] {
|
104 |
background-color: transparent !important;
|
105 |
-
color: #
|
106 |
-
border-bottom: 2px solid #
|
107 |
font-weight: 600; /* Make selected tab bold */
|
108 |
}
|
109 |
-
/* Sidebar styling */
|
110 |
-
.css-1d391kg {
|
111 |
-
background-color: #
|
112 |
-
}
|
113 |
-
/* Ensure sidebar text is readable */
|
114 |
-
.css-1d391kg .stMarkdown, .css-1d391kg .stCheckbox, .css-1d391kg .stExpander, .css-1d391kg .stText, .css-1d391kg .stButton > button {
|
115 |
-
color: #
|
116 |
-
}
|
117 |
/* Button styling */
|
118 |
.stButton>button {
|
119 |
-
background-color: #
|
120 |
-
color: #
|
121 |
-
border: 1px solid #
|
122 |
transition: all 0.3s ease !important;
|
123 |
box-shadow: none !important; /* Remove default shadow */
|
124 |
}
|
125 |
.stButton>button:hover {
|
126 |
-
background-color: #
|
127 |
-
border-color: #
|
128 |
transform: none !important; /* Remove hover transform */
|
129 |
box-shadow: none !important;
|
130 |
}
|
131 |
.stButton>button:active {
|
132 |
-
background-color: #
|
133 |
}
|
134 |
/* Expander header styling */
|
135 |
.stExpander > div:first-child {
|
136 |
-
background-color: #
|
137 |
border-radius: 4px;
|
138 |
}
|
139 |
.stExpander header { /* Target expander header specifically */
|
140 |
-
color: #
|
141 |
font-weight: 600;
|
142 |
}
|
143 |
/* General adjustments for minimalist feel */
|
144 |
h1, h2, h3, h4, h5, h6 {
|
145 |
-
color: #
|
146 |
}
|
147 |
.stMarkdown p {
|
148 |
-
color: #
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
</style>
|
151 |
"""
|
@@ -280,8 +286,8 @@ with main_tabs[0]: # Camera Feed Tab
|
|
280 |
st.markdown(
|
281 |
f"""
|
282 |
<div style="background-color: {preview_color_hsl}; width: 100%; height: 30px;
|
283 |
-
border: 1px solid #
|
284 |
-
<p style='text-align: center;
|
285 |
Preview (Lower Bound)
|
286 |
</p>
|
287 |
</div>
|
@@ -371,7 +377,7 @@ with main_tabs[0]: # Camera Feed Tab
|
|
371 |
"border-radius": "8px",
|
372 |
"margin": "0 auto",
|
373 |
"display": "block",
|
374 |
-
"border": "2px solid #
|
375 |
},
|
376 |
),
|
377 |
)
|
@@ -524,3 +530,14 @@ with main_tabs[2]: # Documentation Tab
|
|
524 |
"""
|
525 |
)
|
526 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
f.write(
|
27 |
"""
|
28 |
[theme]
|
29 |
+
base = "dark" # Use Streamlit's dark theme as a base
|
30 |
+
primaryColor = "#CCCCCC" # Light Grey accent
|
31 |
+
backgroundColor = "#0E1117" # Default Streamlit dark bg
|
32 |
+
secondaryBackgroundColor = "#262730" # Slightly lighter dark grey
|
33 |
+
textColor = "#FAFAFA" # Light text
|
34 |
font = "sans serif"
|
35 |
"""
|
36 |
)
|
|
|
80 |
#MainMenu {visibility: hidden;}
|
81 |
footer {visibility: hidden;}
|
82 |
header {visibility: hidden;}
|
83 |
+
/* Body background - Already set by theme config */
|
84 |
+
/* .stApp {
|
85 |
+
background-color: #0E1117;
|
86 |
+
} */
|
87 |
/* Tab styling */
|
88 |
.stTabs [data-baseweb="tab-list"] {
|
89 |
gap: 8px; /* Slightly reduced gap */
|
90 |
+
border-bottom: 1px solid #333333; /* Darker border */
|
91 |
}
|
92 |
.stTabs [data-baseweb="tab"] {
|
93 |
background-color: transparent; /* Make tabs transparent */
|
94 |
border-radius: 0; /* Remove border radius */
|
95 |
padding: 10px 15px;
|
96 |
+
color: #AAAAAA; /* Lighter Grey text */
|
97 |
border-bottom: 2px solid transparent; /* Prepare for selected indicator */
|
98 |
transition: all 0.3s ease;
|
99 |
}
|
100 |
.stTabs [data-baseweb="tab"]:hover {
|
101 |
+
background-color: #262730; /* Dark grey hover */
|
102 |
+
color: #FAFAFA; /* White text on hover */
|
103 |
}
|
104 |
.stTabs [aria-selected="true"] {
|
105 |
background-color: transparent !important;
|
106 |
+
color: #FAFAFA !important; /* White text for selected */
|
107 |
+
border-bottom: 2px solid #CCCCCC !important; /* Light grey underline for selected */
|
108 |
font-weight: 600; /* Make selected tab bold */
|
109 |
}
|
110 |
+
/* Sidebar styling - Mostly handled by theme config */
|
111 |
+
/* .css-1d391kg {
|
112 |
+
background-color: #262730 !important;
|
113 |
+
} */
|
114 |
+
/* Ensure sidebar text is readable - Mostly handled by theme config */
|
115 |
+
/* .css-1d391kg .stMarkdown, .css-1d391kg .stCheckbox, .css-1d391kg .stExpander, .css-1d391kg .stText, .css-1d391kg .stButton > button {
|
116 |
+
color: #FAFAFA !important;
|
117 |
+
} */
|
118 |
/* Button styling */
|
119 |
.stButton>button {
|
120 |
+
background-color: #262730 !important; /* Dark grey background */
|
121 |
+
color: #FAFAFA !important; /* Light text */
|
122 |
+
border: 1px solid #444444 !important; /* Slightly lighter border */
|
123 |
transition: all 0.3s ease !important;
|
124 |
box-shadow: none !important; /* Remove default shadow */
|
125 |
}
|
126 |
.stButton>button:hover {
|
127 |
+
background-color: #3a3c44 !important; /* Lighter grey on hover */
|
128 |
+
border-color: #666666 !important;
|
129 |
transform: none !important; /* Remove hover transform */
|
130 |
box-shadow: none !important;
|
131 |
}
|
132 |
.stButton>button:active {
|
133 |
+
background-color: #444444 !important; /* Slightly darker grey on click */
|
134 |
}
|
135 |
/* Expander header styling */
|
136 |
.stExpander > div:first-child {
|
137 |
+
background-color: #262730; /* Dark grey background for expander header */
|
138 |
border-radius: 4px;
|
139 |
}
|
140 |
.stExpander header { /* Target expander header specifically */
|
141 |
+
color: #FAFAFA !important; /* Light text for expander header */
|
142 |
font-weight: 600;
|
143 |
}
|
144 |
/* General adjustments for minimalist feel */
|
145 |
h1, h2, h3, h4, h5, h6 {
|
146 |
+
color: #FAFAFA; /* Ensure headers are light */
|
147 |
}
|
148 |
.stMarkdown p {
|
149 |
+
color: #CCCCCC; /* Slightly darker light color for paragraph text */
|
150 |
+
}
|
151 |
+
/* Color Preview Text */
|
152 |
+
.color-preview-text {
|
153 |
+
color: #1E1E1E !important; /* Ensure text is visible on light/dark previews */
|
154 |
+
text-shadow: 0 0 2px #FFFFFF; /* Add a subtle white shadow for contrast */
|
155 |
}
|
156 |
</style>
|
157 |
"""
|
|
|
286 |
st.markdown(
|
287 |
f"""
|
288 |
<div style="background-color: {preview_color_hsl}; width: 100%; height: 30px;
|
289 |
+
border: 1px solid #555555; border-radius: 5px; margin-top: 10px;">
|
290 |
+
<p class='color-preview-text' style='text-align: center; line-height: 30px; font-size: 12px; font-weight: bold;'>
|
291 |
Preview (Lower Bound)
|
292 |
</p>
|
293 |
</div>
|
|
|
377 |
"border-radius": "8px",
|
378 |
"margin": "0 auto",
|
379 |
"display": "block",
|
380 |
+
"border": "2px solid #AAAAAA", # Changed border to lighter grey
|
381 |
},
|
382 |
),
|
383 |
)
|
|
|
530 |
"""
|
531 |
)
|
532 |
|
533 |
+
st.markdown(
|
534 |
+
"""
|
535 |
+
<div style="position: fixed; bottom: 0; width: 100%; background-color: #0E1117;
|
536 |
+
padding: 8px; text-align: center; border-top: 1px solid #262730;">
|
537 |
+
<p style="margin: 0; font-size: 13px; color: #AAAAAA;">
|
538 |
+
OpenCV Explorer | Built with Streamlit | © 2024
|
539 |
+
</p>
|
540 |
+
</div>
|
541 |
+
""",
|
542 |
+
unsafe_allow_html=True,
|
543 |
+
)
|