Skip to content

Commit

Permalink
upgrade syntax to 0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
adhami3310 committed Oct 21, 2024
1 parent 82fdc12 commit 4682cfc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions reflexle/reflexle/reflexle.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class Reflexle(rx.State):

_word: ReflexleGame = ReflexleGame()

current_guess: str = ""
current_guess: rx.Field[str] = rx.field("")

high_contrast: bool = False
high_contrast: rx.Field[bool] = rx.field(False)

@rx.var
def guesses(self) -> list[list[tuple[str, Correctness]]]:
Expand All @@ -143,6 +143,7 @@ def guesses(self) -> list[list[tuple[str, Correctness]]]:
* (6 - len(already_guessed) - 1)
)

@rx.event
def received_letter(self, letter: str):
"""Receive a letter."""
if self.game_status != GameStatus.ONGOING:
Expand All @@ -169,6 +170,7 @@ def game_status(self) -> GameStatus:
"""Get the game status."""
return self._word.game_status()

@rx.event
def reset_game(self):
"""Reset the game."""
self._word = ReflexleGame()
Expand Down Expand Up @@ -216,6 +218,11 @@ def letters(self) -> list[list[tuple[str, Correctness]]]:
for row in query
]

@rx.event
def toggle_high_contrast(self):
"""Toggle high contrast."""
self.high_contrast = not self.high_contrast


def icon_button(icon, **kwargs):
"""Icon button."""
Expand Down Expand Up @@ -384,7 +391,7 @@ def index():
play_again(),
icon_button(
rx.icon("contrast"),
on_click=Reflexle.set_high_contrast(~Reflexle.high_contrast),
on_click=Reflexle.toggle_high_contrast,
),
icon_button(
rx.color_mode_cond(
Expand Down
2 changes: 1 addition & 1 deletion reflexle/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
reflex==0.6.2.post1
reflex==0.6.3

0 comments on commit 4682cfc

Please sign in to comment.