Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interactive: fix dark mode #3582

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/interactive/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion xdsl/interactive/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Loading