From ad2af62029763fcc9cff19e15bc3648ad5752a2a Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 20 Oct 2022 10:01:24 +0100 Subject: [PATCH] Update sandbox example to test animated dark mode toggle --- sandbox/darren/color_animate.css | 8 ++++++++ sandbox/darren/color_animate.py | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sandbox/darren/color_animate.css b/sandbox/darren/color_animate.css index e69de29bb..124ee26e0 100644 --- a/sandbox/darren/color_animate.css +++ b/sandbox/darren/color_animate.css @@ -0,0 +1,8 @@ + * { + transition: color 300ms linear, background 300ms linear; +} + +#another-box { + background: $boost; + padding: 1 2; +} diff --git a/sandbox/darren/color_animate.py b/sandbox/darren/color_animate.py index fb5227d76..83c28a3e5 100644 --- a/sandbox/darren/color_animate.py +++ b/sandbox/darren/color_animate.py @@ -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)