Replies: 2 comments 1 reply
-
|
I agree it would be nice to formalize this. I use this technique in almost every project, and do it differently every time (but not yet with |
Beta Was this translation helpful? Give feedback.
-
Frames
This feature is one of my biggest ambitions and also my personal nemesis. I have spent more time thinking about this than any other feature. There have been 5 attempts to design an API for this, and 2 abandoned implementation attempts. I'm currently working on more managable things, but here are my incomplete thoughts for anyone interested: What content can be shown in a frame?The most ambitious layer feature was that multiple copies of an web app can run on multiple layers, and that content does not need to know whether they're used on the root page, or in an overlay. I think the same should apply here. Any content that can now be loaded into an overlay should also be containable by a frame. Can we use frames for subinteractions?I think so, for the same reason. We would need to decide what happens when a frame is accepted or dismissed. We cannot "close" a frame like we do with overlays. A default behavior may be to restore their original content. We might need a way to override this default. Can frames be nested?Probably? Otherwise we would have rules about what kind of content works in a frame. Is there isolation between frames?I think so. A frame shouldn't be able to accidentally see or change elements from another frame unless explicitly stated with an I'm not sure whether is ever necessary to target arbitrary frames on the layer (through a selector?), or only its parent and children. Probably the latter? Is there isolation between nested frames?Child frames shouldn't be able to accidentally see or change elements from their parent frame unless explicitly stated with an I'm undecided whether parent frames should be able to see elements from their children. If we isolate children from their parents in both directions, the child frame's element itself must still be part of the parent frame, or the parent could never delete a child frame from itself. Is any layer automatically considered a "frame"?Probably? Can frames update history?Probably not, unless the frame is itself a layer? Must frame containers have unique selectors?No, this would violate the ambition to use any content for a frame or layer. It should be possible to load any selector into a frame, or to use default main targets when no selector is given. This is currently not possible with Turbo Frames, where each frame needs a unique ID and every response must contain a How would a JavaScript API to work with frames look like?We would at least need functions to:
How does this affect existing APIs?Frame isolation would affect all functionality that works with selectors and elements. So pretty much everything. Solving this requires a huge design and implementation effort. When layers were introduced I went to every single function and thought how they should work with layer isolation. In most cases the new behavior I decided on was:
This allowed us to keep simple APIs like However, we cannot easily have a similar function While we do have a reference element when the user follows an Lots of soul searching required here. Can we have a pretty and unified APIs that works for both layers and frames?I haven't come up with one, but I think we need this. Content should not need to know whether it's running on the root page, in an overlay, or in a frame. E.g. if the user asks to accept or dismiss the current "scope" it should accept either layer or frame. On the Javascript I'm unsure whether this could all be merged into the Lots of soul searching required here. Alternatives to frames
A similar feature is that fragment placement considers interaction origin. For example:
It's not isolated like layers are, but for some use cases it's enough. I used this heavily in the demo's task list. Lazy-loading content
I think this would be a great addition which I've often implemented through custom compilers. Unpoly usually attempts to retain basic functionality without JavaScript, so this would probably look like a link that follows itself automatically. Something like this? <div class="menu">
<a href="/expensive-menu" up-autofollow up-target=".menu">Menu</a>
</div> Maybe such an link would replace its own element if no It should also be possible to delay loading until the frame scrolls into the viewport. I think htmx and Turbo can do this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! This is a bit of a meandering train of thought but hopefully it makes sense...
I was originally going to propose a feature, something like "
up-lazy" or "up-deferred", where an element could be marked as immediately triggering a second request to the server on page load.An example of where this might be useful: say you have a "dashboard" page which contains multiple components (charts, metrics etc), some of which require some slightly heavy computation on the server to generate. Rather than having the user wait for the entire page to load, you could instead send the "shell" of the page (the structure, but with empty divs in place of the expensive-to-calculate metrics), and then have the expensive metrics loaded in with separate HTTP requests.
You can sort-of simulate this by using
<div id="expensive-metric" up-poll up-interval="0" up-source="/expensive-metric/"></div>, and then have/expensive-metric/return a page containing a div with a matchingidbut withoutup-pollorup-interval, so the "polling" stops as soon as it arrives in the DOM. This works but feels a little hacky, so I was thinking something like<div up-lazy up-source="/expensive-metric/"></div>might be nicer.(This is roughly equivalent to
<div hx-get="/expensive-metric/" hx-trigger="load"></div>in htmx).However...
This got me thinking about scoped navigation. What if I wanted the lazily-loaded content to include a form, which could then be submitted "within" the containing
<div>? What if I wanted to be able to navigate further, or wanted a "refresh" button within the element?This reminded me a bit of Turbo Frames from Hotwire.
But then I realised Unpoly kind-of already has this functionality: layers!
I'm not sure how this would look syntax-wise, but what about the concept of an "inline" layer? A way of marking a div in the page (with no special structure or styling) as being a layer? A few things would need to be added (ie the concept of loading the markup for the layer on page load, rather than as a result of user interaction) but I think a lot of the concepts are otherwise transferable.
Of course it might be that I'm missing something and this is already possible!
Anyway, thanks for Unpoly and keep up the good work.
Beta Was this translation helpful? Give feedback.
All reactions