Skip to content
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
1 change: 1 addition & 0 deletions docs/app/news/+state-overview-dark-heading.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the State overview example heading rendering black on the dark background in dark mode.
34 changes: 34 additions & 0 deletions docs/app/tests/test_state_overview_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Regression coverage for the State overview page's color-cycling example."""

import re
from pathlib import Path

import pytest
import reflex as rx
from reflex_base.registry import RegistrationContext

from reflex_docs.docgen_pipeline import render_docgen_document

DOCS = Path(__file__).resolve().parents[2]


@pytest.fixture(autouse=True)
def isolated_registration():
"""Keep the demo's state class out of the shared registries other tests use."""
with RegistrationContext(
_config=rx.Config(app_name="reflex_docs", frontend_path="/docs")
):
yield


def test_example_heading_starts_theme_aware():
"""The first color is the theme foreground, not black, so it reads in dark mode."""
# A test-specific virtual path keeps the demo's state class from colliding
# with the one test_docgen_double_eval registers for the real page.
body, _ = render_docgen_document(
"docs/state/overview_heading_test.md", str(DOCS / "state" / "overview.md")
)
rendered = str(body)
# The example source is embedded with escaped quotes, so match loosely.
assert re.search(r'colors: list\[str\] = \[\\?"var\(--gray-12\)\\?"', rendered)
assert not re.search(r'colors: list\[str\] = \[\\?"black\\?"', rendered)
2 changes: 1 addition & 1 deletion docs/state/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Click the text to change its color.
```python demo exec
class ExampleState(rx.State):
# A base var for the list of colors to cycle through.
colors: list[str] = ["black", "red", "green", "blue", "purple"]
colors: list[str] = ["var(--gray-12)", "red", "green", "blue", "purple"]
Comment thread
FarhanAliRaza marked this conversation as resolved.

# A base var for the index of the current color.
index: int = 0
Expand Down
Loading