-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
__version__ = "0.0.1" | ||
|
||
from .core.components import button, button_group, autocomplete, checkbox, select | ||
from .core.layout import grid | ||
from .core.layout import grid, container, box | ||
|
||
__all__ = [ | ||
"button", | ||
"button_group", | ||
"autocomplete", | ||
"checkbox", | ||
"select", | ||
"grid" | ||
"grid", | ||
"container", | ||
"box" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
) | ||
|
||
md_grid = export(_js_module, "MDGrid") | ||
md_container = export(_js_module, "MDContainer") | ||
md_box = export(_js_module, "MDBox") | ||
|
||
@component | ||
def grid(*children: VdomChild, attrs: Any = {}): | ||
|
@@ -23,3 +25,26 @@ def grid(*children: VdomChild, attrs: Any = {}): | |
children_items += (c, ) | ||
|
||
return md_grid(attrs, children_items) | ||
|
||
@component | ||
def container(*children: VdomChild, attrs: Any = {}): | ||
children_items = () | ||
for c in children: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Archmonger
Collaborator
|
||
if isinstance(c, Component): | ||
children_items += (c.render(), ) | ||
else: | ||
children_items += (c, ) | ||
|
||
return md_container(attrs, children_items) | ||
|
||
@component | ||
def box(*children: VdomChild, attrs: Any = {}): | ||
children_items = () | ||
for c in children: | ||
if isinstance(c, Component): | ||
children_items += (c.render(), ) | ||
else: | ||
children_items += (c, ) | ||
|
||
return md_box(attrs, children_items) | ||
|
So, @Archmonger , at first time when creating a custom component like that i had problem when it needed to render multiple components as children. I didnt understood completly the work that reactpy core do when handling a custom component like that, but at the end this for loop over children solved the question.
But moving forward a new problem regarding this implementation showed up. When the custom component receives a generator he doesnt render it.
So, in the example above the grid component receives a generator instead of a Component object, and at the page appears something like
<generator object app.<locals>.<genexpr> at 0x7fc28ae431b0>
.Whats the correct way to proceed here?