-
Notifications
You must be signed in to change notification settings - Fork 146
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
Complex Layout with multiple "set of children" #870
Comments
Hi again, After some digging into the solara repo, I have two potential approaches, on how proceed with the question above:
@solara.component
def Layout(children=[]):
# there will only be 1 child, which is the Page()
return children[0] Then we could define a custom "Wrapper" component, something like @solara.component
WrapperLayout(side_panel=None, main_panel=None):
.... The above would define the whole layout. Then we can just pass components do this wrapper component, and combined with the "empty" layout above, it should do the trick. I am not sure if this approach is valid.. At first I thought that there is another "layer" through with the
More easily shown as a pycafe example What I do not like about this.. is well I do not quite understand how it works, and whether it is an appropriate approach to be used with many routes and many simultanious users. But I "understand" it enough to adopt it for my usecase and make a "complex" layout that can be filled with various components (which was the original quest). I would very much appreciate some pointers in which of the two approaches above is recommended for use with solara (if any!), or and I approaching this in an entirely wrong manner. Thank you - I hope this makes sense. P.S.: As I said, I do not understand this |
That might actually container your children, but indeed there might be an extra Div around it, which you saw. It is probably this Div If you print out the children of a Layout, you should see:
In the case of your above PyCafe app:
will print out:
Yes, perfectly valid, you'd need to do a bit of work to handle routing yourself, but not a bad idea.
Also valid, the This portal was needed to support a 'streamlit-style' sidebar, which makes it easier to people to switch from streamlit. I think 1 is easier to read/understand. 2. is a bit more easy to use, at the cost of some hidden complexity/magic. Feel free to pick you poison :) Let me know if anything is still unclear. |
Hi! I think option 2 is magic i've never seen before,and so powerful..allows for some crazy things. Scary to use since it is not public, but maybe you should consider making it if it is stable enough. Thanks! (Feel free to close this) |
Hi,
I need to create a more complex layout, that requires passing different children (component) to different parts (components) of the layout. I have made this simple pycafe example illustrating what my intention is: I want to pass a component to the "Left" part of the layout, and a different component to the "right" part of the Layout.
Here is the pycafe example
Currently, the component passed to the layout is used in both the "Left" and "Right" side of the layout. I would like essentially to be able to pass (in whatever way) the
Left
andRight
component to be on the same page.What I tried:
Router
object, and then select the relevant stuff inside the layout component. That does not work as aDiv
class is recieved by the time data arrives in theLayout
class/component.My current understanding (looking at the Layout documentation and the few layout implementations of solara) is that there is a single Div (child?) that is passed to the layout. Is there a way we can interface to that, or otherwise intercept it to allow for different type of input (say multiple components?).
I hope the question is clear, if not I would be happy to elaborate. Thank you!!
The text was updated successfully, but these errors were encountered: