From fb2fa3392dc7bc58e5794299c53ebaab70cc7256 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 12 Sep 2024 12:46:16 -0400 Subject: [PATCH 1/3] Rename the ViewTransitions component to ClientRouter --- .changeset/hip-wombats-exercise.md | 11 +++++++++++ examples/starlog/src/components/BaseHead.astro | 4 ++-- .../view-transitions/src/layouts/Layout.astro | 4 ++-- ...iewTransitions.astro => ClientRouter.astro} | 0 packages/astro/client.d.ts | 8 ++++++-- .../dev-toolbar/src/layout/Layout.astro | 4 ++-- .../src/components/AttributedLayout.astro | 4 ++-- .../src/components/Layout.astro | 18 ++++++++++-------- .../src/components/listener-layout.astro | 16 ++++++++-------- .../view-transitions/src/pages/abort.astro | 15 ++++++++------- .../view-transitions/src/pages/abort2.astro | 4 ++-- .../src/pages/client-load.astro | 9 +++++---- .../view-transitions/src/pages/dialog.astro | 17 +++++++++-------- .../view-transitions/src/pages/form-four.astro | 4 ++-- .../src/pages/half-baked.astro | 7 ++++--- .../src/pages/no-directive-one.astro | 4 ++-- .../src/pages/no-directive-two.astro | 4 ++-- packages/astro/e2e/view-transitions.test.js | 18 +++++++++--------- packages/astro/src/transitions/router.ts | 2 +- .../src/transitions/vite-plugin-transitions.ts | 7 +++++-- packages/astro/src/types/public/config.ts | 4 ++-- .../ticketing-example/src/layouts/Layout.astro | 4 ++-- 22 files changed, 96 insertions(+), 72 deletions(-) create mode 100644 .changeset/hip-wombats-exercise.md rename packages/astro/{components/ViewTransitions.astro => ClientRouter.astro} (100%) diff --git a/.changeset/hip-wombats-exercise.md b/.changeset/hip-wombats-exercise.md new file mode 100644 index 000000000000..d30d37cbb6bc --- /dev/null +++ b/.changeset/hip-wombats-exercise.md @@ -0,0 +1,11 @@ +--- +'astro': minor +--- + +ViewTransitions component renamed to ClientRouter + +The `` component has been renamed to ``. 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. diff --git a/examples/starlog/src/components/BaseHead.astro b/examples/starlog/src/components/BaseHead.astro index bb2c64ee8b81..34aff98fbf78 100644 --- a/examples/starlog/src/components/BaseHead.astro +++ b/examples/starlog/src/components/BaseHead.astro @@ -1,5 +1,5 @@ --- -import { ViewTransitions } from 'astro:transitions'; +import { ClientRouter } from 'astro:transitions'; import SEO, { type Props as SEOProps } from './SEO.astro'; import { SiteTitle, SiteDescription } from '../consts'; @@ -17,4 +17,4 @@ const { title = SiteTitle, name = SiteTitle, description = SiteDescription, ...s rel="stylesheet" /> - + diff --git a/examples/view-transitions/src/layouts/Layout.astro b/examples/view-transitions/src/layouts/Layout.astro index 39a73bca0981..fee2c9ef1e1e 100644 --- a/examples/view-transitions/src/layouts/Layout.astro +++ b/examples/view-transitions/src/layouts/Layout.astro @@ -1,6 +1,6 @@ --- import '../styles/styles.css'; -import { ViewTransitions } from 'astro:transitions'; +import { ClientRouter } from 'astro:transitions'; import Footer from '../components/Footer.astro'; import Nav from '../components/Nav.astro'; @@ -20,7 +20,7 @@ const { title } = Astro.props as Props; {title} - +
diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/ClientRouter.astro similarity index 100% rename from packages/astro/components/ViewTransitions.astro rename to packages/astro/ClientRouter.astro diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index ee91b09bb71c..e828124a1062 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -116,8 +116,12 @@ declare module 'astro:transitions' { export const fade: TransitionModule['fade']; export const createAnimationScope: TransitionModule['createAnimationScope']; - type ViewTransitionsModule = typeof import('./components/ViewTransitions.astro'); - export const ViewTransitions: ViewTransitionsModule['default']; + type ClientRouterModule = typeof import('./components/ClientRouter.astro'); + /** + * @deprecated The ViewTransitions component has been renamed to ClientRouter + */ + export const ViewTransitions: ClientRouterModule['default']; + export const ClientRouter: ClientRouterModule['default']; } declare module 'astro:transitions/client' { diff --git a/packages/astro/e2e/fixtures/dev-toolbar/src/layout/Layout.astro b/packages/astro/e2e/fixtures/dev-toolbar/src/layout/Layout.astro index 35c96e3e0281..780ada07b747 100644 --- a/packages/astro/e2e/fixtures/dev-toolbar/src/layout/Layout.astro +++ b/packages/astro/e2e/fixtures/dev-toolbar/src/layout/Layout.astro @@ -1,10 +1,10 @@ --- -import { ViewTransitions } from 'astro:transitions'; +import { ClientRouter } from 'astro:transitions'; --- View Transition Test - + - - - - - From add38f42517e6a4d204813bb76308fc7e431b32c Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 12 Sep 2024 16:35:46 -0400 Subject: [PATCH 3/3] Move it --- packages/astro/components/ClientRouter.astro | 149 +++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 packages/astro/components/ClientRouter.astro diff --git a/packages/astro/components/ClientRouter.astro b/packages/astro/components/ClientRouter.astro new file mode 100644 index 000000000000..8bda7b780fa0 --- /dev/null +++ b/packages/astro/components/ClientRouter.astro @@ -0,0 +1,149 @@ +--- +type Fallback = 'none' | 'animate' | 'swap'; + +export interface Props { + fallback?: Fallback; + /** @deprecated handleForms is enabled by default in Astro 4.0 + * + * Set `data-astro-reload` on your form to opt-out of the default behavior. + */ + handleForms?: boolean; +} + +const { fallback = 'animate' } = Astro.props; +--- + + + + +