Skip to content

Commit d22a93d

Browse files
6 - Building a Custom Reflex Component
1 parent b353acd commit d22a93d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

full_stack_python/full_stack_python.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,29 @@ def handle_title_input_change(self, val):
1515
def did_click(self):
1616
print("Hello world did click")
1717

18+
def navbar() -> rx.Component:
19+
return rx.heading("SaaS", size="9"),
1820

19-
def index() -> rx.Component:
20-
# Welcome Page (Index)
21+
def base_page(child: rx.Component, hide_navbar=False, *args, **kwargs) -> rx.Component:
22+
# print([type(x) for x in args])
23+
if not isinstance(child,rx. Component):
24+
child = rx.heading("this is not a valid child element")
25+
if hide_navbar:
26+
return rx.container(
27+
child,
28+
rx.logo(),
29+
rx.color_mode.button(position="bottom-left"),
30+
)
2131
return rx.container(
32+
navbar(),
33+
child,
34+
rx.logo(),
2235
rx.color_mode.button(position="bottom-left"),
36+
)
37+
38+
def index() -> rx.Component:
39+
# Welcome Page (Index)
40+
return base_page(
2341
rx.vstack(
2442
rx.heading(State.label, size="9"),
2543
rx.text(
@@ -42,7 +60,7 @@ def index() -> rx.Component:
4260
justify="center",
4361
min_height="85vh",
4462
),
45-
rx.logo(),
63+
hide_navbar=True
4664
)
4765

4866

0 commit comments

Comments
 (0)