From 7d7e4758e09786ef8005406dd70c76f30dfed706 Mon Sep 17 00:00:00 2001 From: Alex Rice Date: Fri, 6 Dec 2024 10:52:31 +0000 Subject: [PATCH] interactive: fix dark mode --- tests/interactive/test_app.py | 18 ++++++++++++++++++ xdsl/interactive/app.py | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/interactive/test_app.py b/tests/interactive/test_app.py index 5f2d24290e..c70d029096 100644 --- a/tests/interactive/test_app.py +++ b/tests/interactive/test_app.py @@ -519,3 +519,21 @@ async def test_argument_pass_screen(): arg_screen_str: type[Screen[Any]] = AddArguments assert isinstance(app.screen, arg_screen_str) + + +@pytest.mark.asyncio +async def test_dark_mode(): + """Tests that 'd' switches between dark and light mode""" + + async with InputApp(tuple(), tuple()).run_test() as pilot: + app = cast(InputApp, pilot.app) + + assert app.theme == "textual-dark" + + await pilot.press("d") + + assert app.theme == "textual-light" + + await pilot.press("d") + + assert app.theme == "textual-dark" diff --git a/xdsl/interactive/app.py b/xdsl/interactive/app.py index bd1061d508..e6ef9794a7 100644 --- a/xdsl/interactive/app.py +++ b/xdsl/interactive/app.py @@ -635,7 +635,9 @@ def watch_diff_operation_count_tuple(self) -> None: def action_toggle_dark(self) -> None: """An action to toggle dark mode.""" - self.dark = not self.dark + self.theme = ( + "textual-dark" if self.theme == "textual-light" else "textual-light" + ) def action_quit_app(self) -> None: """An action to quit the app."""