Skip to content

Commit be49517

Browse files
[GTM-838][GTM-841]Add template name and fix broken template links (#1089)
* Add template name and fix broken template links * revert install command logic * remove website from templates * Rectify links and template content * The width should be passed as a prop * remove dead code * remove dollat sign from template * fix ci template, template name * make requested changes * the template cards should have the full reflex command * add max-width * templates: install_command copy button animation import `copy_script` from the shiki code block and reuse it * templates: set width="100%" for description text allow truncation ellipses and auto tooltip logic in browsers like safari and firefox --------- Co-authored-by: Masen Furer <[email protected]>
1 parent 3df1a6f commit be49517

File tree

13 files changed

+85
-58
lines changed

13 files changed

+85
-58
lines changed

pcweb/components/code_card.py

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
import reflex as rx
22
from pcweb.components.icons.icons import get_icon
3+
from reflex.components.datadisplay.shiki_code_block import copy_script
34

45

5-
def install_command(command: str) -> rx.Component:
6+
def install_command(command: str, show_dollar_sign: bool = True, **props) -> rx.Component:
67
return rx.el.button(
7-
get_icon(icon="copy", class_name="p-[5px]"),
8+
rx.icon("copy", size=14, margin_left="5px"),
89
rx.text(
9-
"$" + command,
10+
"$" + command if show_dollar_sign else command,
1011
as_="p",
1112
class_name="flex-grow flex-shrink min-w-0 font-small text-start truncate",
1213
),
1314
title=command,
14-
on_click=rx.set_clipboard(command),
15+
on_click=[
16+
rx.set_clipboard(command),
17+
copy_script(),
18+
],
1519
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",
20+
style={
21+
"opacity": "1",
22+
"cursor": "pointer",
23+
"transition": "background 0.250s ease-out",
24+
"&>svg": {
25+
"transition": "transform 0.250s ease-out, opacity 0.250s ease-out",
26+
},
27+
},
28+
**props,
1629
)
1730

1831

@@ -28,7 +41,7 @@ def repo(repo_url: str) -> rx.Component:
2841
def code_card(app: dict) -> rx.Component:
2942
return rx.flex(
3043
rx.box(
31-
rx.link(
44+
rx.el.a(
3245
rx.image(
3346
src=app["image_url"],
3447
loading="lazy",
@@ -88,35 +101,55 @@ def gallery_app_card(app: dict) -> rx.Component:
88101
),
89102
rx.box(
90103
rx.box(
91-
rx.el.h4(
104+
rx.el.h6(
92105
app["title"],
93106
class_name="font-smbold text-slate-12 truncate",
107+
width="100%",
94108
),
95109
rx.text(
96110
app["description"],
97111
class_name="text-slate-10 font-small truncate text-pretty",
112+
width="100%",
98113
),
99114
rx.box(
100-
rx.cond(
101-
"Reflex" in app["author"],
115+
rx.vstack(
102116
rx.box(
103-
rx.text(
104-
"by",
105-
class_name="text-slate-9 font-small",
117+
rx.hstack(
118+
install_command(f"reflex init --template {app['title']}"),
119+
rx.hstack(
120+
repo(app["demo"]),
121+
justify="start",
122+
123+
),
124+
),
125+
width="310px",
126+
max_width="310px",
127+
128+
),
129+
rx.cond(
130+
"Reflex" in app["author"],
131+
rx.box(
132+
rx.text(
133+
"by",
134+
class_name="text-slate-9 font-small",
135+
),
136+
get_icon(icon="badge_logo"),
137+
rx.text(
138+
app["author"],
139+
class_name="text-slate-9 font-small",
140+
),
141+
class_name="flex flex-row items-start gap-1",
106142
),
107-
get_icon(icon="badge_logo"),
108143
rx.text(
109-
app["author"],
144+
f"by {app['author']}",
110145
class_name="text-slate-9 font-small",
111146
),
112-
class_name="flex flex-row items-center gap-1",
113-
),
114-
rx.text(
115-
f"by {app['author']}",
116-
class_name="text-slate-9 font-small",
117147
),
148+
align_items="start",
149+
class_name="brother-john"
118150
),
119-
repo(app["demo"]),
151+
152+
120153
class_name="flex flex-row items-center gap-[6px] justify-between w-full",
121154
),
122155
class_name="flex flex-col justify-between items-start gap-1 p-[0.625rem_0.75rem_0.625rem_0.75rem] w-full h-full",

pcweb/pages/gallery/gallery.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def gallery_heading() -> rx.Component:
5252
),
5353
class_name="font-md text-balance text-slate-9 -mt-4",
5454
),
55+
rx.text.span(
56+
"Copy the template command and use it during ",
57+
rx.code("reflex init"),
58+
class_name="font-sm text-balance text-slate-9",
59+
),
5560
class_name="section-header",
5661
)
5762

templates/api-admin-panel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: API Admin Panel
2+
title: api_admin_panel
33
description: "Interactive dashboard for API requests and response visualization"
44
author: "Reflex"
55
image: "api-admin-panel.webp"
66
demo: "https://api-admin-panel.reflex.run/"
7-
source: "https://github.com/reflex-dev/gallery-apps/tree/main/api-admin-panel"
7+
source: "https://github.com/reflex-dev/templates/tree/main/api_admin_panel"
88
meta: [
99
{"name": "keywords", "content": "admin panel, api admin panel, reflex admin panel"},
1010
]

templates/chat-app.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Chat App
2+
title: reflex-chat
33
description: "Real-time chat application with multiple rooms using Reflex and ChatGPT"
44
author: "Reflex"
55
image: "chat-app.webp"
66
demo: "https://chat.reflex.run/"
7-
source: "https://github.com/reflex-dev/reflex-examples/tree/main/gpt/gpt"
7+
source: "https://github.com/reflex-dev/reflex-chat"
88
meta: [
99
{"name": "keywords", "content": ""},
1010
]
@@ -18,11 +18,7 @@ The following is a python chat app. It is 100% Python-based, including the UI, a
1818
To run this app locally, install Reflex and run:
1919

2020
```bash
21-
git clone https://github.com/reflex-dev/reflex-chat.git
22-
```
23-
24-
```bash
25-
cd reflex-chat
21+
reflex init --template reflex-chat
2622
```
2723

2824
Set up your OpenAI API key:

templates/ci-job.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
2-
title: CI Job
2+
title: ci_template
33
description: "CI/CD job dashboard with real-time updates and controls"
44
author: "Reflex"
55
image: "cijob.webp"
66
demo: "https://cijob.reflex.run/"
77
source: "https://github.com/reflex-dev/templates/tree/main/ci_template"
8+
89
meta: [
910
{"name": "keywords", "content": ""},
1011
]

templates/customer-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Customer Data App
2+
title: customer_data_app
33
description: "A Reflex app for customer data management with visualizations"
44
author: "Reflex"
55
image: "customer-app.webp"

templates/dalle.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
title: DALL-E
2+
title: dalle
33
description: "DALL-E is a Reflex app for generating images using OpenAI's API"
44
author: "Reflex"
55
image: "dalle.webp"
66
demo: "https://dalle.reflex.run/"
7-
source: "https://github.com/reflex-dev/reflex-examples/tree/main/dalle"
7+
source: "https://github.com/reflex-dev/templates/tree/main/dalle"
88
meta: [
99
{"name": "keywords", "content": ""},
1010
]
11+
template: "dalle"
1112
---
1213

1314
In this example we create a simple app for generating images using OpenAI's API.
@@ -17,8 +18,7 @@ In this example we create a simple app for generating images using OpenAI's API.
1718
To run this app locally, install Reflex and run:
1819

1920
```bash
20-
git clone https://github.com/reflex-dev/reflex-examples.git
21-
cd reflex-examples/ci-job
21+
reflex init --template dalle
2222
```
2323

2424
Set up your OpenAI API key:

templates/dashboard.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
2-
title: Dashboard
2+
title: dashboard
33
description: "Interactive dashboard with real-time data visualization"
44
author: "Reflex"
55
image: "dashboard.webp"
66
demo: "https://dashboard-new.reflex.run/"
77
source: "https://github.com/reflex-dev/templates/tree/main/dashboard"
8-
meta: [{ "name": "keywords", "content": "" }]
8+
meta: [
9+
{"name": "keywords", "content": ""},
10+
]
911
---
1012

1113
The following is a dashboard to interactively display data some data. It is a good starting point for building more complex apps that require data visualization.

templates/image-gen.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Image Gen
2+
title: ai_image_gen
33
description: "Generate AI images using Replicate's API"
44
author: "Reflex"
55
image: "image-gen.webp"
@@ -17,7 +17,7 @@ The following is an app that allows you to generate AI images. The current map u
1717
To run this app locally, install Reflex and run:
1818

1919
```bash
20-
reflex init --template image_gen
20+
reflex init --template ai_image_gen
2121
```
2222

2323
To run the app, set the `REPLICATE_API_TOKEN`:

templates/llamaindex-app.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: LLamaIndex App
2+
title: reflex-llamaindex-template
33
description: "A minimal chat app using LLamaIndex"
44
author: "Reflex"
55
image: "llamaindex.png"
@@ -21,9 +21,11 @@ If you plan on deploying your agentic workflow to prod, follow the [llama deploy
2121
To run this app locally, install Reflex and run:
2222

2323
```bash
24-
git clone https://github.com/reflex-dev/reflex-llamaindex-template.git
24+
reflex init --template reflex-llamaindex-template
2525
```
2626

27+
28+
2729
The following [lines](https://github.com/reflex-dev/reflex-llamaindex-template/blob/abfda49ff193ceb7da90c382e5cbdcb5fcdb665c/frontend/state.py#L55-L79) in the state.py file are where the app makes a request to your deployed agentic workflow. If you have not deployed your agentic workflow, you can edit this to call and api endpoint of your choice.
2830

2931
```python

0 commit comments

Comments
 (0)