BS-014 Implement accepted responsive BortStack footer

This commit is contained in:
rob
2026-11-11 15:34:49 +00:00
parent 5bfb128e94
commit 26605771ff
61 changed files with 465 additions and 38 deletions
+48
View File
@@ -0,0 +1,48 @@
import AxeBuilder from '@axe-core/playwright'
import { expect, test } from '@playwright/test'
for (const theme of ['dark', 'light']) {
test(`${theme} footer identity, navigation and accessibility on public routes`, async ({ page }) => {
await page.addInitScript(theme => localStorage.setItem('bortstack-theme', theme), theme)
for (const path of ['/', '/services', '/about', '/contact', '/projects', '/projects/example', '/privacy']) {
await page.goto(path)
const footer = page.getByRole('contentinfo')
await expect(footer).toContainText('BortStack')
await expect(footer).not.toContainText(/roborto/i)
await expect(footer.getByText('Navigation', { exact: true })).toBeVisible()
await expect(footer.getByRole('link')).toHaveCount(5)
await expect(footer.getByRole('img')).toHaveCount(0)
await expect(footer).toContainText('Software, websites and integrations built around your business.')
for (const [name, href] of [['Services', '/services'], ['Projects', '/projects'], ['About', '/about'], ['Contact', '/contact'], ['Privacy', '/privacy']]) {
await expect(footer.getByRole('link', { name, exact: true })).toHaveAttribute('href', href)
}
expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
}
const footer = page.getByRole('contentinfo')
await footer.getByRole('link', { name: 'Contact', exact: true }).focus()
await page.keyboard.press('Enter')
await expect(page).toHaveURL(/\/contact$/)
await footer.getByRole('link', { name: 'Privacy', exact: true }).focus()
await page.keyboard.press('Enter')
await expect(page).toHaveURL(/\/privacy$/)
expect((await new AxeBuilder({ page }).include('footer').analyze()).violations).toEqual([])
})
}
for (const width of [1440, 768, 375, 320]) {
test(`footer follows showcase navigation layout at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 })
await page.goto('/')
const links = page.getByRole('navigation', { name: 'Footer navigation' }).getByRole('link')
const boxes = await Promise.all((await links.all()).map(link => link.boundingBox()))
expect(boxes).toHaveLength(4)
if (width >= 768) {
expect(Math.max(...boxes.map(box => box.y)) - Math.min(...boxes.map(box => box.y))).toBeLessThan(2)
} else {
expect(Math.abs(boxes[0].y - boxes[1].y)).toBeLessThan(2)
expect(boxes[2].y).toBeGreaterThan(boxes[0].y)
expect(Math.abs(boxes[2].y - boxes[3].y)).toBeLessThan(2)
}
expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
})
}
+17 -9
View File
@@ -1,20 +1,28 @@
import { Container } from "react-bootstrap";
import { NavLink } from "react-router-dom";
import { site } from "../../config/site";
import styles from "./Footer.module.scss";
export default function Footer() {
return <footer className={styles.footer}>
<Container>
<div className={styles.footerRow}>
<p className={styles.copyright}>&copy; {new Date().getFullYear()} BortStack</p>
<nav className={styles.links} aria-label="Footer navigation">
<NavLink to="/contact">Contact</NavLink>
<NavLink to="/privacy">Privacy</NavLink>
<div className={styles.mainRow}>
<div className={styles.identity}>
<p className={styles.name}>Bort<span>Stack</span></p>
<p className={styles.description}>Software, websites and integrations built around your business.</p>
</div>
<nav className={styles.navigation} aria-label="Footer navigation">
<p className={styles.navigationHeading}>Navigation</p>
<div className={styles.links}>
<NavLink to="/services">Services</NavLink>
<NavLink to="/projects">Projects</NavLink>
<NavLink to="/about">About</NavLink>
<NavLink to="/contact">Contact</NavLink>
</div>
</nav>
<a href={site.developer.url} aria-label={site.developer.linkLabel} rel="noreferrer" className={styles.developerSlot}>
<img src={site.developer.logoPath} alt={site.developer.name} className={styles.developerLogo} />
</a>
</div>
<div className={styles.legalRow}>
<p className={styles.copyright}>&copy; {new Date().getFullYear()} BortStack</p>
<NavLink className={styles.privacy} to="/privacy">Privacy</NavLink>
</div>
</Container>
</footer>;
+54 -6
View File
@@ -1,8 +1,56 @@
.footer { padding-block: 10px; color: var(--site-muted); font-size: 10px; background: var(--site-bg); }
.footer {
--footer-line: color-mix(in srgb, var(--bs-steel-blue) 70%, var(--site-text));
margin: 0 24px 24px;
padding-block: 28px 16px;
border: 1px solid var(--footer-line);
border-radius: 18px;
color: var(--site-text);
background: linear-gradient(115deg, var(--site-surface), color-mix(in srgb, var(--site-bg) 65%, var(--site-surface)));
}
.footer :global(.container) { width: calc(100% - 112px); max-width: 1280px; padding-inline: 0; }
.footerRow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; }
.links { display: flex; gap: 18px; a { color: var(--site-muted); text-decoration: none; } a:hover { color: var(--site-link); } }
.developerSlot { display: inline-flex; border-radius: 2px; padding: 3px 5px; background: #F5F7FA; }
.developerLogo { display: block; width: 76px; height: auto; }
.mainRow { display: grid; grid-template-columns: 39% 1fr; padding-bottom: 24px; }
.identity { padding-right: 32px; }
.name {
margin: -3px 0 8px; font-size: 44px; font-weight: 700; line-height: 1.12; letter-spacing: -.045em;
span { color: var(--site-link); }
}
.description { max-width: 33ch; margin: 0; font-size: 18px; line-height: 1.45; }
.navigation { min-width: 0; border-left: 1px solid var(--footer-line); padding-left: 48px; }
.navigationHeading {
display: flex; align-items: center; gap: 20px; margin: 4px 0 10px;
color: var(--site-link); font-size: 14px; font-weight: 700; letter-spacing: .09em; line-height: 1.4; text-transform: uppercase;
&::after { content: ''; flex: 1; height: 1px; background: var(--footer-line); }
}
.links { display: flex; justify-content: space-between; gap: 8px 20px; padding-right: 14%; }
.links a, .privacy {
display: inline-flex; align-items: center; min-height: 44px; color: var(--site-text); text-decoration: none;
&:hover, &:focus-visible { color: var(--site-link); text-decoration: underline; }
}
.links a { font-size: 18px; line-height: 1.5; }
.legalRow {
display: flex; justify-content: space-between; align-items: center; gap: 12px 24px;
border-top: 1px solid var(--footer-line); padding-top: 10px; font-size: 14px;
}
.copyright { margin: 0; }
@media (max-width: 767.98px) { .footer :global(.container) { width: calc(100% - 40px); } .footerRow { justify-content: center; } .copyright { flex-basis: 100%; text-align: center; } }
@media (max-width: 1199.98px) {
.footer :global(.container) { width: calc(100% - 64px); }
.name { font-size: 34px; }
.description { font-size: 14px; }
.navigation { padding-left: 32px; }
.navigationHeading { font-size: 12px; gap: 16px; }
.links { padding-right: 0; gap: 12px; }
.links a { font-size: 14px; }
.legalRow { font-size: 13px; }
}
@media (max-width: 767.98px) {
.footer { margin: 0 16px 16px; padding-block: 24px 12px; border-radius: 16px; }
.footer :global(.container) { width: calc(100% - 48px); }
.mainRow { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-bottom: 20px; }
.identity { padding-right: 0; }
.name { margin-top: 0; font-size: 30px; }
.description { max-width: 36ch; }
.navigation { border-left: 0; padding: 0; }
.navigationHeading { margin-top: 0; margin-bottom: 12px; font-size: 13px; gap: 16px; }
.links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.legalRow { flex-wrap: wrap; gap: 0 12px; font-size: 12px; }
}
+15 -9
View File
@@ -1,17 +1,23 @@
import { render, screen } from "@testing-library/react";
import { render, screen, within } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { describe, expect, it } from "vitest";
import Footer from "./Footer";
describe("Footer", () => {
it("links the developer logo to the configured developer website", () => {
it("presents the business and public navigation without developer attribution", () => {
render(<MemoryRouter><Footer /></MemoryRouter>);
const developerLink = screen.getByRole("link", {
name: "Visit roborto.net, developer website",
});
expect(developerLink).toHaveAttribute("href", "https://roborto.net/");
expect(screen.getByRole("img", { name: "roborto.net" }))
.toHaveAttribute("src", "/developer-logo.svg");
const footer = screen.getByRole("contentinfo");
expect(within(footer).getByText(`© ${new Date().getFullYear()} BortStack`)).toBeVisible();
expect(within(footer).getByText("Navigation", { exact: true })).toBeVisible();
const navigation = within(footer).getByRole("navigation", { name: "Footer navigation" });
expect(within(navigation).getByRole("link", { name: "Contact" })).toHaveAttribute("href", "/contact");
expect(within(footer).getByRole("link", { name: "Privacy" })).toHaveAttribute("href", "/privacy");
for (const [name, href] of [["Services", "/services"], ["Projects", "/projects"], ["About", "/about"]]) {
expect(within(navigation).getByRole("link", { name })).toHaveAttribute("href", href);
}
expect(within(footer).getByText("Software, websites and integrations built around your business.")).toBeVisible();
expect(within(footer).getAllByRole("link")).toHaveLength(5);
expect(footer).not.toHaveTextContent(/roborto/i);
expect(within(footer).queryByRole("img")).not.toBeInTheDocument();
});
});
-6
View File
@@ -3,12 +3,6 @@ export const site = Object.freeze({
defaultTitle: "BortStack",
titleTemplate: "%s | BortStack",
description: "Custom software, websites, APIs, hosting and ongoing maintenance for businesses and research projects.",
developer: Object.freeze({
name: "roborto.net",
url: "https://roborto.net/",
logoPath: "/developer-logo.svg",
linkLabel: "Visit roborto.net, developer website",
}),
});
export function pageTitle(title) {