Skip to content

Commit 2911416

Browse files
feat(ui): show closed message on all routes
Instead of hiding the board when the game is closed, display a large 'GAME CLOSED' message in the same space as the board. This provides better visibility and a consistent user experience across all views including the main.py implementation. - Add build_closed_message function to both modules - Update sync_board_state to display message in both modules - Display message using the header font and free space color
1 parent 76abafc commit 2911416

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

main.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,10 @@ def sync_board_state():
418418
header_label.set_text(CLOSED_HEADER_TEXT)
419419
header_label.update()
420420

421-
# Hide all board views
421+
# Show closed message in all board views
422422
for view_key, (container, _) in board_views.items():
423-
container.style("display: none;")
423+
container.clear()
424+
build_closed_message(container)
424425
container.update()
425426

426427
# Make sure controls row is showing only the Start New Game button
@@ -915,9 +916,37 @@ def generate_new_board():
915916
reset_board()
916917

917918

919+
def build_closed_message(parent):
920+
"""
921+
Build a message indicating the game is closed, to be displayed in place of the board.
922+
923+
Args:
924+
parent: The parent UI element to build the message in
925+
"""
926+
with parent:
927+
with ui.element("div").classes(GRID_CONTAINER_CLASS):
928+
with ui.element("div").classes("flex justify-center items-center h-full w-full"):
929+
ui.label("GAME CLOSED").classes("text-center fit-header").style(
930+
f"font-family: {HEADER_FONT_FAMILY}; color: {FREE_SPACE_TEXT_COLOR}; font-size: 6rem;"
931+
)
932+
933+
# Run JavaScript to ensure text is resized properly
934+
try:
935+
js_code = """
936+
setTimeout(function() {
937+
if (typeof fitty !== 'undefined') {
938+
fitty('.fit-header', { multiLine: true, minSize: 10, maxSize: 2000 });
939+
}
940+
}, 50);
941+
"""
942+
ui.run_javascript(js_code)
943+
except Exception as e:
944+
logging.debug(f"JavaScript execution failed: {e}")
945+
946+
918947
def close_game():
919948
"""
920-
Close the game - hide the board and update the header text.
949+
Close the game - show closed message instead of the board and update the header text.
921950
This function is called when the close button is clicked.
922951
"""
923952
global is_game_closed, header_label
@@ -928,9 +957,10 @@ def close_game():
928957
header_label.set_text(CLOSED_HEADER_TEXT)
929958
header_label.update()
930959

931-
# Hide all board views (both home and stream)
960+
# Show closed message in all board views
932961
for view_key, (container, tile_buttons_local) in board_views.items():
933-
container.style("display: none;")
962+
container.clear()
963+
build_closed_message(container)
934964
container.update()
935965

936966
# Modify the controls row to only show the New Board button

0 commit comments

Comments
 (0)