mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Rename "on" things to "filled" things
Because Textual uses on_ for event handlers there was the danger of a name clash; so to keep things as clear as possible this renames anything to do with "on" (method names, properties, style classes) so that it talks about "filled" instead. See https://github.com/Textualize/textual/pull/963#discussion_r1000544563
This commit is contained in:
@@ -47,12 +47,12 @@ GameCell:hover {
|
|||||||
border: round $panel;
|
border: round $panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameCell.on {
|
GameCell.filled {
|
||||||
background: $secondary;
|
background: $secondary;
|
||||||
border: round $secondary-darken-1;
|
border: round $secondary-darken-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameCell.on:hover {
|
GameCell.filled:hover {
|
||||||
background: $secondary-lighten-1;
|
background: $secondary-lighten-1;
|
||||||
border: round $secondary;
|
border: round $secondary;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,20 +136,20 @@ class Game(Screen):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_cells(self) -> DOMQuery[GameCell]:
|
def filled_cells(self) -> DOMQuery[GameCell]:
|
||||||
"""The collection of cells that are currently turned on.
|
"""The collection of cells that are currently turned on.
|
||||||
|
|
||||||
:type: DOMQuery[GameCell]
|
:type: DOMQuery[GameCell]
|
||||||
"""
|
"""
|
||||||
return cast(DOMQuery[GameCell], self.query("GameCell.on"))
|
return cast(DOMQuery[GameCell], self.query("GameCell.filled"))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_count(self) -> int:
|
def filled_count(self) -> int:
|
||||||
"""The number of cells that are turned on.
|
"""The number of cells that are turned on.
|
||||||
|
|
||||||
:type: int
|
:type: int
|
||||||
"""
|
"""
|
||||||
return len(self.on_cells)
|
return len(self.filled_cells)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_on(self) -> bool:
|
def all_on(self) -> bool:
|
||||||
@@ -157,7 +157,7 @@ class Game(Screen):
|
|||||||
|
|
||||||
:type: bool
|
:type: bool
|
||||||
"""
|
"""
|
||||||
return self.on_count == self.SIZE * self.SIZE
|
return self.filled_count == self.SIZE * self.SIZE
|
||||||
|
|
||||||
def game_playable(self, playable: bool) -> None:
|
def game_playable(self, playable: bool) -> None:
|
||||||
"""Mark the game as playable, or not.
|
"""Mark the game as playable, or not.
|
||||||
@@ -195,7 +195,7 @@ class Game(Screen):
|
|||||||
it with an invalid cell coordinate.
|
it with an invalid cell coordinate.
|
||||||
"""
|
"""
|
||||||
if 0 <= row <= (self.SIZE - 1) and 0 <= col <= (self.SIZE - 1):
|
if 0 <= row <= (self.SIZE - 1) and 0 <= col <= (self.SIZE - 1):
|
||||||
self.cell(row, col).toggle_class("on")
|
self.cell(row, col).toggle_class("filled")
|
||||||
|
|
||||||
_PATTERN: Final = (-1, 1, 0, 0, 0)
|
_PATTERN: Final = (-1, 1, 0, 0, 0)
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ class Game(Screen):
|
|||||||
"""
|
"""
|
||||||
for row, col in zip(self._PATTERN, reversed(self._PATTERN)):
|
for row, col in zip(self._PATTERN, reversed(self._PATTERN)):
|
||||||
self.toggle_cell(cell.row + row, cell.col + col)
|
self.toggle_cell(cell.row + row, cell.col + col)
|
||||||
self.query_one(GameHeader).on = self.on_count
|
self.query_one(GameHeader).on = self.filled_count
|
||||||
|
|
||||||
def make_move_on(self, cell: GameCell) -> None:
|
def make_move_on(self, cell: GameCell) -> None:
|
||||||
"""Make a move on the given cell.
|
"""Make a move on the given cell.
|
||||||
@@ -227,7 +227,7 @@ class Game(Screen):
|
|||||||
def action_new_game(self) -> None:
|
def action_new_game(self) -> None:
|
||||||
"""Start a new game."""
|
"""Start a new game."""
|
||||||
self.query_one(GameHeader).moves = 0
|
self.query_one(GameHeader).moves = 0
|
||||||
self.on_cells.remove_class("on")
|
self.filled_cells.remove_class("filled")
|
||||||
self.query_one(WinnerMessage).hide()
|
self.query_one(WinnerMessage).hide()
|
||||||
middle = self.cell(self.SIZE // 2, self.SIZE // 2)
|
middle = self.cell(self.SIZE // 2, self.SIZE // 2)
|
||||||
self.toggle_cells(middle)
|
self.toggle_cells(middle)
|
||||||
|
|||||||
Reference in New Issue
Block a user