Pluto.jl icon indicating copy to clipboard operation
Pluto.jl copied to clipboard

PlutoHTMLElement and PlutoHTMLElementList

Open dralletje opened this issue 4 years ago • 4 comments

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?

dralletje avatar Nov 25 '21 18:11 dralletje

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

github-actions[bot] avatar Nov 25 '21 18:11 github-actions[bot]

@dralletje Can you make a TODO list?

fonsp avatar Nov 27 '21 14:11 fonsp

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.

dralletje avatar Dec 15 '21 00:12 dralletje

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

fonsp avatar Dec 21 '21 21:12 fonsp