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

Show warning when ui.dark_mode breaks Tailwind #3994

Merged
merged 2 commits into from
Nov 18, 2024
Merged
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
14 changes: 14 additions & 0 deletions nicegui/elements/dark_mode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional

from .. import core, helpers
from ..events import Handler, ValueChangeEventArguments
from .mixins.value_element import ValueElement

Expand All @@ -20,6 +21,19 @@ def __init__(self, value: Optional[bool] = False, *, on_change: Optional[Handler
"""
super().__init__(value=value, on_value_change=on_change)

# HACK: this is a temporary warning to inform users about issue #3753
if core.app.is_started:
self._check_for_issue_3753()
else:
core.app.on_startup(self._check_for_issue_3753)

def _check_for_issue_3753(self) -> None:
if self.client.page.resolve_dark() is None and core.app.config.tailwind:
helpers.warn_once(
'`ui.dark_mode` is not supported on pages with `dark=None` while running with `tailwind=True` (the default). '
'See https://github.com/zauberzeug/nicegui/issues/3753 for more information.'
)

def enable(self) -> None:
"""Enable dark mode."""
self.value = True
Expand Down