11import reflex as rx
2+ from reflex .experimental .client_state import ClientStateVar
3+
4+ from pcweb .components .icons .hugeicons import hi
25from pcweb .components .icons .icons import get_icon
3- from reflex .components .datadisplay .shiki_code_block import copy_script
46
57
8+ @rx .memo
69def 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 )
0 commit comments