mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Update sandbox example to test animated dark mode toggle
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
* {
|
||||
transition: color 300ms linear, background 300ms linear;
|
||||
}
|
||||
|
||||
#another-box {
|
||||
background: $boost;
|
||||
padding: 1 2;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.binding import Binding
|
||||
from textual.color import Color
|
||||
from textual.widgets import Static
|
||||
|
||||
@@ -7,11 +8,16 @@ END_COLOR = Color.parse("#0000FF0F")
|
||||
|
||||
|
||||
class ColorAnimate(App):
|
||||
BINDINGS = [Binding("d", action="toggle_dark", description="Dark mode")]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
box = Static("Hello, world", id="box")
|
||||
box.styles.background = START_COLOR
|
||||
self.box = box
|
||||
yield box
|
||||
self.box = Static("Hello, world", id="box")
|
||||
self.box.styles.background = START_COLOR
|
||||
|
||||
self.another_box = Static("Another box with $boost", id="another-box")
|
||||
|
||||
yield self.box
|
||||
yield self.another_box
|
||||
|
||||
def key_a(self):
|
||||
self.animator.animate(self.box.styles, "background", END_COLOR, duration=2.0)
|
||||
|
||||
Reference in New Issue
Block a user