diff --git a/assets/css/components.css b/assets/css/components.css index c14831f..c5be0be 100644 --- a/assets/css/components.css +++ b/assets/css/components.css @@ -135,10 +135,40 @@ footer a { } .chrnx-site-footer__site a { + position: relative; + display: inline-flex; + align-items: center; + min-height: 45px; color: var(--chrnx-text); text-decoration: none; } +.chrnx-site-footer__site a::after { + position: absolute; + right: 0.1rem; + bottom: 0.2rem; + left: 0.1rem; + height: 2px; + border-radius: 999px; + background: currentcolor; + content: ""; + opacity: 0; + transform: scaleX(0.35); + transform-origin: center; +} + +.chrnx-site-footer__site a:hover, +.chrnx-site-footer__site a:focus-visible { + color: var(--chrnx-green); + text-decoration: none; +} + +.chrnx-site-footer__site a:hover::after, +.chrnx-site-footer__site a:focus-visible::after { + opacity: 1; + transform: scaleX(1); +} + .chrnx-site-footer__credit, .chrnx-site-footer__line { color: var(--chrnx-muted); diff --git a/tests/e2e/navigation.spec.mjs b/tests/e2e/navigation.spec.mjs index 0ec5ff6..2584475 100644 --- a/tests/e2e/navigation.spec.mjs +++ b/tests/e2e/navigation.spec.mjs @@ -231,6 +231,69 @@ test.describe( 'site navigation shell', () => { } ); } + for ( const theme of [ 'light', 'dark' ] ) { + test( `${ theme } footer site link has hover and focus affordances`, async ( { page } ) => { + await page.setViewportSize( { width: 1280, height: 800 } ); + await page.goto( '/' ); + await page.evaluate( ( value ) => localStorage.setItem( 'chrnx-theme', value ), theme ); + await page.goto( '/music/' ); + + const siteLink = page.locator( '.chrnx-site-footer__site a' ); + const resting = await siteLink.evaluate( ( element ) => { + const style = window.getComputedStyle( element ); + const marker = window.getComputedStyle( element, '::after' ); + return { + color: style.color, + decoration: style.textDecorationLine, + markerContent: marker.content, + markerOpacity: Number.parseFloat( marker.opacity ), + }; + } ); + expect( resting.decoration ).toBe( 'none' ); + expect( resting.markerContent ).not.toBe( 'none' ); + expect( resting.markerOpacity ).toBe( 0 ); + + await siteLink.hover(); + const hovered = await siteLink.evaluate( ( element ) => { + const style = window.getComputedStyle( element ); + const marker = window.getComputedStyle( element, '::after' ); + const footer = window.getComputedStyle( element.closest( 'footer' ) ); + return { + color: style.color, + decoration: style.textDecorationLine, + markerHeight: Number.parseFloat( marker.height ), + markerOpacity: Number.parseFloat( marker.opacity ), + surface: footer.backgroundColor, + }; + } ); + expect( hovered.color ).not.toBe( resting.color ); + expect( hovered.decoration ).toBe( 'none' ); + expect( hovered.markerHeight ).toBeGreaterThanOrEqual( 2 ); + expect( hovered.markerOpacity ).toBe( 1 ); + expect( contrastRatio( hovered.color, hovered.surface ) ).toBeGreaterThanOrEqual( 4.5 ); + + await page.mouse.move( 0, 0 ); + await siteLink.focus(); + const focused = await siteLink.evaluate( ( element ) => { + const style = window.getComputedStyle( element ); + const marker = window.getComputedStyle( element, '::after' ); + const footer = window.getComputedStyle( element.closest( 'footer' ) ); + return { + color: style.color, + boxShadow: style.boxShadow, + markerOpacity: Number.parseFloat( marker.opacity ), + surface: footer.backgroundColor, + targetHeight: element.getBoundingClientRect().height, + }; + } ); + expect( focused.color ).not.toBe( resting.color ); + expect( focused.boxShadow ).not.toBe( 'none' ); + expect( focused.markerOpacity ).toBe( 1 ); + expect( contrastRatio( focused.color, focused.surface ) ).toBeGreaterThanOrEqual( 4.5 ); + expect( focused.targetHeight ).toBeGreaterThanOrEqual( 44 ); + } ); + } + test( 'desktop has a stable accessible header, approved local brand, and compact footer', async ( { page, }, testInfo ) => {