Skip to content

Commit 50cc357

Browse files
committed
useTypesPlugin
1 parent 8c0b28e commit 50cc357

12 files changed

Lines changed: 148 additions & 97 deletions

File tree

package-lock.json

Lines changed: 71 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
},
1111
"devDependencies": {
1212
"@astrojs/check": "^0.9.4",
13-
"@astrojs/starlight": "^0.34.4",
13+
"@astrojs/starlight": "^0.35.1",
1414
"@expressive-code/plugin-collapsible-sections": "^0.41.3",
1515
"@expressive-code/plugin-line-numbers": "^0.41.3",
16-
"@inox-tools/portal-gun": "^1.1.2",
17-
"@playwright/test": "^1.54.0",
18-
"@types/node": "^24.0.12",
16+
"@inox-tools/portal-gun": "^1.2.0",
17+
"@playwright/test": "^1.54.1",
18+
"@types/node": "^24.0.15",
1919
"@vtbag/cam-shaft": "^1.0.6",
2020
"@vtbag/element-crossing": "^1.1.0",
2121
"@vtbag/inspection-chamber": "^1.0.22",
2222
"@vtbag/turn-signal": "^1.3.1",
23-
"@vtbag/utensil-drawer": "^1.2.9",
24-
"astro": "^5.11.0",
23+
"@vtbag/utensil-drawer": "^1.2.11",
24+
"astro": "^5.12.0",
2525
"astro-d2": "^0.8.0",
2626
"astro-og": "^0.3.0",
2727
"astro-vtbot": "^2.1.6",
28+
"postcss-active-view-transition-type": "^0.0.4",
2829
"rehype-autolink-headings": "^7.1.0",
2930
"rehype-external-links": "^3.0.0",
3031
"rehype-slug": "^6.0.0",

postcss.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
plugins: [require("postcss-active-view-transition-type")({ mode: "append" })],
3+
};

src/components/Media.astro

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,30 +79,32 @@
7979
//@ts-ignore
8080
smallMedia.style.viewTransitionClass = "media";
8181

82-
mayStartViewTransition({
83-
update: () => {
84-
dialog.style.viewTransitionName = `dialog`;
85-
smallMedia.style.viewTransitionName = "none";
86-
bigMedia.style.viewTransitionName = "media";
87-
dialog.showModal();
82+
mayStartViewTransition(
83+
{
84+
update: () => {
85+
dialog.style.viewTransitionName = `dialog`;
86+
smallMedia.style.viewTransitionName = "none";
87+
bigMedia.style.viewTransitionName = "media";
88+
dialog.showModal();
89+
},
90+
types: ["media"],
8891
},
89-
types: ["media"],
90-
});
92+
{ useTypesPolyfill: "auto" }
93+
);
9194
dialog.addEventListener(
9295
"click",
9396
() => {
9497
mayStartViewTransition({
95-
update: () => {
96-
bigMedia.style.viewTransitionName = "none";
97-
smallMedia.style.viewTransitionName = "media";
98-
dialog.close();
99-
},
100-
types: ["media"],
101-
})
102-
.finished.finally(() => {
103-
smallMedia.style.viewTransitionName =
104-
dialog.style.viewTransitionName = "none";
105-
});
98+
update: () => {
99+
bigMedia.style.viewTransitionName = "none";
100+
smallMedia.style.viewTransitionName = "media";
101+
dialog.close();
102+
},
103+
types: ["media"],
104+
}, {useTypesPolyfill: 'auto'}).finished.finally(() => {
105+
smallMedia.style.viewTransitionName =
106+
dialog.style.viewTransitionName = "none";
107+
});
106108
},
107109
{ once: true }
108110
);

src/content/docs/basics/javascript.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Skipping the transition means that the pseudo-element tree created by the view t
118118

119119
You can dynamically add or remove view transition types during the view transition by modifying the `types` object. Such changes will directly affect CSS rules that use the `:active-view-transition-type` pseudo-class.
120120

121+
View transition types are a feature of Level 2 of the View Transition API. They [can be polyfilled](/tools/utensil-drawer/#the-postcss-active-view-transition-type-postcss-plugin) if you want to use them with Level 1 implementations.
122+
121123

122124
### Canceling and Chaining
123125

src/content/docs/basics/styling.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ There is an additional pseudo-class that does not take type parameters.
364364

365365
This selector will match the the `:root` element while a view transition is active. You can use this for example to [change the shape of the pointer](/tips/pointer/) during view transitions.
366366

367+
368+
While view transition types are a Level 2 feature, they [can be polyfilled](/tools/utensil-drawer/#the-postcss-active-view-transition-type-postcss-plugin) if you want to use them with Level 1 implementations.
369+
367370
When you navigate forth and back through the pages of this site, you see an example on how types are used to select different animation.
368371

369372
<Steps>

src/content/docs/fwvt/twinkling.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ For the best experience, follow along with your own Starlight site or with the [
7272
Nearly a year ago, I wrote a [step-by-step guide](https://events-3bg.pages.dev/jotter/starlight/guide/) on using Astro's `<ClientRouter />` component (formerly `<ViewTransitions />`) to give a Starlight site that SPA-like look and feel wih view transitions.
7373

7474

75-
**This time things are different:** As you'd expect from `vtbag.dev`, this is not about Astro's client router. We are going browser-native!
75+
**This time things are different:** As you'd expect from `vtbag.dev`, this is not about Astro's client router. We are going browser-native! Works in browsers with native Level 2 view transition support.
76+
7677

7778
The steps we take are not specific to Astro, and some will be old acquaintances from earlier _Fun With View Transitions_ episodes, now applied directly to your Starlight site.
7879

src/content/docs/tips/css.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ One of the main benefits of this pattern is that view transition names are only
130130
This pattern works well in all current browser versions that natively support the View Transition API.
131131
Once Firefox adds native support for Level 1 view transitions, this will likely break [because `:active-view-transition-type` is only available with Level 2 of the API](/basics/levels/#same-document-features-missing-in-level-1).
132132

133-
The Bag offers a [polyfill for view transition types](/tools/utensil-drawer/#usetypespolyfill-always--never) that allows you to use them even with browsers that support only Level 1 of the View Transition API.
133+
The Bag provides a [polyfill for view transition types](/tools/utensil-drawer/#usetypespolyfill-always--never) that allows you to use them even with browsers that support only Level 1 of the View Transition API.
134134
:::
135135

136136
#### Auto-generated View Transition Names

0 commit comments

Comments
 (0)