Skip to content

Commit e2cc158

Browse files
committed
make more mobile friendly
1 parent e6066a6 commit e2cc158

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

clerk_api_demo/clerk_api_demo/clerk_api_demo.py

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ def data_list_item(label: str, value: rx.Component | str) -> rx.Component:
243243
)
244244

245245

246+
close_icon = rx.icon(
247+
"x",
248+
position="absolute",
249+
top="8px",
250+
right="8px",
251+
background_color=rx.color("tomato", 6),
252+
_hover=dict(background_color=rx.color("tomato", 7)),
253+
padding="2px",
254+
border_radius="5px",
255+
z_index="5",
256+
)
257+
258+
246259
def demo_card(
247260
heading: str, description: str | rx.Component, demo: rx.Component
248261
) -> rx.Component:
@@ -253,9 +266,10 @@ def demo_card(
253266
),
254267
max_width="30em",
255268
_hover=dict(background=rx.color("gray", 4)),
269+
height="100%",
256270
)
257271

258-
content_popover = rx.hover_card.root(
272+
content_popover_desktop = rx.hover_card.root(
259273
rx.hover_card.trigger(
260274
card,
261275
),
@@ -264,7 +278,21 @@ def demo_card(
264278
avoid_collisions=True,
265279
),
266280
)
267-
return content_popover
281+
content_popover_mobile = rx.popover.root(
282+
rx.popover.trigger(
283+
card,
284+
),
285+
rx.popover.content(
286+
rx.popover.close(
287+
close_icon,
288+
),
289+
demo,
290+
),
291+
)
292+
return rx.fragment(
293+
rx.desktop_only(content_popover_desktop),
294+
rx.mobile_and_tablet(content_popover_mobile),
295+
)
268296

269297

270298
def current_clerk_state_values() -> rx.Component:
@@ -519,13 +547,15 @@ def user_profile_demo() -> rx.Component:
519547
rx.code("clerk.user_profile"),
520548
" component that renders a UI within your page.",
521549
),
522-
rx.dialog.root(
523-
rx.dialog.trigger(
524-
rx.button("Show in dialog"),
550+
rx.popover.root(
551+
rx.popover.trigger(
552+
rx.button("Show in popover"),
525553
),
526-
rx.dialog.content(
554+
rx.popover.content(
555+
rx.popover.close(
556+
close_icon,
557+
),
527558
clerk.user_profile(),
528-
width="1000px",
529559
max_width="1000px",
530560
),
531561
),
@@ -545,35 +575,16 @@ def user_profile_demo() -> rx.Component:
545575

546576

547577
def demo_header() -> rx.Component:
548-
# rx.markdown(
549-
# dedent(
550-
# """\
551-
# The demos below are using a development Clerk API key, so you can try out everything with fake credentials.
552-
#
553-
# To simply log in, you can use the email/password combination:
554-
#
555-
# - username: `[email protected]`
556-
# - password: `test-clerk-password`
557-
#
558-
# Or if you want to try signing up, you can use any email with `+clerk_test` appended to it. E.g., `[email protected]`.
559-
#
560-
# Use any password you like, and then the verification code will be `424242`.
561-
#
562-
# More info on test credentials can be found [in the Clerk documentation](https://clerk.com/docs/testing/test-emails-and-phones).
563-
# """,
564-
# )
565-
# ),
566578
return rx.vstack(
567579
rx.heading("Demos", size="6"),
568-
rx.hstack(
580+
rx.grid(
569581
rx.vstack(
570582
rx.text(
571583
"The demos below are using a development Clerk API key, so you can try out everything with fake credentials."
572584
),
573585
rx.text(
574586
"To simply log in, you can use the email/password combination."
575587
),
576-
width="50%",
577588
),
578589
rx.card(
579590
rx.vstack(
@@ -593,8 +604,8 @@ def demo_header() -> rx.Component:
593604
),
594605
),
595606
),
596-
width="50%",
597607
),
608+
columns=rx.breakpoints(initial="1", md="2"),
598609
),
599610
rx.text(
600611
"Or if you want test signing up, you can use any email with ",
@@ -643,6 +654,7 @@ def index() -> rx.Component:
643654
user_profile_demo(),
644655
columns=rx.breakpoints(initial="1", sm="2", md="3", xl="4"),
645656
spacing="4",
657+
align="stretch",
646658
),
647659
align="center",
648660
spacing="7",

0 commit comments

Comments
 (0)