-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(astro:transitions): add missing docs for available public APIs #12734
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
base: main
Are you sure you want to change the base?
fix(astro:transitions): add missing docs for available public APIs #12734
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
| <div transition:animate={slide({ duration: '0.4s' })} /> | ||
| ``` | ||
|
|
||
| ### `createAnimationScope()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section and the code snippet might need a review from someone used to view transitions (and Astro's implementation). This is my understanding but maybe I'm wrong here. 😅
Also, the code snippet is a bit heavy, but if I understand correctly, we need all of this to have a working example?
| <Since v="3.6.0" /> | ||
| </p> | ||
|
|
||
| A constant to avoid writing the `astro:before-preparation` event name in plain text when you define an event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably for Sarah: I struggled a bit to describe the constants (this one and the followings). I'm not sure this is the best description, but I think those are useful to document.
| - Anything else some other listener might have set. | ||
| The direction of the transition. This can be a predefined [`Direction`](#direction) or anything else some other listener might have set. | ||
|
|
||
| In the [`astro:before-preparation` event](#astrobefore-swap-event), the value is writable and accepts any `string`. In the [`astro:before-swap` event](#astrobefore-swap-event), the value is readonly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it true ("some other listener might have set")? I'm not familiar enough with view transitions but from my understanding, this can only be defined inside an astro:before-preparation event so the current description might be confusing?
I reused the wording we had, and added a sentence below to clarify that, although common to both, this attribute does not have the same purpose depending on the event.
|
|
||
| **Type:** `FormData | undefined` | ||
| **Type:** `FormData | undefined`<br /> | ||
| **Available in:** [`astro:before-preparation` event](#astrobefore-preparation-event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if this should be plain text or part of the API block, but I think this is helpful to add this information for someone getting there from a direct link, an AI, etc.
|
Anyone is welcome to review this PR, but I'll ping @matthewp and @martrapp because they know better the view transitions API. If one of you two has the time to check the accuracy of the new sections this would be helpful! No rush! Context: Some imports weren't documented, at least in the reference page. I added docs for them and fixed some types/since while I was there. The details is available in the first post. You're free to check the whole PR, but your help is especially useful for Also, is there a reason for the |
|
Hi @ArmandPhilippot 👋🏼 thank you for taking care and fixing! I'm afraid, some of these are long forgotten youthful mistakes and which we should mark them as deprecated:
|
|
Thanks for the feedback, Martin! Well, even if we end up not documenting them because we prefer to deprecate them, this allows us to identify what we should clean up in a future version! The same thing happened with |
Good question, that never really stood out to me. @matthewp?
Yes, you are right, this can only be changed in a listener for Details: For links and form submission, direction is automatically set to While normal navigation is Your |
|
Armand feel free to create a new issue on the main repo and assign it to the v6 milestone once you know what we should deprecated/remove! |
Description (required)
Updates
astro:transitionsreference to:<Since />in<ClientRouter />(added in v5, Rename the ViewTransitions component to ClientRouter astro#11980)transitionEnabledOnThisPagetypeinfois typed asanyand this matches what we describe ("arbitrary data").directionis typed asstring(becausestringis wider thanDirection) and usingDirectionwas a bit confusing given the description ("anything else").Type:/<Since />for "Lifecycle events"fallbackas available prop for<ClientRouter />(hidden in the ToC)getFallback()createAnimationScope,isTransitionBeforePreparationEvent,isTransitionBeforeSwapEvent,TRANSITION_BEFORE_PREPARATION,TRANSITION_AFTER_PREPARATION,TRANSITION_BEFORE_SWAP,TRANSITION_AFTER_SWAP,TRANSITION_PAGE_LOAD,type NavigationTypeString,type TransitionBeforePreparationEvent,type TransitionBeforeSwapEventtype Directionandtype Fallbackadded in API for clientside router astro#8571<ReadMore />around existing contentUpdates "View Transitions" guide to:
navigate()options with a link (we already document them, the same way, in the reference)history optionslinkNot documented
ClientRouterModule,TransitionModulefromastro:transitions: although importable those are internal typesEventModule,TransitionRouterModule,TransitionSwapFunctionModulefromastro:transitions/client: although importable those are internal typestype Options: I think it makes more sense to details the properties undernavigate()so I wasn't sure how to document the type. I left it in the available imports fromastro:transitions/clientthough.TransitionAnimation,TransitionAnimationPair,TransitionAnimationValue,TransitionDirectionalAnimationstypes (currently partially displayed in the guide) because they are exported fromastro, notastro:transitions.Related issues & labels (optional)
add new content,improve or update documentation