Spaces:
Running
Running
openhands
openhands
commited on
Commit
·
9b84cf0
1
Parent(s):
2854ddd
Fix dark mode: use legible logo and lighter link colors
Browse files- Add dark mode logo (logo-dark.png) for better visibility on dark backgrounds
- Use CSS .dark class selector to switch logos based on theme
- Make link colors lighter in dark mode (#cccccc instead of #aaaaaa)
Co-authored-by: openhands <openhands@all-hands.dev>
- app.py +22 -5
- assets/logo-dark.png +0 -0
app.py
CHANGED
|
@@ -143,10 +143,10 @@ theme = gr.themes.Base(
|
|
| 143 |
color_accent_soft='*neutral_200',
|
| 144 |
color_accent_soft_dark='*neutral_800',
|
| 145 |
link_text_color='#555555',
|
| 146 |
-
link_text_color_dark='#
|
| 147 |
-
link_text_color_active_dark='#
|
| 148 |
-
link_text_color_hover_dark='#
|
| 149 |
-
link_text_color_visited_dark='#
|
| 150 |
table_even_background_fill='*neutral_100',
|
| 151 |
table_even_background_fill_dark='*neutral_800',
|
| 152 |
button_primary_background_fill='*secondary_900',
|
|
@@ -180,6 +180,18 @@ except FileNotFoundError:
|
|
| 180 |
logger.warning(f"Home icon file not found at {LOGO_PATH}")
|
| 181 |
home_icon_data_uri = "none"
|
| 182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
# --- This is the final CSS ---
|
| 184 |
final_css = css + f"""
|
| 185 |
/* --- Find the "Home" button and replace its text with an icon --- */
|
|
@@ -198,7 +210,7 @@ final_css = css + f"""
|
|
| 198 |
font-size: 0 !important;
|
| 199 |
text-indent: -9999px;
|
| 200 |
|
| 201 |
-
/* 3. Apply the icon as the background */
|
| 202 |
background-image: url("{home_icon_data_uri}") !important;
|
| 203 |
background-size: contain !important;
|
| 204 |
background-repeat: no-repeat !important;
|
|
@@ -210,6 +222,11 @@ final_css = css + f"""
|
|
| 210 |
border: none !important;
|
| 211 |
outline: none !important;
|
| 212 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
"""
|
| 214 |
# --- Gradio App Definition ---
|
| 215 |
logger.info("Creating Gradio application")
|
|
|
|
| 143 |
color_accent_soft='*neutral_200',
|
| 144 |
color_accent_soft_dark='*neutral_800',
|
| 145 |
link_text_color='#555555',
|
| 146 |
+
link_text_color_dark='#cccccc',
|
| 147 |
+
link_text_color_active_dark='#bbbbbb',
|
| 148 |
+
link_text_color_hover_dark='#dddddd',
|
| 149 |
+
link_text_color_visited_dark='#bbbbbb',
|
| 150 |
table_even_background_fill='*neutral_100',
|
| 151 |
table_even_background_fill_dark='*neutral_800',
|
| 152 |
button_primary_background_fill='*secondary_900',
|
|
|
|
| 180 |
logger.warning(f"Home icon file not found at {LOGO_PATH}")
|
| 181 |
home_icon_data_uri = "none"
|
| 182 |
|
| 183 |
+
# Load dark mode logo (PNG)
|
| 184 |
+
LOGO_DARK_PATH = "assets/logo-dark.png"
|
| 185 |
+
try:
|
| 186 |
+
import base64
|
| 187 |
+
with open(LOGO_DARK_PATH, "rb") as f:
|
| 188 |
+
dark_logo_content = f.read()
|
| 189 |
+
encoded_dark_logo = base64.b64encode(dark_logo_content).decode('utf-8')
|
| 190 |
+
home_icon_dark_data_uri = f"data:image/png;base64,{encoded_dark_logo}"
|
| 191 |
+
except FileNotFoundError:
|
| 192 |
+
logger.warning(f"Dark mode logo file not found at {LOGO_DARK_PATH}")
|
| 193 |
+
home_icon_dark_data_uri = home_icon_data_uri # Fallback to light logo
|
| 194 |
+
|
| 195 |
# --- This is the final CSS ---
|
| 196 |
final_css = css + f"""
|
| 197 |
/* --- Find the "Home" button and replace its text with an icon --- */
|
|
|
|
| 210 |
font-size: 0 !important;
|
| 211 |
text-indent: -9999px;
|
| 212 |
|
| 213 |
+
/* 3. Apply the icon as the background (light mode) */
|
| 214 |
background-image: url("{home_icon_data_uri}") !important;
|
| 215 |
background-size: contain !important;
|
| 216 |
background-repeat: no-repeat !important;
|
|
|
|
| 222 |
border: none !important;
|
| 223 |
outline: none !important;
|
| 224 |
}}
|
| 225 |
+
|
| 226 |
+
/* Dark mode logo override */
|
| 227 |
+
.dark .nav-holder nav a[href*="/home"] {{
|
| 228 |
+
background-image: url("{home_icon_dark_data_uri}") !important;
|
| 229 |
+
}}
|
| 230 |
"""
|
| 231 |
# --- Gradio App Definition ---
|
| 232 |
logger.info("Creating Gradio application")
|
assets/logo-dark.png
ADDED
|