-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
💡 RFC: client:media
should be composable with :load
, :visible
, and :idle
#877
Comments
Possible syntax:
Use-case:
RFC Discussion:
RFC Call:
|
I think the |
True. |
The answer for the syntax is in the issue title :) It’s not composable if you have to use a single attribute. Separate attributes with their own respective semantics allow composition, and can be applied with a well-understood evaluation order (inside out). Probably with some special casing internally to work around issues already present (various nesting scenarios). |
I agree with @eyelidlessness that separate attributes are needed. I think we might not need special syntax here, if there are multiple attributes then use this combined behavior. Just as an implementation note that how hydrators work currently it's not an easy change to make. Probably this part will need a major refactor to enable this feature. |
Given hydration is already async (it depends on at least one import), couldn't you conceivably wrap each hydration method in a |
I'll play devils advocate: why do we need separate attributes? Do we have any use-cases outlined? Could we instead make them default to |
@FredKSchott some hydrators like <Component client:media="(min-width: 800px)" client:interaction="focus" />
<!-- If combined? -->
<Component client:media:interaction="(min-width: 800px)|focus" |
My point was: what if we intentionally say that we don't support composing two hydrator directives? Given how complex this might be to refactor, do we have a clear use-case where a user needs this feature? |
@FredKSchott Your comment here has uses cases: #877 (comment) I think I'm still not understanding you though, as I currently read your comment to mean to not implement this RFC at all... |
Yup! Hence the "devils advocate" preface 😈 . The use-case that I outlined above is a pretty classic "nice to have". Given the complexity to implement this RFC, is it worth the effort & complexity? |
Oh ok, so I was understanding! I would think that "is it worth it" would be quite valid if we are talking new syntax, but if we are not then I side on it being worth implementing. Not a priority for the core team, but I have no objection to someone else taking it on. If the complexity question comes from my comment, I didn't mean to scare off people. Just wanted to note that the current implementation assumes 1-to-1 so it would have to be refactored. It's the usual complexity when moving from 1 to N things, so more effort than a quick lunch time PR. Or I could be wrong and this is super easy to do! |
So, rather than a devil’s advocate argument… what if this is the wrong solution to a problem, and reframing the problem may lead to a better solution? Currently Astro addresses a limited but growing range of hydration options. Composition is just one of many potential ways people might want to expand that selection. At a certain point expansion becomes so general you arrive at… the general solution: Obviously that’s less ergonomic than I still think the nesting case should be addressed, last I checked a |
I'd be in favor of a simple "if any of these are true, hydrate" composing syntax as I suggested, plus an API for defining functions for loading directives that would handle more complex cases. Would it be |
Okay now I'm all in on "this should be an arbitrary function". I was interpreting composition as |
Actually, I've forgotten my original ask: that it is
😨 |
Wait a second... shouldn't |
The idea of implementing your own hydrator has come up a few times, which I think is what you're suggesting @eyelidlessness. This is indeed a more powerful solution. We probably need an RFC to talk about a specific solution to that. |
@matthewp yeah it could be another RFC, but I'm suggesting it may also be the appropriate solution to this one. |
Hey everyone! Our current RFC process is beginning to break down at this size, with over 50 open RFCs currently in the "discussing" stage. A growing community is a great problem to have, but our ability to give you RFC feedback has suffered as a result. In an effort to improve our RFC process, we are making some changes to better organize things. From now on, all RFCs will live in a standalone repo: https://github.com/withastro/rfcs This allows us to do three things: 1) Use threaded discussions for high-level ideas and improvements, without necessarily requiring an implementation for every idea. 2) Improve the quality of our RFC template and the speed/quality of all feedback. 3) Support inline comments and explicit approvals on RFCs, via a new Pull Request review process. We hope that this new process leads to better RFC weekly calls and faster feedback on your RFCs from maintainers. More detail can be found in the new RFC repo README. We can't automatically convert this issue to an RFC in the new repo because new RFC template is more detailed that this one. But, you can still continue this discussion in the new repo by creating a new Discussion in the RFC repo and copy-and-pasting this post (and any relevant follow-up comments) into it. Discussions are available for high-level ideas and suggestions without the requirement of a full implementation proposal. Then, when you are ready to propose (or re-propose) an implementation for feedback and approval, you can create a new RFC using the new RFC template. More detail about how to do this can be found in the new RFC repo README. Thanks for your patience as we attempt to improve things for both authors and reviewers. If you have any questions, don't hesitate to reach out on Discord. https://astro.build/chat |
Background & Motivation
I want to be able to load certain components only at a certain breakpoint while also selecting when it loads, which currently
client:media
does not allow, as it defaults to eagerly loading.Proposed Solution
Possible solutions
This could potentially compose similar to tailwindcss directives.
Alternatives considered
Risks, downsides, and/or tradeoffs
Open Questions
Detailed Design
No response
Help make it happen!
The text was updated successfully, but these errors were encountered: