Skip to content

Commit 812ae28

Browse files
Merge pull request #8 from OffendingCommit/feature/closed-message-everywhere
Display GAME CLOSED message when game is closed
2 parents 41c30d8 + 1b474f0 commit 812ae28

File tree

10 files changed

+308
-84
lines changed

10 files changed

+308
-84
lines changed

main.py

Lines changed: 37 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,39 @@ 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(
929+
"flex justify-center items-center h-full w-full"
930+
):
931+
ui.label("GAME CLOSED").classes("text-center fit-header").style(
932+
f"font-family: {HEADER_FONT_FAMILY}; color: {FREE_SPACE_TEXT_COLOR}; font-size: 6rem;"
933+
)
934+
935+
# Run JavaScript to ensure text is resized properly
936+
try:
937+
js_code = """
938+
setTimeout(function() {
939+
if (typeof fitty !== 'undefined') {
940+
fitty('.fit-header', { multiLine: true, minSize: 10, maxSize: 2000 });
941+
}
942+
}, 50);
943+
"""
944+
ui.run_javascript(js_code)
945+
except Exception as e:
946+
logging.debug(f"JavaScript execution failed: {e}")
947+
948+
918949
def close_game():
919950
"""
920-
Close the game - hide the board and update the header text.
951+
Close the game - show closed message instead of the board and update the header text.
921952
This function is called when the close button is clicked.
922953
"""
923954
global is_game_closed, header_label
@@ -928,9 +959,10 @@ def close_game():
928959
header_label.set_text(CLOSED_HEADER_TEXT)
929960
header_label.update()
930961

931-
# Hide all board views (both home and stream)
962+
# Show closed message in all board views
932963
for view_key, (container, tile_buttons_local) in board_views.items():
933-
container.style("display: none;")
964+
container.clear()
965+
build_closed_message(container)
934966
container.update()
935967

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

poetry.lock

Lines changed: 54 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ flake8 = "^7.0.0"
2020
black = "^24.2.0"
2121
isort = "^5.13.2"
2222
python-semantic-release = "^9.1.1"
23+
mypy = "^1.15.0"
2324

2425
[build-system]
2526
requires = ["poetry-core>=1.8"]

src/config/constants.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,53 @@
22
Configuration constants for the Bingo application.
33
"""
44

5+
from typing import Final, Literal
6+
7+
# Type definitions for CSS properties
8+
CssColor = str # Hex color code like "#123456" or named color like "red"
9+
CssFontFamily = str # Font family names like "'Font Name', sans-serif"
10+
CssFontWeight = str # Font weight like "400", "700", etc.
11+
CssFontStyle = Literal["normal", "italic", "oblique"]
12+
CssClass = str # CSS class name or space-separated class names
13+
514
# Header text and display settings
6-
HEADER_TEXT = "COMMIT !BINGO"
7-
HEADER_TEXT_COLOR = "#0CB2B3"
8-
CLOSED_HEADER_TEXT = "Bingo Is Closed"
15+
HEADER_TEXT: Final[str] = "COMMIT !BINGO"
16+
HEADER_TEXT_COLOR: Final[CssColor] = "#0CB2B3"
17+
CLOSED_HEADER_TEXT: Final[str] = "Bingo Is Closed"
18+
CLOSED_MESSAGE_TEXT: Final[str] = "GAME CLOSED"
19+
CLOSED_MESSAGE_COLOR: Final[CssColor] = "#FF7f33"
920

1021
# Free space settings
11-
FREE_SPACE_TEXT = "FREE MEAT"
12-
FREE_SPACE_TEXT_COLOR = "#FF7f33"
22+
FREE_SPACE_TEXT: Final[str] = "FREE MEAT"
23+
FREE_SPACE_TEXT_COLOR: Final[CssColor] = "#FF7f33"
1324

1425
# Tile appearance settings
15-
TILE_CLICKED_BG_COLOR = "#100079"
16-
TILE_CLICKED_TEXT_COLOR = "#1BEFF5"
17-
TILE_UNCLICKED_BG_COLOR = "#1BEFF5"
18-
TILE_UNCLICKED_TEXT_COLOR = "#100079"
26+
TILE_CLICKED_BG_COLOR: Final[CssColor] = "#100079"
27+
TILE_CLICKED_TEXT_COLOR: Final[CssColor] = "#1BEFF5"
28+
TILE_UNCLICKED_BG_COLOR: Final[CssColor] = "#1BEFF5"
29+
TILE_UNCLICKED_TEXT_COLOR: Final[CssColor] = "#100079"
1930

2031
# Page backgrounds
21-
HOME_BG_COLOR = "#100079"
22-
STREAM_BG_COLOR = "#00FF00"
32+
HOME_BG_COLOR: Final[CssColor] = "#100079"
33+
STREAM_BG_COLOR: Final[CssColor] = "#00FF00"
2334

2435
# Font settings
25-
HEADER_FONT_FAMILY = "'Super Carnival', sans-serif"
26-
BOARD_TILE_FONT = "Inter"
27-
BOARD_TILE_FONT_WEIGHT = "700"
28-
BOARD_TILE_FONT_STYLE = "normal"
36+
HEADER_FONT_FAMILY: Final[CssFontFamily] = "'Super Carnival', sans-serif"
37+
BOARD_TILE_FONT: Final[str] = "Inter"
38+
BOARD_TILE_FONT_WEIGHT: Final[CssFontWeight] = "700"
39+
BOARD_TILE_FONT_STYLE: Final[CssFontStyle] = "normal"
2940

3041
# UI Class Constants
31-
BOARD_CONTAINER_CLASS = "flex justify-center items-center w-full"
32-
HEADER_CONTAINER_CLASS = "w-full"
33-
CARD_CLASSES = (
42+
BOARD_CONTAINER_CLASS: Final[CssClass] = "flex justify-center items-center w-full"
43+
HEADER_CONTAINER_CLASS: Final[CssClass] = "w-full"
44+
CARD_CLASSES: Final[CssClass] = (
3445
"relative p-2 rounded-xl shadow-8 w-full h-full flex items-center justify-center"
3546
)
36-
COLUMN_CLASSES = "flex flex-col items-center justify-center gap-0 w-full"
37-
GRID_CONTAINER_CLASS = "w-full aspect-square p-4"
38-
GRID_CLASSES = "gap-2 h-full grid-rows-5"
39-
ROW_CLASSES = "w-full"
40-
LABEL_SMALL_CLASSES = "fit-text-small text-center select-none"
41-
LABEL_CLASSES = "fit-text text-center select-none"
47+
COLUMN_CLASSES: Final[CssClass] = (
48+
"flex flex-col items-center justify-center gap-0 w-full"
49+
)
50+
GRID_CONTAINER_CLASS: Final[CssClass] = "w-full aspect-square p-4"
51+
GRID_CLASSES: Final[CssClass] = "gap-2 h-full grid-rows-5"
52+
ROW_CLASSES: Final[CssClass] = "w-full"
53+
LABEL_SMALL_CLASSES: Final[CssClass] = "fit-text-small text-center select-none"
54+
LABEL_CLASSES: Final[CssClass] = "fit-text text-center select-none"

0 commit comments

Comments
 (0)