diff --git a/packages/ui/src/components/Molecules/PageTransition.tsx b/packages/ui/src/components/Molecules/PageTransition.tsx new file mode 100644 index 000000000..72ca7569b --- /dev/null +++ b/packages/ui/src/components/Molecules/PageTransition.tsx @@ -0,0 +1,33 @@ +import { motion, useReducedMotion } from 'framer-motion'; +import React, { PropsWithChildren, useEffect } from 'react'; + +import { Messages, readMessages } from './Messages'; + +export function PageTransition({ children }: PropsWithChildren) { + const [messages, setMessages] = React.useState>([]); + useEffect(() => { + setMessages(readMessages()); + }, []); + return useReducedMotion() ? ( +
+ + {children} +
+ ) : ( + + + {children} + + ); +} diff --git a/packages/ui/src/components/Routes/ContentHub.tsx b/packages/ui/src/components/Routes/ContentHub.tsx index dfda46723..3f0ec2704 100644 --- a/packages/ui/src/components/Routes/ContentHub.tsx +++ b/packages/ui/src/components/Routes/ContentHub.tsx @@ -1,7 +1,12 @@ import React from 'react'; +import { PageTransition } from '../Molecules/PageTransition'; import { ContentHub as ContentHubOrganism } from '../Organisms/ContentHub'; export function ContentHub(props: { pageSize: number }) { - return ; + return ( + + + + ); } diff --git a/packages/ui/src/components/Routes/Frame.tsx b/packages/ui/src/components/Routes/Frame.tsx index 1e9727df3..9c9d7b738 100644 --- a/packages/ui/src/components/Routes/Frame.tsx +++ b/packages/ui/src/components/Routes/Frame.tsx @@ -1,6 +1,6 @@ -import React, { ComponentProps, PropsWithChildren, useEffect } from 'react'; +import { AnimatePresence, useReducedMotion } from 'framer-motion'; +import React, { ComponentProps, PropsWithChildren } from 'react'; -import { Messages, readMessages } from '../Molecules/Messages'; import { Footer } from '../Organisms/Footer'; import Header from '../Organisms/Header'; @@ -10,16 +10,17 @@ export function Frame( footer: ComponentProps; }>, ) { - const [messages, setMessages] = React.useState>([]); - useEffect(() => { - setMessages(readMessages()); - }, []); return (
- - {props.children} + {useReducedMotion() ? ( + <>{props.children} + ) : ( + + {props.children} + + )}
diff --git a/packages/ui/src/components/Routes/Page.tsx b/packages/ui/src/components/Routes/Page.tsx index 331905ebe..89959af5e 100644 --- a/packages/ui/src/components/Routes/Page.tsx +++ b/packages/ui/src/components/Routes/Page.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { isTruthy } from '../../utils/isTruthy'; import { UnreachableCaseError } from '../../utils/unreachable-case-error'; +import { PageTransition } from '../Molecules/PageTransition'; import { BlockForm } from '../Organisms/PageContent/BlockForm'; import { BlockMarkup } from '../Organisms/PageContent/BlockMarkup'; import { BlockMedia } from '../Organisms/PageContent/BlockMedia'; @@ -10,26 +11,28 @@ import { PageHero } from '../Organisms/PageHero'; export function Page(props: { page: PageFragment }) { return ( -
- {props.page.hero ? : null} -
-
-
- {props.page?.content?.filter(isTruthy).map((block, index) => { - switch (block.__typename) { - case 'BlockMedia': - return ; - case 'BlockMarkup': - return ; - case 'BlockForm': - return ; - default: - throw new UnreachableCaseError(block); - } - })} + +
+ {props.page.hero ? : null} +
+
+
+ {props.page?.content?.filter(isTruthy).map((block, index) => { + switch (block.__typename) { + case 'BlockMedia': + return ; + case 'BlockMarkup': + return ; + case 'BlockForm': + return ; + default: + throw new UnreachableCaseError(block); + } + })} +
-
+ ); } diff --git a/tests/e2e/specs/links.spec.ts b/tests/e2e/specs/links.spec.ts index 949052f5b..82e7e94d4 100644 --- a/tests/e2e/specs/links.spec.ts +++ b/tests/e2e/specs/links.spec.ts @@ -9,10 +9,12 @@ test.describe('links', () => { await page.getByRole('link', { name: 'link to page' }).click(); await page.waitForURL(websiteUrl('/en/privacy')); - await page.goBack(); + await page.goto(websiteUrl('/en/page-links')); const downloadPromise = page.waitForEvent('download'); - await page.getByRole('link', { name: 'link to file' }).click(); + await page + .getByRole('link', { name: 'link to file', includeHidden: true }) + .click(); const download = await downloadPromise; expect(download.url()).toBe( websiteUrl('/sites/default/files/2023-04/document_docx.docx'),