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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework horizontal spacing code to better support embedded notebooks #2903

Merged
merged 2 commits into from
Apr 23, 2024

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Apr 22, 2024

After 4 years, I finally found the CSS code that I wanted 馃挍

  • On very large screen, I want the notebook to be centered in the screen.
  • On medium screens, I want the notebook on the left, with any free space on the right (for the Live Docs panel).
  • On small screens, the notebook should take up all space.

Before, I implemented this with media queries, to detect each of the three situations. But this does not look good when the notebook is embedded on a site with a sidebar on the left, like https://plutojl.org/en/docs/abstractplutodingetjes/

image

Here, I would want the notebook to be pushed to the left, to make space for widgets (like to ToC on the right). But the media queries won't work, because the window width is not the editor width. And container queries are still not implemented.

Solution! I took a long train and found this solution:

pluto-editor main {
    align-self: flex-end;
    margin-right: max(
        /* First part: push away from the right */ min(/* taking up all free space */ (100% - (700px + 25px + 6px)), /* but don't do this more than */ 500px)
            /* Second part: center it */ max(0px, (100% - (700px + 25px + 6px)) / 2)
    );
}

Because it uses 100% in the calculations, it's relative to the editor (without container queries!). And all the min maxes make all the situations work.

Two videos of the new behaviour, one with a simulated sidebar on the left.

Schermopname.2024-04-22.om.20.08.56.mov
Schermopname.2024-04-22.om.20.09.16.mov

@fonsp fonsp added frontend Concerning the HTML editor publishing Notebooks as static documents on the web labels Apr 22, 2024
Copy link
Contributor

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="editor-horizontal-spacing-rework")
julia> using Pluto

@fonsp fonsp merged commit d1f5d88 into main Apr 23, 2024
2 checks passed
@fonsp fonsp deleted the editor-horizontal-spacing-rework branch April 23, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Concerning the HTML editor publishing Notebooks as static documents on the web
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant