MCPcopy
hub / github.com/reflex-dev/reflex / TailwindApp

Function TailwindApp

tests/integration/test_tailwind.py:17–65  ·  view source on GitHub ↗

App with tailwind optionally disabled. Args: tailwind_version: Tailwind version to use. If 0, tailwind is disabled. paragraph_text: Text for the paragraph. paragraph_class_name: Tailwind class_name for the paragraph.

(
    tailwind_version: int = 0,
    paragraph_text: str = PARAGRAPH_TEXT,
    paragraph_class_name: str = PARAGRAPH_CLASS_NAME,
)

Source from the content-addressed store, hash-verified

15
16
17def TailwindApp(
18 tailwind_version: int = 0,
19 paragraph_text: str = PARAGRAPH_TEXT,
20 paragraph_class_name: str = PARAGRAPH_CLASS_NAME,
21):
22 """App with tailwind optionally disabled.
23
24 Args:
25 tailwind_version: Tailwind version to use. If 0, tailwind is disabled.
26 paragraph_text: Text for the paragraph.
27 paragraph_class_name: Tailwind class_name for the paragraph.
28 """
29 from pathlib import Path
30
31 import reflex as rx
32
33 class UnusedState(rx.State):
34 pass
35
36 def index():
37 return rx.el.div(
38 rx.text(paragraph_text, class_name=paragraph_class_name),
39 rx.el.p(paragraph_text, class_name=paragraph_class_name),
40 rx.text(paragraph_text, as_="p", class_name=paragraph_class_name),
41 rx.el.div("Test external stylesheet", class_name="external"),
42 id="p-content",
43 )
44
45 # Write next to the compiled app (Path.cwd() inside the harness) so reruns
46 # don't end up with a stale __file__ from a previous tmp_path's importlib.reload.
47 assets = Path.cwd() / "assets"
48 assets.mkdir(exist_ok=True)
49 stylesheet = assets / "test_styles.css"
50 stylesheet.write_text(".external { color: rgba(0, 0, 255, 0.5) }")
51 app = rx.App(
52 style={"font_family": "monospace"},
53 stylesheets=[stylesheet.name],
54 enable_state=False,
55 )
56 app.add_page(index)
57 if not tailwind_version:
58 config = rx.config.get_config()
59 config.plugins = []
60 elif tailwind_version == 3:
61 config = rx.config.get_config()
62 config.plugins = [rx.plugins.TailwindV3Plugin()]
63 elif tailwind_version == 4:
64 config = rx.config.get_config()
65 config.plugins = [rx.plugins.TailwindV4Plugin()]
66
67
68@pytest.fixture(

Callers

nothing calls this directly

Calls 2

add_pageMethod · 0.95
get_configMethod · 0.80

Tested by

no test coverage detected