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

ExperimentalLayout.hbox creates horizontal overflow and scrollbar if combining plot output with widget #278

Open
schlichtanders opened this issue Nov 17, 2023 · 5 comments

Comments

@schlichtanders
Copy link

schlichtanders commented Nov 17, 2023

Hello,

I would like to use the ExperimentalLayout feature, but am stuck at how to force everything into Pluto's standard cell width.

While at least the plot is responsive (I can test it by making the window width smaller and see it getting smaller and smaller) the combined hbox does put the plot in full cell-width next to the UI elements.

image

This example does not have the scrollbar, but it also shows that the resizing does not work. If I am decreasing the overall browser width, finall the markdown ui element does disappear completely.

Every help is highly appreciated.

@holomorphism
Copy link
Contributor

Hi, @schlichtanders.

Is it correct that your problem is that the plot is too large in ExperimentalLayout.hbox and the elements on the left are crushed?
(I am not a native English speaker, sorry if I am misreading you)

I think the easiest workaround is to specify a size option for the plot. Look at the following image. (The width is specified as 400 pixels with the size=(400,300) option of the plot function)
img01

However, if the width of the drop-down menu is wide, even if you reduce the width of the plot, it may be cut off as shown in the image above.

In that case, you may want to use ExperimentalLayout.vbox instead of ExperimentalLayout.hbox. However, when I tried vbox, it always seemed to expand the plot to the full width of the cell. After a little trial and error, I added the following to the style option of vbox, and it looks natural.
img02

PlutoUI.ExperimentalLayout.vbox(
	[choose, plot(rand(10); size=(500,300))];
	style=Dict(
		"justify-content"=>"center",
		"max-width"=>"fit-content",
		"margin-left"=>"auto",
		"margin-right"=>"auto",
	)
)

@schlichtanders
Copy link
Author

Thank you for your response.

My problem is that I don't understand why the plot correctly resizes, when the overall pluto width shrinks, but does not resizes when inside an hbox.

Hardcoding pixels is no option for me - I need a responsive layout. (Like Pluto itself is). I thought hbox is actually intended to be responsive - then this looks like kind of a bug in hbox.

@holomorphism
Copy link
Contributor

Ah, that's what you meant. Sorry.

@fonsp
Copy link
Member

fonsp commented Nov 20, 2023

Hey! You can wrap the plot in a div with flex: 1 1 auto, i.e. replace [chooser, plot] with

[
	chooser,
	PlutoUI.ExperimentalLayout.Div([plot]; style=Dict("flex" => "1 1 auto")),
]

Maybe this should be the default? I find it a bit difficult to decide on the API of ExpeirmentalLayout, maybe people should just have easy access to the original flex CSS API with no extras...

@schlichtanders
Copy link
Author

It is a bit off topic, but to give comment to your last question about the design of ExperimentalLayout:

I build a little hypertext wrapper which replaces divs with ExperimentalLayout.Div
It needs to parse the string, which feels like an overhead, but on the other side it is probably fine.

This way you get an intuitive html interface. The only downside is that only Divs are supported so far, but especially when using Markdown, the table tags would be super useful as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants