-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Rename the ViewTransitions component to ClientRouter #11980
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
'astro': minor | ||
--- | ||
|
||
ViewTransitions component renamed to ClientRouter | ||
|
||
The `<ViewTransitions />` component has been renamed to `<ClientRouter />`. There are no other changes than the name. The old name will continue to work in Astro 5.x, but will be removed in 6.0. | ||
|
||
This change was done to clarify the role of the component within Astro's View Transitions support. Astro supports View Transitions APIs in a few different ways, and renaming the component makes it more clear that the features you get from the ClientRouter component are slightly different from what you get using the native CSS-based MPA router. | ||
|
||
We still intend to maintain the ClientRouter as before, and it's still important for use-cases that the native support doesn't cover, such as persisting state between pages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/astro/e2e/fixtures/dev-toolbar/src/layout/Layout.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/astro/e2e/fixtures/view-transitions/src/components/AttributedLayout.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
packages/astro/e2e/fixtures/view-transitions/src/components/listener-layout.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
packages/astro/e2e/fixtures/view-transitions/src/pages/abort.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
--- | ||
import { ViewTransitions } from 'astro:transitions'; | ||
import { ClientRouter } from 'astro:transitions'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<ViewTransitions /> | ||
<ClientRouter /> | ||
</head> | ||
<body> | ||
<h1>Abort</h1> | ||
</body> | ||
</html> | ||
<script> | ||
import {navigate } from 'astro:transitions/client'; | ||
import { navigate } from 'astro:transitions/client'; | ||
|
||
document.addEventListener('astro:before-preparation', (e) => { | ||
const originalLoader = e.loader; | ||
e.loader = async () => { | ||
const result = await originalLoader(); | ||
if (e.to.href.endsWith("/two")) { | ||
if (e.to.href.endsWith('/two')) { | ||
// delay loading of /two | ||
await new Promise((resolve) => setTimeout(resolve, 1100)); | ||
} | ||
} | ||
}; | ||
}); | ||
// starts later, but is faster and overtakes the slower navigation | ||
setTimeout(()=>navigate("/one"), 400); | ||
setTimeout(() => navigate('/one'), 400); | ||
// starts now, but is to slow to keep its lead | ||
navigate("/two"); | ||
navigate('/two'); | ||
</script> |
4 changes: 2 additions & 2 deletions
4
packages/astro/e2e/fixtures/view-transitions/src/pages/abort2.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
packages/astro/e2e/fixtures/view-transitions/src/pages/client-load.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
--- | ||
import { ViewTransitions } from "astro:transitions"; | ||
import ClickToNavigate from "../components/ClickToNavigate.jsx" | ||
import { ClientRouter } from 'astro:transitions'; | ||
import ClickToNavigate from '../components/ClickToNavigate.jsx'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<ViewTransitions /> | ||
<ClientRouter /> | ||
</head> | ||
<body> | ||
<ClickToNavigate id="react-client-load-navigate-button" to="/two" client:load/> | ||
<ClickToNavigate id="react-client-load-navigate-button" to="/two" client:load /> | ||
</body> | ||
</html> |
17 changes: 9 additions & 8 deletions
17
packages/astro/e2e/fixtures/view-transitions/src/pages/dialog.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
--- | ||
import { ViewTransitions } from "astro:transitions"; | ||
import { ClientRouter } from 'astro:transitions'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<ViewTransitions /> | ||
<ClientRouter /> | ||
</head> | ||
<body> | ||
<button id="open" onclick="modal.showModal()">Open Modal</button> | ||
<dialog id="modal"> | ||
<form method="dialog"> | ||
<button id="close">Close</button> | ||
</form> | ||
</dialog> | ||
<button id="open" onclick="modal.showModal()">Open Modal</button> | ||
<dialog id="modal"> | ||
<form method="dialog"> | ||
<button id="close">Close</button> | ||
</form> | ||
</dialog> | ||
</body> | ||
</html> |
4 changes: 2 additions & 2 deletions
4
packages/astro/e2e/fixtures/view-transitions/src/pages/form-four.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/astro/e2e/fixtures/view-transitions/src/pages/no-directive-one.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/astro/e2e/fixtures/view-transitions/src/pages/no-directive-two.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 there at all a concern regarding the fact that you still import this from
astro:transitions
? Perhaps it should be exported fromastro/components
now as well and documented as such?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.
Because it's "not real view transitions"? It still uses view transitions; that's still the biggest part of the router. It's not like the other stuff inside
astro:transitions
are not also enhancements to view transitions. This is no different. It's just a rename to clarify that it's an enhancement.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 meant more so in a marketing sense. If we start selling this to users outside of the context of view transitions (e.g. "If you need a client side router, use this") it could be confusing why it's imported from
astro:transitions
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.
It's still pretty deeply tied to view transitions. The
fallback
property is about view transitions. The animations that occur are view transitions. If you wanted to disable the animations you need to dotransition:animate="none"
. It's not a traditional SPA style router and I don't think we should rethink everything just for a rename.