Spaces:
Sleeping
Sleeping
Remove welcome/registration modal screen
Browse files
app.py
CHANGED
|
@@ -217,15 +217,6 @@ def submit_viva_answer_logic(ans, qs, idx, name):
|
|
| 217 |
CSS = """
|
| 218 |
/* HIDE DEFAULT TABS HEADER to use Custom Nav */
|
| 219 |
.tabs > .tab-nav { display: none !important; }
|
| 220 |
-
|
| 221 |
-
#registration_modal {
|
| 222 |
-
position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 223 |
-
z-index: 1000; background: white; padding: 2rem; border-radius: 20px;
|
| 224 |
-
box-shadow: 0 10px 40px rgba(0,0,0,0.3); border: 2px solid #ff6b35; width: 80%; max-width: 600px;
|
| 225 |
-
}
|
| 226 |
-
body:has(#registration_modal:not([style*="display: none"]))::after {
|
| 227 |
-
content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999;
|
| 228 |
-
}
|
| 229 |
#nav_bar { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 5px; }
|
| 230 |
#nav_bar button { flex: 1; white-space: nowrap; }
|
| 231 |
"""
|
|
@@ -240,18 +231,9 @@ with gr.Blocks(title="AnatomyBot") as demo:
|
|
| 240 |
cur_img = gr.State(None)
|
| 241 |
cur_book_topic = gr.State("")
|
| 242 |
|
| 243 |
-
# Modal
|
| 244 |
-
with gr.Column(elem_id="registration_modal") as modal:
|
| 245 |
-
gr.Markdown("# 👨⚕️ Welcome, Doctor!")
|
| 246 |
-
m_name = gr.Textbox(label="Name")
|
| 247 |
-
m_school = gr.Textbox(label="Medical School")
|
| 248 |
-
m_year = gr.Dropdown(["Year 1", "Year 2", "Year 3", "Final Year", "Intern"], label="Year")
|
| 249 |
-
m_btn = gr.Button("Start Learning", variant="primary")
|
| 250 |
-
|
| 251 |
# Main App
|
| 252 |
with gr.Column():
|
| 253 |
gr.Markdown("# 🩺 AnatomyBot - MBBS Tutor")
|
| 254 |
-
welcome_msg = gr.Markdown("")
|
| 255 |
|
| 256 |
# Custom Nav
|
| 257 |
with gr.Row(elem_id="nav_bar"):
|
|
@@ -338,42 +320,6 @@ with gr.Blocks(title="AnatomyBot") as demo:
|
|
| 338 |
tbl = gr.Dataframe()
|
| 339 |
|
| 340 |
# --- EVENT HANDLERS ---
|
| 341 |
-
|
| 342 |
-
# 1. Modal Close - with validation
|
| 343 |
-
def handle_modal_submit(name, school, year):
|
| 344 |
-
"""Handle modal submission with validation."""
|
| 345 |
-
# Validate inputs
|
| 346 |
-
if not name or not name.strip():
|
| 347 |
-
return gr.update(), "", "", None # Don't close modal if name is empty
|
| 348 |
-
if not school or not school.strip():
|
| 349 |
-
return gr.update(), "", "", None # Don't close modal if school is empty
|
| 350 |
-
if not year:
|
| 351 |
-
return gr.update(), "", "", None # Don't close modal if year not selected
|
| 352 |
-
|
| 353 |
-
# Save to database
|
| 354 |
-
save_result = save_student(name.strip(), school.strip(), year)
|
| 355 |
-
|
| 356 |
-
# Return updates
|
| 357 |
-
return (
|
| 358 |
-
gr.update(visible=False), # Close modal
|
| 359 |
-
f"**Doctor {name}** | {school}", # Welcome message
|
| 360 |
-
name, # Store name in state
|
| 361 |
-
save_result # Database save result (True/False)
|
| 362 |
-
)
|
| 363 |
-
|
| 364 |
-
m_btn.click(
|
| 365 |
-
fn=handle_modal_submit,
|
| 366 |
-
inputs=[m_name, m_school, m_year],
|
| 367 |
-
outputs=[modal, welcome_msg, student_name, gr.State()], # dummy output for save
|
| 368 |
-
js="""
|
| 369 |
-
(name, school, year) => {
|
| 370 |
-
if (name && name.trim() && school && school.trim() && year) {
|
| 371 |
-
const modal = document.getElementById('registration_modal');
|
| 372 |
-
if (modal) modal.style.display = 'none';
|
| 373 |
-
}
|
| 374 |
-
}
|
| 375 |
-
"""
|
| 376 |
-
)
|
| 377 |
|
| 378 |
# 2. Navigation (Updates the Tabs 'selected' state)
|
| 379 |
btn_learn.click(lambda: gr.Tabs(selected="tab_learn"), outputs=tabs)
|
|
|
|
| 217 |
CSS = """
|
| 218 |
/* HIDE DEFAULT TABS HEADER to use Custom Nav */
|
| 219 |
.tabs > .tab-nav { display: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
#nav_bar { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 5px; }
|
| 221 |
#nav_bar button { flex: 1; white-space: nowrap; }
|
| 222 |
"""
|
|
|
|
| 231 |
cur_img = gr.State(None)
|
| 232 |
cur_book_topic = gr.State("")
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
# Main App
|
| 235 |
with gr.Column():
|
| 236 |
gr.Markdown("# 🩺 AnatomyBot - MBBS Tutor")
|
|
|
|
| 237 |
|
| 238 |
# Custom Nav
|
| 239 |
with gr.Row(elem_id="nav_bar"):
|
|
|
|
| 320 |
tbl = gr.Dataframe()
|
| 321 |
|
| 322 |
# --- EVENT HANDLERS ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
# 2. Navigation (Updates the Tabs 'selected' state)
|
| 325 |
btn_learn.click(lambda: gr.Tabs(selected="tab_learn"), outputs=tabs)
|