Spaces:
Running
Running
Working on final screen close bug
Browse files- battlewords/ui.py +7 -7
battlewords/ui.py
CHANGED
|
@@ -892,7 +892,7 @@ def _render_correct_try_again(state: GameState):
|
|
| 892 |
|
| 893 |
|
| 894 |
def _render_guess_form(state: GameState):
|
| 895 |
-
with st.form("guess_form",width=300,clear_on_submit=
|
| 896 |
col1, col2 = st.columns([2, 1], vertical_alignment="bottom")
|
| 897 |
with col1:
|
| 898 |
guess_text = st.text_input("Your Guess", value="", max_chars=10, width=200, key="guess_input")
|
|
@@ -934,9 +934,9 @@ def _render_score_panel(state: GameState):
|
|
| 934 |
extra_pts = max(0, pts - letters_display)
|
| 935 |
row_html = (
|
| 936 |
"<tr>"
|
| 937 |
-
f"<td class=\"blue-background \"'>{
|
| 938 |
-
f"<td class=\"blue-background \"'>{
|
| 939 |
-
f"<td class=\"blue-background \"'>{
|
| 940 |
"</tr>"
|
| 941 |
)
|
| 942 |
rows_html.append(row_html)
|
|
@@ -971,15 +971,15 @@ def _render_game_over(state: GameState):
|
|
| 971 |
f"<tr class='blue-background'><td colspan='3'><h3 class='bold-text'>Total: {state.score}</h3></td></tr>"
|
| 972 |
"</table>"
|
| 973 |
)
|
| 974 |
-
# Overlay HTML with close link (
|
| 975 |
st.markdown(
|
| 976 |
f'''
|
| 977 |
<div id="bw-modal-overlay" style="position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999;background:rgba(20,80,180,0.95);display:flex;flex-direction:column;justify-content:center;align-items:center;">
|
| 978 |
<div class="shiny-border" style="position:relative;background: linear-gradient(-45deg, #1d64c8, #ffffff, #1d64c8, #666666);padding:2rem 3rem;box-shadow:0 0 32px #1d64c8;min-width:340px;max-width:90vw; margin:8vh auto 5vh;">
|
| 979 |
-
<a href="?overlay=0" title="Close" style="position:absolute;top:12px;right:12px;display:inline-grid;place-items:center;width:40px;height:40px;border-radius:50%;background:rgba(0,0,0,0.25);color:#fff;text-decoration:none;font-size:1.6rem;font-weight:700;">×</a>
|
| 980 |
<h1 style="color:#fff;font-size:2.5rem;margin-bottom:0.5rem;">Congratulations!</h1>
|
| 981 |
<h2 style="color:#fff;font-size:2rem;margin-bottom:1rem;">Game Over</h2>
|
| 982 |
-
<div style="font-size:1.5rem;color:#
|
| 983 |
<div style="font-size:1.2rem;color:#fff;margin-bottom:2rem;">Tier: <strong>{compute_tier(state.score)}</strong></div>
|
| 984 |
<div style="margin-bottom:2rem;">{table_html}</div>
|
| 985 |
<div style="color:#fff;opacity:0.7;font-size:1rem;margin-bottom:2rem;background:#1d64c8;text-align:center;">Thank you for playing BattleWords!</div>
|
|
|
|
| 892 |
|
| 893 |
|
| 894 |
def _render_guess_form(state: GameState):
|
| 895 |
+
with st.form("guess_form",width=300,clear_on_submit=True):
|
| 896 |
col1, col2 = st.columns([2, 1], vertical_alignment="bottom")
|
| 897 |
with col1:
|
| 898 |
guess_text = st.text_input("Your Guess", value="", max_chars=10, width=200, key="guess_input")
|
|
|
|
| 934 |
extra_pts = max(0, pts - letters_display)
|
| 935 |
row_html = (
|
| 936 |
"<tr>"
|
| 937 |
+
f"<td class=\"blue-background \"'>{word_display}</td>"
|
| 938 |
+
f"<td class=\"blue-background \"'>{letters_display}</td>"
|
| 939 |
+
f"<td class=\"blue-background \"'>{extra_pts}</td>"
|
| 940 |
"</tr>"
|
| 941 |
)
|
| 942 |
rows_html.append(row_html)
|
|
|
|
| 971 |
f"<tr class='blue-background'><td colspan='3'><h3 class='bold-text'>Total: {state.score}</h3></td></tr>"
|
| 972 |
"</table>"
|
| 973 |
)
|
| 974 |
+
# Overlay HTML with close link (forces navigation in same tab)
|
| 975 |
st.markdown(
|
| 976 |
f'''
|
| 977 |
<div id="bw-modal-overlay" style="position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999;background:rgba(20,80,180,0.95);display:flex;flex-direction:column;justify-content:center;align-items:center;">
|
| 978 |
<div class="shiny-border" style="position:relative;background: linear-gradient(-45deg, #1d64c8, #ffffff, #1d64c8, #666666);padding:2rem 3rem;box-shadow:0 0 32px #1d64c8;min-width:340px;max-width:90vw; margin:8vh auto 5vh;">
|
| 979 |
+
<a href="?overlay=0" target="_self" title="Close" style="position:absolute;top:12px;right:12px;display:inline-grid;place-items:center;width:40px;height:40px;border-radius:50%;background:rgba(0,0,0,0.25);color:#fff;text-decoration:none;font-size:1.6rem;font-weight:700;">×</a>
|
| 980 |
<h1 style="color:#fff;font-size:2.5rem;margin-bottom:0.5rem;">Congratulations!</h1>
|
| 981 |
<h2 style="color:#fff;font-size:2rem;margin-bottom:1rem;">Game Over</h2>
|
| 982 |
+
<div style="font-size:1.5rem;color:#fff;margin-bottom:1rem;">Final score: <span style="color:#1ca41c;font-weight:800;">{state.score}</span></div>
|
| 983 |
<div style="font-size:1.2rem;color:#fff;margin-bottom:2rem;">Tier: <strong>{compute_tier(state.score)}</strong></div>
|
| 984 |
<div style="margin-bottom:2rem;">{table_html}</div>
|
| 985 |
<div style="color:#fff;opacity:0.7;font-size:1rem;margin-bottom:2rem;background:#1d64c8;text-align:center;">Thank you for playing BattleWords!</div>
|