Skip to content

Commit

Permalink
Allow the Image component to get transitions (#7836)
Browse files Browse the repository at this point in the history
* Images and view transitions

* Upgrade compiler

* Adding a changeset
  • Loading branch information
matthewp committed Jul 27, 2023
1 parent 9fe1089 commit 59b5562
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-glasses-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Upgrade compiler to bring in Image view transition support
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import { defineConfig } from 'astro/config';
export default defineConfig({
experimental: {
viewTransitions: true,
assets: true,
},
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
import { Image } from 'astro:assets';
import penguinSrc from '../assets/penguin.jpg';
---
<Image src={penguinSrc} alt="a cute penguin" height="400" transition:name="penguin" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
import Layout from '../components/Layout.astro';
import Penguin from '../components/Penguin.astro';
---
<Layout>
<Penguin />
<p id="image-one">Page 1</p>
<a id="click-two" href="/image-two">go to 2</a>
</Layout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
import Layout from '../components/Layout.astro';
import Penguin from '../components/Penguin.astro';
---
<Layout>
<p id="image-two">Page 2</p>
<Penguin />
</Layout>
7 changes: 7 additions & 0 deletions packages/astro/e2e/view-transitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,11 @@ test.describe('View Transitions', () => {
await page.click('#click-one');
await expect(p, 'should have content').toHaveText('Page 1');
});

test('<Image /> component forwards transitions to the <img>', async ({ page, astro }) => {
// Go to page 1
await page.goto(astro.resolveUrl('/image-one'));
const img = page.locator('img[data-astro-transition-scope]');
await expect(img).toBeVisible('The image tag should have the transition scope attribute.');
});
});
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"test:e2e:match": "playwright test -g"
},
"dependencies": {
"@astrojs/compiler": "^1.6.0",
"@astrojs/compiler": "^1.6.3",
"@astrojs/internal-helpers": "^0.1.1",
"@astrojs/language-server": "^1.0.0",
"@astrojs/markdown-remark": "^2.2.1",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 59b5562

Please sign in to comment.