22import reflex as rx
33import re
44from pcweb .components .button import button , button_with_icon
5+ from reflex_ui .blocks .lemcal import lemcal_dialog , LEMCAL_DEMO_URL
56from pcweb .components .code_card import gallery_app_card
67from pcweb .components .icons import get_icon
78from pcweb .constants import SCREENSHOT_BUCKET
89from pcweb .flexdown import xd2 as xd
910from pcweb .pages .gallery import gallery
1011from pcweb .templates .gallery_app_page import gallery_app_page
1112import copy
13+ import reflex_ui as ui
1214
1315GALLERY_APP_SOURCES = [
1416 ("templates/" , "docs/getting-started/open-source-templates/" ),
1517 ("reflex_build_templates/" , "templates/" ),
1618]
1719
20+
1821def load_all_gallery_apps ():
1922 """Load markdown files from all supported paths and associate them with their base folder."""
2023 gallery_apps = {}
2124 for folder , _ in GALLERY_APP_SOURCES :
2225 paths = flexdown .utils .get_flexdown_files (folder )
2326 for path in reversed (sorted (paths )):
2427 document = flexdown .Document .from_file (path ) # This has metadata
25- document .metadata ["title" ] = document .metadata .get ("title" , "Untitled" ).replace ("_" , " " ).title ()
28+ document .metadata ["title" ] = (
29+ document .metadata .get ("title" , "Untitled" ).replace ("_" , " " ).title ()
30+ )
2631 clean_path = str (path ).replace (".md" , "/" )
2732 gallery_apps [(clean_path , folder )] = document
2833 return gallery_apps
2934
3035
3136gallery_apps_data = load_all_gallery_apps ()
32- gallery_apps_data_copy = {
33- path : doc for (path , _ ), doc in gallery_apps_data .items ()
34- }
37+ gallery_apps_data_copy = {path : doc for (path , _ ), doc in gallery_apps_data .items ()}
3538gallery_apps_data_open_source = {
3639 (path , folder ): doc
3740 for (path , folder ), doc in load_all_gallery_apps ().items ()
@@ -55,7 +58,7 @@ def more_posts(current_post: dict) -> rx.Component:
5558 if current_index is None :
5659 selected_posts = app_items [- 3 :]
5760 else :
58- other_posts = app_items [:current_index ] + app_items [current_index + 1 :]
61+ other_posts = app_items [:current_index ] + app_items [current_index + 1 :]
5962 if len (other_posts ) <= 3 :
6063 selected_posts = other_posts
6164 elif current_index == 0 :
@@ -64,9 +67,9 @@ def more_posts(current_post: dict) -> rx.Component:
6467 selected_posts = other_posts [- 3 :]
6568 else :
6669 if current_index < len (app_items ) - 2 :
67- selected_posts = other_posts [current_index - 1 : current_index + 2 ]
70+ selected_posts = other_posts [current_index - 1 : current_index + 2 ]
6871 else :
69- selected_posts = other_posts [current_index - 2 : current_index + 1 ]
72+ selected_posts = other_posts [current_index - 2 : current_index + 1 ]
7073
7174 for path , document in selected_posts :
7275 posts .append (gallery_app_card (app = document .metadata ))
@@ -76,7 +79,9 @@ def more_posts(current_post: dict) -> rx.Component:
7679 rx .el .h2 ("More Templates" , class_name = "font-large text-slate-12" ),
7780 rx .link (
7881 rx .box (
79- rx .text ("View All" , class_name = "font-small text-slate-9 text-nowrap" ),
82+ rx .text (
83+ "View All" , class_name = "font-small text-slate-9 text-nowrap"
84+ ),
8085 get_icon (icon = "new_tab" , class_name = "" ),
8186 class_name = "flex items-center gap-1.5 border-slate-5 bg-slate-1 hover:bg-slate-3 shadow-small px-1.5 py-0.5 border rounded-md w-auto max-w-full text-slate-9 transition-bg cursor-pointer overflow-hidden border-solid" ,
8287 ),
@@ -104,8 +109,8 @@ def page(document, is_reflex_template: bool) -> rx.Component:
104109 loading = "lazy" ,
105110 class_name = "w-full object-cover max-w-full aspect-[1500/938] border-y border-slate-3 border-solid" ,
106111 )
107- if not is_reflex_template else
108- rx .el .div (
112+ if not is_reflex_template
113+ else rx .el .div (
109114 rx .box (
110115 rx .el .h1 (
111116 meta ["title" ].replace ("_" , " " ).title (),
@@ -114,7 +119,7 @@ def page(document, is_reflex_template: bool) -> rx.Component:
114119 class_name = "w-full self-start pl-4" ,
115120 ),
116121 rx .el .iframe (
117- src = meta [' video' ],
122+ src = meta [" video" ],
118123 class_name = "w-full h-full xl:rounded-md shadow-small" ,
119124 id = "iFrame" ,
120125 title = "Reflex Build" ,
@@ -124,7 +129,11 @@ def page(document, is_reflex_template: bool) -> rx.Component:
124129 )
125130 )
126131
127- back_route_origin = "/docs/getting-started/open-source-templates/" if not is_reflex_template else "/templates/"
132+ back_route_origin = (
133+ "/docs/getting-started/open-source-templates/"
134+ if not is_reflex_template
135+ else "/templates/"
136+ )
128137
129138 return rx .el .section (
130139 rx .el .article (
@@ -141,52 +150,61 @@ def page(document, is_reflex_template: bool) -> rx.Component:
141150 class_name = "flex w-fit" ,
142151 href = back_route_origin ,
143152 ),
144- rx .el .h1 (meta ["title" ], class_name = "font-x-large text-slate-12" ) if not is_reflex_template else rx .fragment (),
153+ (
154+ rx .el .h1 (meta ["title" ], class_name = "font-x-large text-slate-12" )
155+ if not is_reflex_template
156+ else rx .fragment ()
157+ ),
145158 rx .el .h2 (meta ["description" ], class_name = "font-md text-slate-11" ),
146159 class_name = "flex flex-col gap-3 p-8" ,
147160 ),
148161 rx .box (
149162 * (
150- [rx .box (
151- rx .link (
152- button_with_icon (
153- "Book a Demo" ,
154- icon = "new_tab" ,
155- class_name = "flex-row-reverse gap-2 !w-full" ,
156- ),
157- is_external = True ,
158- href = "/pricing" ,
159- class_name = "!w-full"
163+ [
164+ rx .box (
165+ ui .link (
166+ render_ = button_with_icon (
167+ "Book a Demo" ,
168+ icon = "new_tab" ,
169+ class_name = "flex-row-reverse gap-2 !w-full" ,
160170 ),
161- class_name = "flex justify-center items-center h-full !w-full" ,
162- )] if is_reflex_template else
163- (
164- [rx .link (
165- button_with_icon (
166- "View Demo" ,
167- icon = "new_tab" ,
168- class_name = "!w-full flex-row-reverse gap-2" ,
171+ target = "_blank" ,
172+ to = LEMCAL_DEMO_URL ,
169173 ),
170- is_external = True ,
171- href = meta ["demo" ],
172- )] if meta .get ("demo" ) else []
174+ class_name = "flex justify-center items-center h-full !w-full [&_button]:!w-full" ,
175+ )
176+ ]
177+ ),
178+ (
179+ rx .link (
180+ button ("View Code" , variant = "muted" , class_name = "!w-full" ),
181+ is_external = True ,
182+ href = meta .get ("source" , "#" ),
173183 )
184+ if not is_reflex_template
185+ else rx .fragment ()
186+ ),
187+ (
188+ rx .cond (
189+ "Reflex" in meta ["author" ],
190+ rx .box (
191+ rx .text (
192+ "Created by" , class_name = "text-slate-9 font-base"
193+ ),
194+ get_icon (icon = "badge_logo" ),
195+ rx .text (
196+ meta ["author" ], class_name = "text-slate-9 font-base"
197+ ),
198+ class_name = "flex flex-row items-center gap-1 self-end" ,
199+ ),
200+ rx .text (
201+ f"by { meta ['author' ]} " ,
202+ class_name = "text-slate-9 font-base" ,
203+ ),
204+ )
205+ if not is_reflex_template
206+ else rx .fragment ()
174207 ),
175- rx .link (
176- button ("View Code" , variant = "muted" , class_name = "!w-full" ),
177- is_external = True ,
178- href = meta .get ('source' , "#" ),
179- ) if not is_reflex_template else rx .fragment (),
180- rx .cond (
181- "Reflex" in meta ["author" ],
182- rx .box (
183- rx .text ("Created by" , class_name = "text-slate-9 font-base" ),
184- get_icon (icon = "badge_logo" ),
185- rx .text (meta ["author" ], class_name = "text-slate-9 font-base" ),
186- class_name = "flex flex-row items-center gap-1 self-end" ,
187- ),
188- rx .text (f"by { meta ['author' ]} " , class_name = "text-slate-9 font-base" ),
189- ) if not is_reflex_template else rx .fragment (),
190208 class_name = "p-8 flex flex-col gap-4" ,
191209 ),
192210 class_name = "grid grid-cols-1 lg:grid-cols-2 divide-y lg:divide-y-0 lg:divide-x divide-slate-3 border-b border-slate-3" ,
@@ -204,7 +222,11 @@ def page(document, is_reflex_template: bool) -> rx.Component:
204222gallery_apps_routes = []
205223for (path , source_folder ), document in gallery_apps_data .items ():
206224 is_reflex_template = source_folder .startswith ("reflex_build_templates" )
207- base_url = "templates/" if is_reflex_template else "docs/getting-started/open-source-templates/"
225+ base_url = (
226+ "templates/"
227+ if is_reflex_template
228+ else "docs/getting-started/open-source-templates/"
229+ )
208230 slug = re .sub (r"[\s_]+" , "-" , document .metadata ["title" ]).lower ()
209231 route = f"/{ base_url } { slug } "
210232
@@ -221,6 +243,10 @@ def page(document, is_reflex_template: bool) -> rx.Component:
221243 image = document .metadata ["image" ],
222244 demo = document .metadata .get ("demo" ),
223245 meta = document .metadata .get ("meta" , []),
224- )(lambda doc = document , is_reflex_template = is_reflex_template : page (doc , is_reflex_template ))
246+ )(
247+ lambda doc = document , is_reflex_template = is_reflex_template : page (
248+ doc , is_reflex_template
249+ )
250+ )
225251
226252 gallery_apps_routes .append (comp )
0 commit comments