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

PlutoHTMLElement and PlutoHTMLElementList #1687

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dralletje
Copy link
Collaborator

@dralletje dralletje commented Nov 25, 2021

What

This replaces PlutoRunner.DivElement with two new primitives: PlutoHTMLElement and PlutoHTMLElementList.

Why

The problem with DivElement are

  1. It's always a div
  2. There is no way to have keyed children

How

I try to fix that by

  1. Making PlutoHTMLElement very generic.
    It basically takes all the same arguments as a Preact.createElement call and passes these on directly.
    It does some special handling for children, more on that later.
  2. Making PlutoHTMLElementList.
    PlutoHTMLElementList takes a Dict{String,Any} (!!) where every key is the key prop the child will get on the Preact side.
    This allows for creating changing lists that preserve identity.

It does contain a polyfill for DivElement based on PlutoHTMLElement, so it doesn't break current PlutoUI.Experimental.Layout uses.

Todo

  • Make sure elements refresh when cell is explicitly re-run (currently some inputs keep their value)
  • Experiment and design the way the identities get preserved
    (I don't really get yet what parts we want and can make reactive)
  • What to do about children!!! As I mentioned before, we apply special handling to the children prop, which we wrap in Pluto-show-thingies. One problem is, (p)react components often use different props for renderable stuff (title, body, icon). Is there a way we can figure out what props we should wrap in Pluto-show-thingies?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2021

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="PlutoHTMLElement-and-PlutoHTMLElementList")
julia> using Pluto

@fonsp
Copy link
Owner

fonsp commented Nov 27, 2021

@dralletje Can you make a TODO list?

@dralletje
Copy link
Collaborator Author

From @fonsp during a call: Why are there two primitives rather than one.
This is a good question, I'll ponder it a bit. I still think we need two primitives, but they might be different ones.

@fonsp
Copy link
Owner

fonsp commented Dec 21, 2021

Can you make the changes to the preact import on main instead?

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

Successfully merging this pull request may close these issues.

2 participants