Surn commited on
Commit
be0de61
·
1 Parent(s): e13dc9c

Finalize changes

Browse files

restore submit button

break on purpose

v2 transition update

Adjust render transitions

Add rnder_game_tab fade in

Files changed (3) hide show
  1. app.py +14 -1
  2. battlewords/ui.py +13 -13
  3. battlewords/ui_helpers.py +5 -12
app.py CHANGED
@@ -19,7 +19,20 @@ def main(opened=False):
19
  )
20
 
21
  st.markdown(
22
- "<style>div[data-testid='stSidebar'] { display: none !important; }</style>",
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  unsafe_allow_html=True,
24
  )
25
  run_app()
 
19
  )
20
 
21
  st.markdown(
22
+ """<style>
23
+ div[data-testid='stSidebar'] { display: none !important; }
24
+ /* #root {transition: opacity 1s ease, visibility 1s ease;} */
25
+ .bw-fadein-prep {visibility: hidden !important; opacity: 0.75; transition: opacity 1s ease, visibility 1s ease !important}
26
+ .bw-fadein-prep #bw-spinner-overlay {
27
+ visibility: visible !important;
28
+ opacity: 1 !important;
29
+ }
30
+ /* #REMOVE ALERT */
31
+ .st-emotion-cache-15g2oxy.emjbblw2 {
32
+ opacity: 0;
33
+ display: none;
34
+ }
35
+ </style>""",
36
  unsafe_allow_html=True,
37
  )
38
  run_app()
battlewords/ui.py CHANGED
@@ -464,7 +464,7 @@ def _render_grid(show_grid_ticks: bool = True):
464
  to { opacity: 1; transform: scale(1); }
465
  }
466
  .bw-cell.letter, .bw-cell.empty, .bw-cell.bw-cell-complete {
467
- animation: bw-reveal 0.20s ease-out;
468
  }
469
  </style>
470
  """,
@@ -701,18 +701,18 @@ def _render_guess_form(state: GameState):
701
  <style>
702
  .st-key-guess_input .stTextInput label .st-emotion-cache-lyi571, .st-key-guess_input .stTextInput label .st-emotion-cache-on6lu2 {
703
  font-size: 1.2em;
704
- transition: opacity 1.5s ease-in, visibility 1.5s ease-in, display 1.5s allow-discrete;
705
- transition-behavior: allow-discrete;
706
  }
707
  .st-emotion-cache-on6lu2, .st-emotion-cache-6c7yup , .st-emotion-cache-1pcf7lv {
708
  visibility: inherit !important;
709
- transition: opacity 1.5s ease-in, visibility 1.5s ease-in, display 1.5s allow-discrete;
710
- transition-behavior: allow-discrete;
711
  }
712
- .stColumn.st-emotion-cache-bw9c3d, .stColumn.st-emotion-cache-drrz8i, .stColumn.st-emotion-cache-bah2wz {
713
  margin-top: 0px;
714
  }
715
- .stColumn.st-emotion-cache-1lo9blm, .stColumn.st-emotion-cache-1w9nhvb{
716
  margin-top: 31px;
717
  }
718
  .st-key-guess_input .stTextInput input {
@@ -852,7 +852,7 @@ def _render_guess_form(state: GameState):
852
  with col2:
853
  submitted = st.form_submit_button("OK", disabled=not state.can_guess, width=100, key="guess_submit")
854
  with col3:
855
- _render_correct_try_again(state)
856
 
857
  if submitted:
858
  # Only process guesses with at least 4 characters (prevent blank/short submissions)
@@ -1175,7 +1175,7 @@ def _render_game_over(state: GameState):
1175
  _game_over_dialog(state)
1176
 
1177
  def run_app():
1178
- start_root_fade_in(0.0)
1179
 
1180
  # Handle query params using new API
1181
  try:
@@ -1202,7 +1202,7 @@ def run_app():
1202
 
1203
  if st.session_state.get("needs_initialization", True):
1204
  spinner_placeholder = st.empty()
1205
- with CustomSpinner(spinner_placeholder, "Initializing Game..."):
1206
  st.session_state.needs_initialization = False
1207
  _render_game_tab()
1208
  try:
@@ -1227,14 +1227,14 @@ def run_app():
1227
  time.sleep(1.0) # slight delay to ensure radar and grid render before overlay appears
1228
  _render_game_over(state)
1229
 
1230
- finish_root_fade_in(2.0)
1231
 
1232
 
1233
  def _render_game_tab():
1234
  """
1235
  Render the main game tab layout.
1236
  """
1237
- # start_root_fade_in(0.5)
1238
  _init_session()
1239
  st.markdown(ocean_background_css, unsafe_allow_html=True)
1240
  #inject_ocean_layers() # <-- add the animated layers
@@ -1272,4 +1272,4 @@ def _render_game_tab():
1272
  show_grid_ticks=st.session_state.get("show_grid_ticks", True),
1273
  )
1274
 
1275
- # finish_root_fade_in(0.3)
 
464
  to { opacity: 1; transform: scale(1); }
465
  }
466
  .bw-cell.letter, .bw-cell.empty, .bw-cell.bw-cell-complete {
467
+ animation: bw-reveal 0.15s ease-out;
468
  }
469
  </style>
470
  """,
 
701
  <style>
702
  .st-key-guess_input .stTextInput label .st-emotion-cache-lyi571, .st-key-guess_input .stTextInput label .st-emotion-cache-on6lu2 {
703
  font-size: 1.2em;
704
+ /* transition: opacity 1.5s ease-in, visibility 1.5s ease-in, display 1.5s allow-discrete;
705
+ transition-behavior: allow-discrete; */
706
  }
707
  .st-emotion-cache-on6lu2, .st-emotion-cache-6c7yup , .st-emotion-cache-1pcf7lv {
708
  visibility: inherit !important;
709
+ /* transition: opacity 1.5s ease-in, visibility 1.5s ease-in, display 1.5s allow-discrete;
710
+ transition-behavior: allow-discrete; */
711
  }
712
+ .stColumn.st-emotion-cache-bw9c3d, .stColumn.st-emotion-cache-drrz8i, .stColumn.st-emotion-cache-bah2wz, .st-emotion-cache-tuze3w {
713
  margin-top: 0px;
714
  }
715
+ .stColumn.st-emotion-cache-1lo9blm, .stColumn.st-emotion-cache-1w9nhvb, .st-emotion-cache-nwgyir {
716
  margin-top: 31px;
717
  }
718
  .st-key-guess_input .stTextInput input {
 
852
  with col2:
853
  submitted = st.form_submit_button("OK", disabled=not state.can_guess, width=100, key="guess_submit")
854
  with col3:
855
+ _render_correct_try_again(state)
856
 
857
  if submitted:
858
  # Only process guesses with at least 4 characters (prevent blank/short submissions)
 
1175
  _game_over_dialog(state)
1176
 
1177
  def run_app():
1178
+ start_root_fade_in(0.1)
1179
 
1180
  # Handle query params using new API
1181
  try:
 
1202
 
1203
  if st.session_state.get("needs_initialization", True):
1204
  spinner_placeholder = st.empty()
1205
+ with CustomSpinner(spinner_placeholder, "Initializing Game...", 2.0):
1206
  st.session_state.needs_initialization = False
1207
  _render_game_tab()
1208
  try:
 
1227
  time.sleep(1.0) # slight delay to ensure radar and grid render before overlay appears
1228
  _render_game_over(state)
1229
 
1230
+ finish_root_fade_in(2.1)
1231
 
1232
 
1233
  def _render_game_tab():
1234
  """
1235
  Render the main game tab layout.
1236
  """
1237
+ #start_root_fade_in(0.35)
1238
  _init_session()
1239
  st.markdown(ocean_background_css, unsafe_allow_html=True)
1240
  #inject_ocean_layers() # <-- add the animated layers
 
1272
  show_grid_ticks=st.session_state.get("show_grid_ticks", True),
1273
  )
1274
 
1275
+ #finish_root_fade_in(5.0)
battlewords/ui_helpers.py CHANGED
@@ -192,7 +192,7 @@ def start_root_fade_in(duration_s: float = 0.35) -> None:
192
  if (!root) return;
193
  root.classList.add('bw-fadein-prep');
194
  // Hide immediately with no transition so a later step can fade in.
195
- root.style.setProperty('transition', 'none', 'important');
196
  root.style.setProperty('visibility', 'hidden', 'important');
197
  // Force style/layout flush so opacity=0 commits before re-enabling transition.
198
  void root.offsetHeight;
@@ -214,10 +214,10 @@ def finish_root_fade_in(duration_s: float = 0.35) -> None:
214
  try {{
215
  var parentDoc = (window.parent && window.parent.document) ? window.parent.document : document;
216
  var root = parentDoc.getElementById('root');
217
- if (!root) return;
218
- root.style.opacity = '0';
 
219
  root.style.visibility = 'visible';
220
- root.style.transition = 'opacity {duration_s:.3f}s ease-in, visibility {duration_s:.3f}s ease-in !important';
221
  root.style.opacity = '1';
222
  root.classList.remove('bw-fadein-prep');
223
  }} catch (e) {{ /* no-op */ }}
@@ -338,12 +338,6 @@ def inject_styles() -> None:
338
  .stVerticalBlock.st-emotion-cache-tn0cau.e1wguzas3 div.element-container:nth-child(3), .stVerticalBlock.st-emotion-cache-tn0cau.ek2vi383 div.element-container:nth-child(3) { display: none; }
339
  .st-emotion-cache-18kf3ut.e1wguzas41 { display: none; }
340
 
341
- .bw-fadein-prep {visibility: hidden !important;}
342
- .bw-fadein-prep #bw-spinner-overlay {
343
- visibility: visible !important;
344
- opacity: 1 !important;
345
- }
346
-
347
  div[data-testid="column"], .st-emotion-cache-zh2fnc, .st-emotion-cache-1tj828o, .st-emotion-cache-1anq8dj { width: auto !important; flex: 1 1 auto !important; min-width: 100% !important; max-width: 100% !important; border-radius:0; background-color: rgb(30, 105, 210); border: 1px solid rgb(30, 105, 210); border-bottom: 1.3px solid rgb(30, 105, 210);}
348
  .st-emotion-cache-1permvm, .st-emotion-cache-1n6tfoc { gap:0.15rem !important; min-height: 2.5rem; min-width: 2.5rem;}
349
  .stColumn.st-emotion-cache-1ruy632, .stColumn.st-emotion-cache-t2z0eb {margin-top:0;}
@@ -352,7 +346,6 @@ def inject_styles() -> None:
352
  .bw-grid-row-anchor + div[data-testid="stHorizontalBlock"] > div[data-testid="column"] { flex: 0 0 auto !important; }
353
  .bw-grid-row-anchor { height: 0; margin: 0; padding: 0; }
354
  .st-emotion-cache-1n6tfoc { background: linear-gradient(-45deg, #a1a1a1, #ffffff, #a1a1a1, #666666); gap: 0.1rem !important; color: white; border-radius:15px; padding: 10px 10px 10px 5px; }
355
- .st-emotion-cache-1n6tfoc::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 10px; margin: 5px;}
356
  .st-emotion-cache-t9ul8o .st-emotion-cache-1n6tfoc, .st-emotion-cache-1pgyx24 .st-emotion-cache-1n6tfoc {background: none; padding: 0; z-index:-1;}
357
  .st-key-guess_input, .st-key-guess_submit { flex-direction: row; display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: flex-end; }
358
 
@@ -396,7 +389,7 @@ def inject_styles() -> None:
396
  .shiny-border:hover::before { left: 100%; }
397
 
398
  .st-emotion-cache-1n1mx2j p {font-size: 1rem;}
399
- .bw-radio-group { display:flex; align-items:flex-start; gap: 5px; flex-flow: row; min-height: 92px; transition: opacity 0.3s ease-in, visibility 0.3s ease-in, display 0.3s allow-discrete; transition-behavior: allow-discrete; visibility: inherit;}
400
  .bw-radio-item { display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center;}
401
  .bw-radio-circle { width: 45px; height: 45px; border-radius: 50%; border: 4px solid; background: rgba(255,255,255,0.06); display: grid; place-items: center; color:#fff; font-weight:700; }
402
  .bw-radio-circle .dot { width: 14px; height: 14px; border-radius: 50%; background:#777; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25); }
 
192
  if (!root) return;
193
  root.classList.add('bw-fadein-prep');
194
  // Hide immediately with no transition so a later step can fade in.
195
+ //root.style.setProperty('transition', 'none', 'important');
196
  root.style.setProperty('visibility', 'hidden', 'important');
197
  // Force style/layout flush so opacity=0 commits before re-enabling transition.
198
  void root.offsetHeight;
 
214
  try {{
215
  var parentDoc = (window.parent && window.parent.document) ? window.parent.document : document;
216
  var root = parentDoc.getElementById('root');
217
+ if (!root) return;
218
+ root.style.opacity = '0';
219
+ root.style.setProperty('transition', 'opacity {duration_s:.3f}s ease-in-out, visibility {duration_s:.3f}s ease-in-out', 'important');
220
  root.style.visibility = 'visible';
 
221
  root.style.opacity = '1';
222
  root.classList.remove('bw-fadein-prep');
223
  }} catch (e) {{ /* no-op */ }}
 
338
  .stVerticalBlock.st-emotion-cache-tn0cau.e1wguzas3 div.element-container:nth-child(3), .stVerticalBlock.st-emotion-cache-tn0cau.ek2vi383 div.element-container:nth-child(3) { display: none; }
339
  .st-emotion-cache-18kf3ut.e1wguzas41 { display: none; }
340
 
 
 
 
 
 
 
341
  div[data-testid="column"], .st-emotion-cache-zh2fnc, .st-emotion-cache-1tj828o, .st-emotion-cache-1anq8dj { width: auto !important; flex: 1 1 auto !important; min-width: 100% !important; max-width: 100% !important; border-radius:0; background-color: rgb(30, 105, 210); border: 1px solid rgb(30, 105, 210); border-bottom: 1.3px solid rgb(30, 105, 210);}
342
  .st-emotion-cache-1permvm, .st-emotion-cache-1n6tfoc { gap:0.15rem !important; min-height: 2.5rem; min-width: 2.5rem;}
343
  .stColumn.st-emotion-cache-1ruy632, .stColumn.st-emotion-cache-t2z0eb {margin-top:0;}
 
346
  .bw-grid-row-anchor + div[data-testid="stHorizontalBlock"] > div[data-testid="column"] { flex: 0 0 auto !important; }
347
  .bw-grid-row-anchor { height: 0; margin: 0; padding: 0; }
348
  .st-emotion-cache-1n6tfoc { background: linear-gradient(-45deg, #a1a1a1, #ffffff, #a1a1a1, #666666); gap: 0.1rem !important; color: white; border-radius:15px; padding: 10px 10px 10px 5px; }
 
349
  .st-emotion-cache-t9ul8o .st-emotion-cache-1n6tfoc, .st-emotion-cache-1pgyx24 .st-emotion-cache-1n6tfoc {background: none; padding: 0; z-index:-1;}
350
  .st-key-guess_input, .st-key-guess_submit { flex-direction: row; display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: flex-end; }
351
 
 
389
  .shiny-border:hover::before { left: 100%; }
390
 
391
  .st-emotion-cache-1n1mx2j p {font-size: 1rem;}
392
+ .bw-radio-group { display:flex; align-items:flex-start; gap: 5px; flex-flow: row; min-height: 92px; /*transition: opacity 0.3s ease-in, visibility 0.3s ease-in, display 0.3s allow-discrete; transition-behavior: allow-discrete;*/ visibility: inherit;}
393
  .bw-radio-item { display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center;}
394
  .bw-radio-circle { width: 45px; height: 45px; border-radius: 50%; border: 4px solid; background: rgba(255,255,255,0.06); display: grid; place-items: center; color:#fff; font-weight:700; }
395
  .bw-radio-circle .dot { width: 14px; height: 14px; border-radius: 50%; background:#777; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25); }