Skip to content

Commit b3b658b

Browse files
committed
template for highlight pages
1 parent 718f3e4 commit b3b658b

File tree

8 files changed

+78
-30
lines changed

8 files changed

+78
-30
lines changed

pcweb/components/docpage/sidebar/sidebar_items/learn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def get_sidebar_items_learn():
1818
getting_started.project_structure,
1919
getting_started.dashboard_tutorial,
2020
getting_started.chatapp_tutorial,
21-
getting_started.use_cases,
2221
],
2322
),
2423
create_item(

pcweb/pages/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pcweb.route import Route
22
from .affiliates import affiliates as affiliates
33
from .databricks import databricks as databricks
4+
from .use_cases import use_cases as use_cases
45
from .blog import blog_routes
56
from .customers.data.customers import customers_routes
67
from .customers.landing import customers as customers

pcweb/pages/customers/views/footer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
LINKEDIN_URL,
1919
)
2020

21+
from pcweb.pages.framework.views.footer_index import dark_mode_toggle
2122

2223
def footer_link(text: str, href: str) -> rx.Component:
2324
return rx.link(
@@ -148,7 +149,9 @@ def footer_customer() -> rx.Component:
148149
footer_link("Common Errors", errors.path),
149150
footer_link("Roadmap", ROADMAP_URL),
150151
footer_link("Forum", FORUM_URL),
151-
footer_link("Use Cases", "/docs/ai-builder/overview/use-cases"),
152+
footer_link("Use Cases", "/use-cases"),
153+
rx.box(class_name="grow"),
154+
dark_mode_toggle(),
152155
],
153156
class_name="!row-span-3 !border-t-0",
154157
),
Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,14 @@
1-
2-
import reflex as rx
3-
41
import flexdown
2+
import reflex as rx
53
from pcweb.flexdown import xd2 as xd
6-
from pcweb.components.docpage.navbar import navbar
7-
from pcweb.pages.customers.views.footer import footer_customer
8-
from pcweb.views.bottom_section.bottom_section import bottom_section
9-
from pcweb.pages.framework.index_colors import index_colors
104

5+
from pcweb.templates.highlightpage import highlight_page
116

127
document = flexdown.parse_file("pcweb/pages/databricks/databricks.md")
138

14-
def databricks_content():
9+
def databricks_content() -> rx.Component:
1510
return rx.box(xd.render(document, document.filename))
1611

17-
18-
@rx.page(route="/databricks", title="Databricks - Reflex")
19-
def databricks():
20-
return rx.box(
21-
rx.box(
22-
index_colors(),
23-
navbar(),
24-
rx.el.main(
25-
databricks_content(),
26-
rx.box(class_name="flex-grow"),
27-
class_name="w-full z-[1] relative flex flex-col justify-center mx-auto max-w-[640px] lg:px-0 px-4 pb-20",
28-
),
29-
rx.box(class_name="h-[1px] bg-slate-3 w-full"),
30-
bottom_section(),
31-
footer_customer(),
32-
class_name="relative flex flex-col justify-start items-center w-full h-full min-h-screen font-instrument-sans gap-4 mx-auto max-w-[64.19rem] lg:border-x border-slate-3 pt-24 lg:pt-48",
33-
),
34-
class_name="relative overflow-hidden",
35-
)
12+
@highlight_page(route="/databricks", title="Databricks - Reflex")
13+
def databricks_page():
14+
return databricks_content()
File renamed without changes.

pcweb/pages/use_cases/use_cases.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import flexdown
2+
import reflex as rx
3+
from pcweb.flexdown import xd2 as xd
4+
5+
from pcweb.templates.highlightpage import highlight_page
6+
7+
document = flexdown.parse_file("pcweb/pages/use_cases/use_cases.md")
8+
9+
def use_cases_content() -> rx.Component:
10+
return rx.box(xd.render(document, document.filename))
11+
12+
@highlight_page(route="/use-cases", title="Use Cases - Reflex")
13+
def use_cases_page():
14+
return use_cases_content()

pcweb/templates/highlightpage.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import reflex as rx
2+
3+
from reflex.event import EventType
4+
from typing import Callable, Any
5+
from pcweb.components.docpage.navbar import navbar
6+
from pcweb.pages.customers.views.footer import footer_customer
7+
from pcweb.views.bottom_section.bottom_section import bottom_section
8+
from pcweb.pages.framework.index_colors import index_colors
9+
10+
def highlight_page(
11+
route: str | None = None,
12+
title: str | None = None,
13+
image: str | None = None,
14+
description: str | None = None,
15+
meta: list[Any] | None = None,
16+
script_tags: list[Any] | None = None,
17+
on_load: EventType[()] | None = None,
18+
) -> Callable[[Callable[[], rx.Component]], Callable[[], rx.Component]]:
19+
"""Decorator that wraps a page's main content in a consistent layout and registers it with rx.page."""
20+
21+
def decorator(page_func: Callable[[], rx.Component]) -> Callable[[], rx.Component]:
22+
@rx.page(
23+
route=route,
24+
title=title,
25+
image=image,
26+
description=description,
27+
meta=meta,
28+
script_tags=script_tags,
29+
on_load=on_load,
30+
)
31+
def wrapped_page() -> rx.Component:
32+
content = page_func()
33+
return rx.box(
34+
rx.box(
35+
index_colors(),
36+
navbar(),
37+
rx.el.main(
38+
content,
39+
rx.box(class_name="flex-grow"),
40+
class_name="w-full z-[1] relative flex flex-col justify-center mx-auto max-w-[640px] lg:px-0 px-4 pb-20",
41+
),
42+
rx.box(class_name="h-[1px] bg-slate-3 w-full"),
43+
bottom_section(),
44+
footer_customer(),
45+
class_name="relative flex flex-col justify-start items-center w-full h-full min-h-screen font-instrument-sans gap-4 mx-auto max-w-[64.19rem] lg:border-x border-slate-3 pt-24 lg:pt-48",
46+
),
47+
class_name="relative overflow-hidden",
48+
)
49+
50+
return wrapped_page
51+
52+
return decorator

pcweb/views/footer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def footer() -> rx.Component:
174174
footer_link("Roadmap", ROADMAP_URL),
175175
footer_link("Forum", FORUM_URL),
176176
footer_link("Affiliates", "/affiliates"),
177-
footer_link("Use Cases", "/docs/ai-builder/overview/use-cases"),
177+
footer_link("Use Cases", "/use-cases"),
178178
rx.box(class_name="grow"),
179179
dark_mode_toggle(),
180180
],

0 commit comments

Comments
 (0)