diff --git a/.gitignore b/.gitignore index 9759259da12..fcbf7ebc860 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ completions.json .history *not_in_use* /packages/dnb-ui-lib +**/test-results # pkm npm-debug.log* diff --git a/packages/dnb-design-system-portal/src/e2e/fullscreen.spec.ts b/packages/dnb-design-system-portal/src/e2e/fullscreen.spec.ts index e6a73baa1e1..61a0fe81c23 100644 --- a/packages/dnb-design-system-portal/src/e2e/fullscreen.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/fullscreen.spec.ts @@ -10,15 +10,14 @@ test.describe('Fullscreen', () => { }) => { await page.waitForSelector('nav#portal-sidebar-menu') - await page.click('button[title="Fullscreen"]') + await page.click('a.fullscreen') - await page.waitForSelector('nav#portal-sidebar-menu', { - state: 'hidden', - }) - - const currentURL = page.url() - expect(currentURL).toContain( + expect(page.url()).toContain( '/uilib/components/button/demos/?fullscreen', ) + + await page.click('a.fullscreen') + + expect(page.url()).toContain('/uilib/components/button/demos/') }) }) diff --git a/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts b/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts index e5696ead4b4..331201b1364 100644 --- a/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts @@ -12,7 +12,6 @@ test.describe('Responsiveness', () => { test('change viewport size should add sidebar menu', async ({ page, - baseURL, }) => { await expect(page.locator('nav#portal-sidebar-menu')).toHaveCSS( 'display', @@ -35,7 +34,7 @@ test.describe('Responsiveness', () => { state: 'attached', }) - expect(page.url()).toBe(`${baseURL}/uilib/about-the-lib/`) + expect(page.url()).toContain('/uilib/about-the-lib/') await expect(page.locator('h1')).toContainText('#About the library') }) }) diff --git a/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js b/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js index e2c3a89e819..6811b5f0704 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js +++ b/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js @@ -25,6 +25,7 @@ import { portalHeaderWrapperStyle, hideSidebarToggleButtonStyle, } from './StickyMenuBar.module.scss' +import { Link } from '../tags/Anchor' export default function StickyMenuBar({ hideSidebarToggleButton, @@ -66,6 +67,7 @@ export default function StickyMenuBar({ text="Home" title="Eufemia main sections" href="/" + element={Link} icon="chevron_left" icon_position="left" /> diff --git a/packages/dnb-design-system-portal/src/shared/parts/PortalStyle.scss b/packages/dnb-design-system-portal/src/shared/parts/PortalStyle.scss index 57f2a35d32a..2525a40b8c0 100644 --- a/packages/dnb-design-system-portal/src/shared/parts/PortalStyle.scss +++ b/packages/dnb-design-system-portal/src/shared/parts/PortalStyle.scss @@ -104,3 +104,9 @@ html[show-dev-grid] .dev-grid { .lh-32 { line-height: calc(var(--line-height-basis) + 0.5rem); /* 2rem */ } + +// Make the home => pages animation +.home-background ul, +#portal-sidebar-menu { + view-transition-name: home; +} diff --git a/packages/dnb-design-system-portal/src/shared/tags/Anchor.tsx b/packages/dnb-design-system-portal/src/shared/tags/Anchor.tsx index 713c01a1f83..5b798fa90c7 100644 --- a/packages/dnb-design-system-portal/src/shared/tags/Anchor.tsx +++ b/packages/dnb-design-system-portal/src/shared/tags/Anchor.tsx @@ -11,6 +11,7 @@ import { } from '@dnb/eufemia/src/components/Anchor' import { GatsbyLinkProps, Link as GatsbyLink } from 'gatsby' import { ElementIsType } from '@dnb/eufemia/src/elements/Element' +import { startPageTransition } from './Transition' export type AnchorProps = Props & Omit< @@ -22,7 +23,7 @@ export type AnchorProps = Props & > const PortalLink = React.forwardRef(function Link( - { href, ...props }: AnchorProps, + { href, onClick = null, ...props }: AnchorProps, ref, ) { return ( @@ -30,8 +31,16 @@ const PortalLink = React.forwardRef(function Link( to={href} ref={ref} {...(props as Omit, 'ref' | 'onClick'>)} + onClick={clickHandler} /> ) + + function clickHandler(event: React.MouseEvent) { + startPageTransition() + if (onClick) { + onClick(event) + } + } }) export { PortalLink as Link } diff --git a/packages/dnb-design-system-portal/src/shared/tags/Intro.tsx b/packages/dnb-design-system-portal/src/shared/tags/Intro.tsx index c27c58f4740..f1d8c7e1d21 100644 --- a/packages/dnb-design-system-portal/src/shared/tags/Intro.tsx +++ b/packages/dnb-design-system-portal/src/shared/tags/Intro.tsx @@ -7,8 +7,10 @@ import React from 'react' import { Global, css } from '@emotion/react' import PropTypes from 'prop-types' import { navigate } from 'gatsby' -import { Link, Button, Space } from '@dnb/eufemia/src' +import { Anchor, Button, Space } from '@dnb/eufemia/src' import { wrapperStyle, innerStyle, footerStyle } from './Intro.module.scss' +import { startPageTransition } from './Transition' +import { Link } from './Anchor' const ref = React.createRef() const Intro = ({ children }) => { @@ -17,6 +19,7 @@ const Intro = ({ children }) => { if (/textarea|input/i.test(document.activeElement.tagName)) { return } + startPageTransition() try { if (e.key === 'ArrowRight' && ref && ref.current) { const elem = ref.current.querySelector('a[href*="/intro"]') @@ -61,13 +64,14 @@ export const IntroFooter = ({ href, text }) => ( } `} /> -