Skip to content

Commit 75522ad

Browse files
carlosabadiaLineIndentTom Gotsman
authored
ENG-6455: New templates page (#1456)
* init * rebuild templates page * patches to new templates * more patches * health dashboard md file * fix sidebar bug and patch templates * update sidebar ui and update hosting templates * Revert "Merge branch 'main' into carlos/templates-sidebar" revert main This reverts commit 11cc081, reversing changes made to 96d282d. * update * add 2x templates more * whitelis empty * update all md files * small fix * update uv files * Revert "Revert "Merge branch 'main' into carlos/templates-sidebar"" This reverts commit fcb98ad. * use flexdown v2 * update test * update test part II * update test part II --------- Co-authored-by: Ahmad Hakim <[email protected]> Co-authored-by: Tom Gotsman <[email protected]> Co-authored-by: Ahmad Hakim <[email protected]>
1 parent 84947f1 commit 75522ad

39 files changed

+1151
-312
lines changed
457 KB
Loading
186 KB
Loading
592 KB
Loading
384 KB
Loading
464 KB
Loading
360 KB
Loading
314 KB
Loading
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Open Source Templates
2+
3+
Check out what the community is building with Reflex. See 2000+ more public projects on [Github](https://github.com/reflex-dev/reflex/network/dependents). Want to get your app featured? Submit it [here](https://github.com/reflex-dev/templates). Copy the template command and use it during `reflex init`
4+
5+
```python exec
6+
7+
import reflex as rx
8+
9+
from pcweb.components.code_card import gallery_app_card
10+
from pcweb.components.webpage.comps import h1_title
11+
from pcweb.pages.gallery.sidebar import TemplatesState, pagination, sidebar
12+
from pcweb.templates.webpage import webpage
13+
14+
15+
@rx.memo
16+
def skeleton_card() -> rx.Component:
17+
return rx.skeleton(
18+
class_name="box-border shadow-large border rounded-xl w-full h-[280px] overflow-hidden",
19+
loading=True,
20+
)
21+
22+
23+
def component_grid() -> rx.Component:
24+
from pcweb.pages.gallery.apps import gallery_apps_data
25+
26+
posts = []
27+
for path, document in list(gallery_apps_data.items()):
28+
posts.append(
29+
rx.cond(
30+
TemplatesState.filtered_templates.contains(document.metadata["title"]),
31+
gallery_app_card(app=document.metadata),
32+
None,
33+
)
34+
)
35+
return rx.box(
36+
*posts,
37+
rx.box(
38+
rx.el.h4(
39+
"No templates found",
40+
class_name="text-base font-semibold text-slate-12 text-nowrap",
41+
),
42+
class_name="flex-col gap-2 flex absolute left-1 top-0 z-[-1] w-full",
43+
),
44+
class_name="gap-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 w-full relative",
45+
)
46+
47+
48+
def gallery() -> rx.Component:
49+
return rx.el.section(
50+
rx.box(
51+
sidebar(),
52+
rx.box(
53+
component_grid(),
54+
pagination(),
55+
class_name="flex flex-col",
56+
),
57+
class_name="flex flex-col gap-6 lg:gap-10 w-full",
58+
),
59+
id="gallery",
60+
class_name="mx-auto",
61+
)
62+
63+
```
64+
65+
```python eval
66+
gallery()
67+
```

pcweb/components/code_card.py

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
import reflex as rx
2+
from reflex.experimental.client_state import ClientStateVar
3+
4+
from pcweb.components.icons.hugeicons import hi
25
from pcweb.components.icons.icons import get_icon
3-
from reflex.components.datadisplay.shiki_code_block import copy_script
46

57

8+
@rx.memo
69
def install_command(
7-
command: str, show_dollar_sign: bool = True, **props
10+
command: str,
11+
show_dollar_sign: bool = True,
812
) -> rx.Component:
13+
copied = ClientStateVar.create("is_copied", default=False, global_ref=False)
914
return rx.el.button(
10-
rx.icon("copy", size=14, margin_left="5px"),
15+
rx.cond(
16+
copied.value,
17+
hi(
18+
"tick-02",
19+
size=14,
20+
class_name="ml-[5px] shrink-0",
21+
),
22+
hi("copy-01", size=14, class_name="shrink-0 ml-[5px]"),
23+
),
1124
rx.text(
12-
"$" + command if show_dollar_sign else command,
25+
rx.cond(
26+
show_dollar_sign,
27+
f"${command}",
28+
command,
29+
),
1330
as_="p",
14-
class_name="flex-grow flex-shrink min-w-0 font-small text-start truncate",
31+
class_name="font-small text-start truncate",
1532
),
1633
title=command,
1734
on_click=[
35+
rx.call_function(copied.set_value(True)),
1836
rx.set_clipboard(command),
19-
copy_script(),
2037
],
21-
class_name="flex items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full max-w-full text-slate-9 transition-bg cursor-pointer overflow-hidden",
38+
on_mouse_down=rx.call_function(copied.set_value(False)).debounce(1500),
39+
class_name="flex items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small pr-1.5 border rounded-md w-full text-slate-9 transition-bg cursor-pointer overflow-hidden min-w-0 flex-1 h-[24px]",
2240
style={
2341
"opacity": "1",
2442
"cursor": "pointer",
@@ -27,7 +45,6 @@ def install_command(
2745
"transition": "transform 0.250s ease-out, opacity 0.250s ease-out",
2846
},
2947
},
30-
**props,
3148
)
3249

3350

@@ -36,7 +53,7 @@ def repo(repo_url: str) -> rx.Component:
3653
get_icon(icon="new_tab", class_name="p-[5px]"),
3754
href=repo_url,
3855
is_external=True,
39-
class_name="border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small border border-solid rounded-md text-slate-9 hover:!text-slate-9 no-underline transition-bg cursor-pointer",
56+
class_name="border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small border border-solid rounded-md text-slate-9 hover:!text-slate-9 no-underline transition-bg cursor-pointer shrink-0",
4057
)
4158

4259

@@ -48,12 +65,12 @@ def code_card(app: dict) -> rx.Component:
4865
src=app["image_url"],
4966
loading="lazy",
5067
alt="Image preview for app: " + app["name"],
51-
class_name="w-full h-full duration-150 object-top object-cover hover:scale-105 transition-transform ease-out",
68+
class_name="size-full duration-150 object-top object-cover hover:scale-105 transition-transform ease-out",
5269
),
5370
href=app["demo_url"],
5471
is_external=True,
5572
),
56-
class_name="relative border-slate-5 border-b border-solid w-full h-full overflow-hidden",
73+
class_name="relative border-slate-5 border-b border-solid w-full overflow-hidden h-[180px]",
5774
),
5875
rx.box(
5976
rx.box(
@@ -64,7 +81,9 @@ def code_card(app: dict) -> rx.Component:
6481
class_name="flex flex-row justify-between items-center gap-3 p-[0.625rem_0.75rem_0rem_0.75rem] w-full",
6582
),
6683
rx.box(
67-
install_command("reflex init --template " + app["demo_url"]),
84+
install_command(
85+
"reflex init --template " + app["demo_url"], show_dollar_sign=False
86+
),
6887
rx.cond(app["source"], repo(app["source"])),
6988
rx.link(
7089
get_icon(icon="eye", class_name="p-[5px]"),
@@ -87,87 +106,76 @@ def code_card(app: dict) -> rx.Component:
87106
)
88107

89108

90-
def gallery_app_card(app: dict) -> rx.Component:
109+
def gallery_app_card(app: dict[str, str]) -> rx.Component:
91110
return rx.flex(
92111
rx.box(
93112
rx.link(
94113
rx.image(
95114
src=app["image"],
96115
loading="lazy",
97116
alt="Image preview for app: " + app["title"],
98-
class_name="w-full h-full duration-150 object-top object-cover hover:scale-105 transition-transform ease-out aspect-[1500/938]",
117+
class_name="size-full duration-150 object-cover hover:scale-105 transition-transform ease-out",
99118
),
100-
href=f"/templates/{app['title'].replace(' ', '-').lower()}",
119+
href=f"/docs/getting-started/open-source-templates/{app['title'].replace(' ', '-').lower()}",
101120
),
102-
class_name="relative border-slate-5 border-b border-solid w-full overflow-hidden h-[60%]",
121+
class_name="relative border-slate-5 border-b border-solid w-full overflow-hidden h-[180px]",
103122
),
104123
rx.box(
105124
rx.box(
106125
rx.el.h6(
107126
app["title"],
108-
class_name="font-smbold text-slate-12 truncate",
127+
class_name="font-smbold text-slate-12 truncate shrink-0",
109128
width="100%",
110129
),
111130
rx.text(
112131
app["description"],
113-
class_name="text-slate-10 font-small truncate text-pretty",
132+
class_name="text-slate-10 font-small truncate text-pretty shrink-0",
114133
width="100%",
115134
),
116135
rx.box(
117-
rx.vstack(
118-
rx.box(
119-
rx.hstack(
120-
install_command(
121-
f"reflex init --template {app['title']}"
122-
),
123-
*(
124-
[
125-
rx.hstack(
126-
repo(app["demo"]),
127-
justify="start",
128-
)
129-
]
130-
if "demo" in app
131-
else []
132-
),
133-
),
134-
width="310px",
135-
max_width="310px",
136+
rx.box(
137+
install_command(
138+
command=f"reflex init --template {app['title']}",
139+
show_dollar_sign=False,
140+
),
141+
*(
142+
[
143+
rx.box(
144+
repo(app["demo"]),
145+
class_name="flex flex-row justify-start",
146+
)
147+
]
148+
if "demo" in app
149+
else []
136150
),
137-
rx.cond(
138-
"Reflex" in app["author"],
139-
rx.box(
140-
rx.text(
141-
"by",
142-
class_name="text-slate-9 font-small",
143-
),
144-
get_icon(icon="badge_logo"),
145-
rx.text(
146-
app["author"],
147-
class_name="text-slate-9 font-small",
148-
),
149-
class_name="flex flex-row items-start gap-1",
151+
class_name="flex flex-row max-w-full gap-2 w-full shrink-0",
152+
),
153+
rx.box(class_name="grow"),
154+
rx.cond(
155+
"Reflex" in app["author"],
156+
rx.box(
157+
rx.text(
158+
"by",
159+
class_name="text-slate-9 font-small",
150160
),
161+
get_icon(icon="badge_logo"),
151162
rx.text(
152-
f"by {app['author']}",
163+
app["author"],
153164
class_name="text-slate-9 font-small",
154165
),
166+
class_name="flex flex-row items-start gap-1",
167+
),
168+
rx.text(
169+
f"by {app['author']}",
170+
class_name="text-slate-9 font-small",
155171
),
156-
align_items="start",
157-
class_name="brother-john",
158172
),
159-
class_name="flex flex-row items-center gap-[6px] justify-between w-full",
173+
class_name="flex flex-col gap-[6px] size-full",
160174
),
161-
class_name="flex flex-col justify-between items-start gap-1 p-[0.625rem_0.75rem_0.625rem_0.75rem] w-full h-full",
175+
class_name="flex flex-col items-start gap-2 p-[0.625rem_0.75rem_0.625rem_0.75rem] w-full h-full",
162176
),
163177
class_name="flex flex-col gap-[10px] w-full h-full flex-1",
164178
),
165-
style={
166-
"animation": "fade-in 0.35s ease-out",
167-
"@keyframes fade-in": {
168-
"0%": {"opacity": "0"},
169-
"100%": {"opacity": "1"},
170-
},
171-
},
172-
class_name="box-border flex flex-col border-slate-5 bg-slate-1 shadow-large border rounded-xl w-full h-[320px] overflow-hidden",
179+
key=app["title"],
180+
class_name="box-border flex-col border-slate-5 bg-slate-1 shadow-large border rounded-xl w-full h-[360px] overflow-hidden",
173181
)

pcweb/components/docpage/navbar/navbar.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,13 @@ def new_component_section() -> rx.Component:
434434
rx.badge(
435435
"Docs",
436436
variant="surface",
437-
class_name=(
438-
"text-violet-9 text-sm",
439-
rx.cond(
440-
rx.State.router.page.path.contains("docs")
441-
| rx.State.router.page.path.contains("ai-builder")
442-
| rx.State.router.page.path.contains("cloud"),
443-
"xl:flex hidden",
444-
"hidden",
445-
),
437+
class_name="text-violet-9 xl:flex hidden text-sm",
438+
display=rx.cond(
439+
rx.State.router.page.path.contains("docs")
440+
| rx.State.router.page.path.contains("ai-builder")
441+
| rx.State.router.page.path.contains("cloud"),
442+
"block",
443+
"none",
446444
),
447445
),
448446
class_name="flex flex-row gap-x-0",

0 commit comments

Comments
 (0)