Skip to content

Commit d3ea180

Browse files
authored
Merge branch 'main' into ahmad/blog-post
2 parents c106bca + 6ac4492 commit d3ea180

File tree

11 files changed

+94
-32
lines changed

11 files changed

+94
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
### **✨ The open-source framework to build and deploy web apps - no Javascript required. ✨**
88
[![PyPI version](https://badge.fury.io/py/reflex.svg)](https://badge.fury.io/py/reflex)
9-
![tests](https://github.com/pynecone-io/pynecone/actions/workflows/integration.yml/badge.svg)
9+
[![tests](https://github.com/reflex-dev/reflex-web/actions/workflows/integration_tests.yml/badge.svg)](https://github.com/reflex-dev/reflex-web/actions/workflows/integration_tests.yml)
1010
![versions](https://img.shields.io/pypi/pyversions/reflex.svg)
1111
[![Documentation](https://img.shields.io/badge/Documentation%20-Introduction%20-%20%23007ec6)](https://reflex.dev/docs/getting-started/introduction/)
1212
[![Discord](https://img.shields.io/discord/1029853095527727165?color=%237289da&label=Discord)](https://discord.gg/T5WSbC2YtQ)

docs/ai_builder/app_lifecycle/general.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,3 @@ rx.el.div(render_image())
4646

4747
- **Delete App**
4848
Permanently remove an app you no longer need. **Warning:** This action cannot be undone.
49-
50-
## Common Use Cases
51-
52-
- **Keep Apps Organized**
53-
Rename apps to make them easier to find in your workspace.
54-
55-
- **Integration Reference**
56-
Use the App ID when connecting your app to other tools or APIs.
57-
58-
- **Clean Up Workspace**
59-
Delete outdated or test apps to keep your workspace tidy.

docs/ai_builder/features/ide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Reflex Build includes a **powerful, in-browser IDE** built on **Monaco Editor**,
66
<iframe
77
width="100%"
88
height="400"
9-
src="https://www.youtube.com/embed/aW0ZefEC3SU"
9+
src="https://www.youtube.com/embed/UAj9vUweQ5g"
1010
title="Reflex Build - IDE"
1111
frameborder="0"
1212
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"

docs/ai_builder/features/interaction_modes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Use Chat mode when you want to **ask questions** or get **advice without alterin
5555
## When to Use Each
5656

5757
- **Build a new feature or component** → Use **Agent**
58-
- **Set up integrations (DB, API, etc.)** → Use **Agent**
58+
- **Set up integrations (DB, etc.)** → Use **Agent**
5959
- **Understand Reflex concepts** → Use **Chat**
6060
- **Debug an error in your code** → Start with **Chat**, then switch to **Agent**
6161
- **Explore ideas or best practices** → Use **Chat**

docs/wrapping-react/props.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,49 @@ class EventHandlerComponent(MyBaseComponent):
154154

155155
```md alert info
156156
# Custom event specs have a few use case where they are particularly useful. If the event returns non-serializable data, you can filter them out so the event can be sent to the backend. You can also use them to transform the data before sending it to the backend.
157+
```
158+
159+
### Emulating Event Handler Behavior Outside a Component
160+
161+
In some instances, you may need to replicate the special behavior applied to
162+
event handlers from outside of a component context. For example if the component
163+
to be wrapped requires event callbacks passed in a dictionary, this can be
164+
achieved by directly instantiating an `EventChain`.
165+
166+
A real-world example of this is the `onEvents` prop of
167+
[`echarts-for-react`](https://www.npmjs.com/package/echarts-for-react) library,
168+
which, unlike a normal event handler, expects a mapping of event handlers like:
169+
170+
```javascript
171+
<ReactECharts
172+
option={this.getOption()}
173+
style={{ height: '300px', width: '100%' }}
174+
onEvents={{
175+
'click': this.onChartClick,
176+
'legendselectchanged': this.onChartLegendselectchanged
177+
}}
178+
/>
179+
```
180+
181+
To achieve this in Reflex, you can create an explicit `EventChain` for each
182+
event handler:
183+
184+
```python
185+
@classmethod
186+
def create(cls, *children, **props):
187+
on_events = props.pop("on_events", {})
188+
189+
event_chains = {}
190+
for event_name, handler in on_events.items():
191+
# Convert the EventHandler/EventSpec/lambda to an EventChain
192+
event_chains[event_name] = rx.EventChain.create(
193+
handler,
194+
args_spec=rx.event.no_args_event_spec,
195+
key=event_name,
196+
)
197+
if on_events:
198+
props["on_events"] = event_chains
199+
200+
# Create the component instance
201+
return super().create(*children, **props)
157202
```

pcweb/components/docpage/navbar/navbar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def link_item(name: str, url: str, active_str: str = ""):
106106
}
107107
},
108108
class_name=common_cn + rx.cond(active, active_cn, unactive_cn),
109+
on_click=SidebarState.set_sidebar_index(0)
109110
)
110111

111112

@@ -455,7 +456,7 @@ def new_component_section() -> rx.Component:
455456
nav_menu.item(
456457
link_item(
457458
"AI Builder",
458-
ai_builder_pages.overview.what_is_reflex_build.path,
459+
ai_builder_pages.overview.best_practices.path,
459460
"builder",
460461
),
461462
),

pcweb/components/docpage/sidebar/sidebar.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def filter_out_non_sidebar_items(items: list[SideBarBase]) -> list[SideBarItem]:
286286

287287
def sidebar_category(name: str, url: str, icon: str, index: int):
288288
return rx.el.li(
289-
rx.link(
289+
rx.el.div(
290290
rx.box(
291291
rx.box(
292292
rx.box(
@@ -314,17 +314,20 @@ def sidebar_category(name: str, url: str, icon: str, index: int):
314314
SidebarState.sidebar_index == index, " visible", " hidden"
315315
),
316316
),
317-
class_name="flex flex-row justify-between items-center hover:bg-slate-3 p-[0.5rem_1rem_0.5rem_0.5rem] rounded-2xl w-full transition-bg self-stretch"
317+
class_name="cursor-pointer flex flex-row justify-between items-center hover:bg-slate-3 p-[0.5rem_1rem_0.5rem_0.5rem] rounded-2xl w-full transition-bg self-stretch"
318318
+ rx.cond(
319319
SidebarState.sidebar_index == index,
320320
" bg-slate-3",
321321
" bg-transparent",
322322
),
323323
),
324-
on_click=SidebarState.set_sidebar_index(index),
325-
class_name="w-full text-slate-9 hover:!text-slate-9",
326-
underline="none",
327-
href=url,
324+
rx.el.a(
325+
to=url,
326+
on_click=rx.prevent_default,
327+
class_name="inset-0 absolute z-[-1]",
328+
),
329+
class_name="w-full text-slate-9 hover:!text-slate-9 relative",
330+
on_click=[SidebarState.set_sidebar_index(index), rx.redirect(url)],
328331
),
329332
class_name="w-full",
330333
)
@@ -417,13 +420,13 @@ def sidebar_comp(
417420
rx.el.ul(
418421
sidebar_category(
419422
"Learn",
420-
"/docs/ai-builder/overview/best-practices",
423+
ai_builder_pages.overview.best_practices.path,
421424
"bot",
422425
0,
423426
),
424427
sidebar_category(
425428
"MCP",
426-
"/docs/ai-builder/integrations/mcp-overview",
429+
ai_builder_pages.integrations.mcp_overview.path,
427430
"plug",
428431
1,
429432
),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def create_item(route: Route, children=None):
1717
.replace("Cli", "CLI")
1818
.replace("Ai", "AI")
1919
.replace("Ide", "IDE")
20+
.replace("Mcp", "MCP")
21+
2022
)
2123
return SideBarItem(
2224
names=name, alt_name_for_next_prev=alt_name_for_next_prev, link=url

pcweb/components/docpage/sidebar/state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ class SideBarSection(SideBarBase):
3939
class SidebarState(rx.State):
4040
_sidebar_index: int = -1
4141

42+
@rx.event(temporal=True)
4243
def set_sidebar_index(self, num) -> int:
4344
self._sidebar_index = num
4445

45-
@rx.var(cache=True, initial_value=-1)
46+
@rx.var(initial_value=-1)
4647
def sidebar_index(self) -> int:
4748
route = self.router.page.path
4849
if self._sidebar_index < 0:

pcweb/pages/docs/apiref.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
rx.Base,
1010
rx.Component,
1111
rx.ComponentState,
12-
rx.Config,
12+
(rx.Config, rx.config.BaseConfig),
1313
rx.event.Event,
1414
rx.event.EventHandler,
1515
rx.event.EventSpec,
@@ -26,9 +26,17 @@
2626

2727
pages = []
2828
for module in modules:
29+
if isinstance(module, tuple):
30+
module, *extra_modules = module
31+
extra_fields = []
32+
for extra_module in extra_modules:
33+
s_extra = Source(module=extra_module)
34+
extra_fields.extend(s_extra.get_fields())
35+
else:
36+
extra_fields = None
2937
s = Source(module=module)
3038
name = module.__name__.lower()
31-
docs = generate_docs(name, s)
39+
docs = generate_docs(name, s, extra_fields=extra_fields)
3240
title = name.replace("_", " ").title()
3341
page_data = docpage(f"/docs/api-reference/{name}/", title)(docs)
3442
page_data.title = page_data.title.split("·")[0].strip()

0 commit comments

Comments
 (0)