Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTM-838][GTM-841]Add template name and fix broken template links #1089

Merged
merged 13 commits into from
Nov 26, 2024
71 changes: 52 additions & 19 deletions pcweb/components/code_card.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import reflex as rx
from pcweb.components.icons.icons import get_icon
from reflex.components.datadisplay.shiki_code_block import copy_script


def install_command(command: str) -> rx.Component:
def install_command(command: str, show_dollar_sign: bool = True, **props) -> rx.Component:
return rx.el.button(
get_icon(icon="copy", class_name="p-[5px]"),
rx.icon("copy", size=14, margin_left="5px"),
rx.text(
"$" + command,
"$" + command if show_dollar_sign else command,
as_="p",
class_name="flex-grow flex-shrink min-w-0 font-small text-start truncate",
),
title=command,
on_click=rx.set_clipboard(command),
on_click=[
rx.set_clipboard(command),
copy_script(),
],
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",
style={
"opacity": "1",
"cursor": "pointer",
"transition": "background 0.250s ease-out",
"&>svg": {
"transition": "transform 0.250s ease-out, opacity 0.250s ease-out",
},
},
**props,
)


Expand All @@ -28,7 +41,7 @@ def repo(repo_url: str) -> rx.Component:
def code_card(app: dict) -> rx.Component:
return rx.flex(
rx.box(
rx.link(
rx.el.a(
rx.image(
src=app["image_url"],
loading="lazy",
Expand Down Expand Up @@ -88,35 +101,55 @@ def gallery_app_card(app: dict) -> rx.Component:
),
rx.box(
rx.box(
rx.el.h4(
rx.el.h6(
app["title"],
class_name="font-smbold text-slate-12 truncate",
width="100%",
),
rx.text(
app["description"],
class_name="text-slate-10 font-small truncate text-pretty",
width="100%",
),
rx.box(
rx.cond(
"Reflex" in app["author"],
rx.vstack(
rx.box(
rx.text(
"by",
class_name="text-slate-9 font-small",
rx.hstack(
install_command(f"reflex init --template {app['title']}"),
rx.hstack(
repo(app["demo"]),
justify="start",

),
),
width="310px",
max_width="310px",

),
rx.cond(
"Reflex" in app["author"],
rx.box(
rx.text(
"by",
class_name="text-slate-9 font-small",
),
get_icon(icon="badge_logo"),
rx.text(
app["author"],
class_name="text-slate-9 font-small",
),
class_name="flex flex-row items-start gap-1",
),
get_icon(icon="badge_logo"),
rx.text(
app["author"],
f"by {app['author']}",
class_name="text-slate-9 font-small",
),
class_name="flex flex-row items-center gap-1",
),
rx.text(
f"by {app['author']}",
class_name="text-slate-9 font-small",
),
align_items="start",
class_name="brother-john"
),
repo(app["demo"]),


class_name="flex flex-row items-center gap-[6px] justify-between w-full",
),
class_name="flex flex-col justify-between items-start gap-1 p-[0.625rem_0.75rem_0.625rem_0.75rem] w-full h-full",
Expand Down
5 changes: 5 additions & 0 deletions pcweb/pages/gallery/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def gallery_heading() -> rx.Component:
),
class_name="font-md text-balance text-slate-9 -mt-4",
),
rx.text.span(
"Copy the template command and use it during ",
rx.code("reflex init"),
class_name="font-sm text-balance text-slate-9",
),
class_name="section-header",
)

Expand Down
4 changes: 2 additions & 2 deletions templates/api-admin-panel.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: API Admin Panel
title: api_admin_panel
description: "Interactive dashboard for API requests and response visualization"
author: "Reflex"
image: "api-admin-panel.webp"
demo: "https://api-admin-panel.reflex.run/"
source: "https://github.com/reflex-dev/gallery-apps/tree/main/api-admin-panel"
source: "https://github.com/reflex-dev/templates/tree/main/api_admin_panel"
meta: [
{"name": "keywords", "content": "admin panel, api admin panel, reflex admin panel"},
]
Expand Down
10 changes: 3 additions & 7 deletions templates/chat-app.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Chat App
title: reflex-chat
description: "Real-time chat application with multiple rooms using Reflex and ChatGPT"
author: "Reflex"
image: "chat-app.webp"
demo: "https://chat.reflex.run/"
source: "https://github.com/reflex-dev/reflex-examples/tree/main/gpt/gpt"
source: "https://github.com/reflex-dev/reflex-chat"
meta: [
{"name": "keywords", "content": ""},
]
Expand All @@ -18,11 +18,7 @@ The following is a python chat app. It is 100% Python-based, including the UI, a
To run this app locally, install Reflex and run:

```bash
git clone https://github.com/reflex-dev/reflex-chat.git
```

```bash
cd reflex-chat
reflex init --template reflex-chat
```

Set up your OpenAI API key:
Expand Down
3 changes: 2 additions & 1 deletion templates/ci-job.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: CI Job
title: ci_template
description: "CI/CD job dashboard with real-time updates and controls"
author: "Reflex"
image: "cijob.webp"
demo: "https://cijob.reflex.run/"
source: "https://github.com/reflex-dev/templates/tree/main/ci_template"

meta: [
{"name": "keywords", "content": ""},
]
Expand Down
2 changes: 1 addition & 1 deletion templates/customer-app.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Customer Data App
title: customer_data_app
description: "A Reflex app for customer data management with visualizations"
author: "Reflex"
image: "customer-app.webp"
Expand Down
8 changes: 4 additions & 4 deletions templates/dalle.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
title: DALL-E
title: dalle
description: "DALL-E is a Reflex app for generating images using OpenAI's API"
author: "Reflex"
image: "dalle.webp"
demo: "https://dalle.reflex.run/"
source: "https://github.com/reflex-dev/reflex-examples/tree/main/dalle"
source: "https://github.com/reflex-dev/templates/tree/main/dalle"
meta: [
{"name": "keywords", "content": ""},
]
template: "dalle"
---

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

```bash
git clone https://github.com/reflex-dev/reflex-examples.git
cd reflex-examples/ci-job
reflex init --template dalle
```

Set up your OpenAI API key:
Expand Down
6 changes: 4 additions & 2 deletions templates/dashboard.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
title: Dashboard
title: dashboard
description: "Interactive dashboard with real-time data visualization"
author: "Reflex"
image: "dashboard.webp"
demo: "https://dashboard-new.reflex.run/"
source: "https://github.com/reflex-dev/templates/tree/main/dashboard"
meta: [{ "name": "keywords", "content": "" }]
meta: [
{"name": "keywords", "content": ""},
]
---

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.
Expand Down
4 changes: 2 additions & 2 deletions templates/image-gen.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Image Gen
title: ai_image_gen
description: "Generate AI images using Replicate's API"
author: "Reflex"
image: "image-gen.webp"
Expand All @@ -17,7 +17,7 @@ The following is an app that allows you to generate AI images. The current map u
To run this app locally, install Reflex and run:

```bash
reflex init --template image_gen
reflex init --template ai_image_gen
```

To run the app, set the `REPLICATE_API_TOKEN`:
Expand Down
6 changes: 4 additions & 2 deletions templates/llamaindex-app.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: LLamaIndex App
title: reflex-llamaindex-template
description: "A minimal chat app using LLamaIndex"
author: "Reflex"
image: "llamaindex.png"
Expand All @@ -21,9 +21,11 @@ If you plan on deploying your agentic workflow to prod, follow the [llama deploy
To run this app locally, install Reflex and run:

```bash
git clone https://github.com/reflex-dev/reflex-llamaindex-template.git
reflex init --template reflex-llamaindex-template
```



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.

```python
Expand Down
5 changes: 3 additions & 2 deletions templates/nba-app.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: NBA App
title: nba
description: "Interactive NBA app with player stats and live updates"
author: "Reflex"
image: "nba-app.webp"
Expand All @@ -8,6 +8,7 @@ source: "https://github.com/reflex-dev/templates/tree/main/nba"
meta: [
{"name": "keywords", "content": ""},
]
template: "nba"
---

The following is an app that displays NBA player stats from the 2015-2016 season. The table tab allows filtering and live updates. The graph tab shows the relationship between player stats.
Expand All @@ -17,7 +18,7 @@ The following is an app that displays NBA player stats from the 2015-2016 season
To run this app locally, install Reflex and run:

```bash
reflex init --template nba_app
reflex init --template nba
```

To run the app, use:
Expand Down
13 changes: 0 additions & 13 deletions templates/reflex-web.md

This file was deleted.

6 changes: 3 additions & 3 deletions templates/sales-app.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Sales App
title: sales
description: "Sales app with interactive charts and real-time data updates"
author: "Reflex"
image: "sales.webp"
Expand All @@ -10,14 +10,14 @@ meta: [
]
---

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.
The following is a sales app that displays sales data. The table tab allows filtering and live updates. The graph tab shows the relationship between sales data.

## Setup

To run this app locally, install Reflex and run:

```bash
reflex init --template dashboard
reflex init --template sales
```

To run the app, use:
Expand Down