Commit
Β·
36b8ff4
1
Parent(s):
9b8af35
fix(ui): CSS autofill override and text centering
Browse files- Add -webkit-autofill selectors to prevent white background on focus
- Add :focus-visible for better accessibility
- Split description into two centered divs with styled HR
- HR element was breaking text-align inheritance
Fixes issue where API key input turned white when browser autofilled
and text after HR was left-aligned instead of centered.
- src/app.py +20 -4
src/app.py
CHANGED
|
@@ -26,16 +26,28 @@ OrchestratorMode = Literal["simple", "magentic", "advanced", "hierarchical"]
|
|
| 26 |
|
| 27 |
|
| 28 |
# CSS to force dark mode on API key input
|
|
|
|
| 29 |
CUSTOM_CSS = """
|
| 30 |
.api-key-input input {
|
| 31 |
background-color: #1f2937 !important;
|
| 32 |
color: white !important;
|
| 33 |
border-color: #374151 !important;
|
| 34 |
}
|
| 35 |
-
.api-key-input input:focus
|
|
|
|
| 36 |
background-color: #1f2937 !important;
|
| 37 |
color: white !important;
|
| 38 |
border-color: #e879f9 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
"""
|
| 41 |
|
|
@@ -262,13 +274,17 @@ def create_demo() -> tuple[gr.ChatInterface, gr.Accordion]:
|
|
| 262 |
api_key_state = gr.State("")
|
| 263 |
|
| 264 |
# 1. Unwrapped ChatInterface (Fixes Accordion Bug)
|
|
|
|
| 265 |
description = (
|
| 266 |
-
"<div style='text-align: center'>"
|
| 267 |
"<em>AI-Powered Research Agent β searches PubMed, "
|
| 268 |
"ClinicalTrials.gov, Europe PMC & OpenAlex</em><br><br>"
|
| 269 |
"Deep research for sexual wellness, ED treatments, hormone therapy, "
|
| 270 |
-
"libido, and reproductive health - for all genders
|
| 271 |
-
"
|
|
|
|
|
|
|
|
|
|
| 272 |
"<em>Research tool only β not for medical advice.</em><br>"
|
| 273 |
"<strong>MCP Server Active</strong>: Connect Claude Desktop to "
|
| 274 |
"<code>/gradio_api/mcp/</code>"
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
# CSS to force dark mode on API key input
|
| 29 |
+
# NOTE: Browser autofill requires -webkit-autofill selectors to override
|
| 30 |
CUSTOM_CSS = """
|
| 31 |
.api-key-input input {
|
| 32 |
background-color: #1f2937 !important;
|
| 33 |
color: white !important;
|
| 34 |
border-color: #374151 !important;
|
| 35 |
}
|
| 36 |
+
.api-key-input input:focus,
|
| 37 |
+
.api-key-input input:focus-visible {
|
| 38 |
background-color: #1f2937 !important;
|
| 39 |
color: white !important;
|
| 40 |
border-color: #e879f9 !important;
|
| 41 |
+
outline: none !important;
|
| 42 |
+
}
|
| 43 |
+
/* Override aggressive browser autofill styling */
|
| 44 |
+
.api-key-input input:-webkit-autofill,
|
| 45 |
+
.api-key-input input:-webkit-autofill:hover,
|
| 46 |
+
.api-key-input input:-webkit-autofill:focus {
|
| 47 |
+
-webkit-box-shadow: 0 0 0px 1000px #1f2937 inset !important;
|
| 48 |
+
-webkit-text-fill-color: white !important;
|
| 49 |
+
caret-color: white !important;
|
| 50 |
+
transition: background-color 5000s ease-in-out 0s;
|
| 51 |
}
|
| 52 |
"""
|
| 53 |
|
|
|
|
| 274 |
api_key_state = gr.State("")
|
| 275 |
|
| 276 |
# 1. Unwrapped ChatInterface (Fixes Accordion Bug)
|
| 277 |
+
# NOTE: Using inline styles on each element because HR breaks text-align inheritance
|
| 278 |
description = (
|
| 279 |
+
"<div style='text-align: center;'>"
|
| 280 |
"<em>AI-Powered Research Agent β searches PubMed, "
|
| 281 |
"ClinicalTrials.gov, Europe PMC & OpenAlex</em><br><br>"
|
| 282 |
"Deep research for sexual wellness, ED treatments, hormone therapy, "
|
| 283 |
+
"libido, and reproductive health - for all genders."
|
| 284 |
+
"</div>"
|
| 285 |
+
"<hr style='margin: 1em auto; width: 80%; border: none; "
|
| 286 |
+
"border-top: 1px solid #374151;'>"
|
| 287 |
+
"<div style='text-align: center;'>"
|
| 288 |
"<em>Research tool only β not for medical advice.</em><br>"
|
| 289 |
"<strong>MCP Server Active</strong>: Connect Claude Desktop to "
|
| 290 |
"<code>/gradio_api/mcp/</code>"
|