Skip to content

Commit 59b5562

Browse files
authored
Allow the Image component to get transitions (#7836)
* Images and view transitions * Upgrade compiler * Adding a changeset
1 parent 9fe1089 commit 59b5562

File tree

9 files changed

+44
-9
lines changed

9 files changed

+44
-9
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Upgrade compiler to bring in Image view transition support

packages/astro/e2e/fixtures/view-transitions/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ import { defineConfig } from 'astro/config';
44
export default defineConfig({
55
experimental: {
66
viewTransitions: true,
7+
assets: true,
78
},
89
});
330 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
import { Image } from 'astro:assets';
3+
import penguinSrc from '../assets/penguin.jpg';
4+
---
5+
<Image src={penguinSrc} alt="a cute penguin" height="400" transition:name="penguin" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
import Layout from '../components/Layout.astro';
3+
import Penguin from '../components/Penguin.astro';
4+
---
5+
<Layout>
6+
<Penguin />
7+
<p id="image-one">Page 1</p>
8+
<a id="click-two" href="/image-two">go to 2</a>
9+
</Layout>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
import Layout from '../components/Layout.astro';
3+
import Penguin from '../components/Penguin.astro';
4+
---
5+
<Layout>
6+
<p id="image-two">Page 2</p>
7+
<Penguin />
8+
</Layout>

packages/astro/e2e/view-transitions.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,11 @@ test.describe('View Transitions', () => {
182182
await page.click('#click-one');
183183
await expect(p, 'should have content').toHaveText('Page 1');
184184
});
185+
186+
test('<Image /> component forwards transitions to the <img>', async ({ page, astro }) => {
187+
// Go to page 1
188+
await page.goto(astro.resolveUrl('/image-one'));
189+
const img = page.locator('img[data-astro-transition-scope]');
190+
await expect(img).toBeVisible('The image tag should have the transition scope attribute.');
191+
});
185192
});

packages/astro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"test:e2e:match": "playwright test -g"
116116
},
117117
"dependencies": {
118-
"@astrojs/compiler": "^1.6.0",
118+
"@astrojs/compiler": "^1.6.3",
119119
"@astrojs/internal-helpers": "^0.1.1",
120120
"@astrojs/language-server": "^1.0.0",
121121
"@astrojs/markdown-remark": "^2.2.1",

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)