mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
snapshot
This commit is contained in:
42
tests/snapshot_tests/snapshot_apps/focus_component_class.py
Normal file
42
tests/snapshot_tests/snapshot_apps/focus_component_class.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from rich.text import Text
|
||||
|
||||
from textual.app import App, ComposeResult, RenderResult
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import Header, Footer
|
||||
from textual.widget import Widget
|
||||
|
||||
|
||||
class Tester(Widget, can_focus=True):
|
||||
COMPONENT_CLASSES = {"tester--text"}
|
||||
|
||||
DEFAULT_CSS = """
|
||||
Tester {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
Tester:focus > .tester--text {
|
||||
background: red;
|
||||
}
|
||||
"""
|
||||
|
||||
def __init__(self, n: int) -> None:
|
||||
self.n = n
|
||||
super().__init__()
|
||||
|
||||
def render(self) -> RenderResult:
|
||||
return Text(
|
||||
f"test widget {self.n}", style=self.get_component_rich_style("tester--text")
|
||||
)
|
||||
|
||||
|
||||
class StyleBugApp(App[None]):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
with Vertical():
|
||||
for n in range(40):
|
||||
yield Tester(n)
|
||||
yield Footer()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
StyleBugApp().run()
|
||||
Reference in New Issue
Block a user