BS-002 Establish public marketing routes and navigation

This commit is contained in:
rob
2026-11-10 14:06:46 +00:00
parent 52265961cb
commit ea28637259
13 changed files with 165 additions and 199 deletions
+31 -45
View File
@@ -1,57 +1,43 @@
import "./styles/custom.scss";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { AuthProvider } from "./contexts/AuthContext";
import ProtectedRoute from "./routing/ProtectedRoute";
import PageNotFound from "./views/PageNotFound/PageNotFound";
import Login from "./views/Login/Login";
import Register from "./views/Register/Register";
import ForgotPassword from "./views/ForgotPassword/ForgotPassword";
import ResetPassword from "./views/ResetPassword/ResetPassword";
import VerifyEmail from "./views/VerifyEmail/VerifyEmail";
import Contact from "./views/Contact/Contact";
import Privacy from "./views/Legal/Privacy";
import Terms from "./views/Legal/Terms";
import Header from "./components/Header/Header";
import Footer from "./components/Footer/Footer";
import PageMeta from "./components/PageMeta/PageMeta";
import Homepage from "./views/Home/Homepage";
import Dashboard from "./views/Dashboard/Dashboard";
import RoutePlaceholder from "./views/RoutePlaceholder";
const pages = [
["services", "Services", "Website development, custom software, APIs and managed hosting."],
["projects", "Projects", "Project details will be added after publication permissions and genuine imagery are confirmed."],
["projects/:slug", "Project details", "This case study is not available. Only verified, approved work will be published."],
["about", "About BortStack", "Business background and working approach are being prepared."],
["contact", "Contact", "The enquiry form and verified business email will be available here. Enquiries cannot be submitted yet."],
["privacy", "Privacy policy", "Privacy information is awaiting review against the actual website data flows before publication."],
];
const App = () => {
export default function App() {
return (
<div className="app" data-bs-theme="dark">
<div className="app">
<BrowserRouter>
<AuthProvider>
<>
<a className="skipLink" href="#main-content">Skip to main content</a>
<Header />
<div id="main-content" className="pageContent" tabIndex="-1">
<Routes>
<Route index element={<><PageMeta /><Homepage /></>} />
<Route element={<ProtectedRoute />}>
<Route path="dashboard" element={<><PageMeta title="Dashboard" noIndex /><Dashboard /></>} />
</Route>
<Route path="login" element={<><PageMeta title="Login" noIndex /><Login /></>} />
<Route path="register" element={<><PageMeta title="Register" noIndex /><Register /></>} />
<Route path="forgot-password" element={<><PageMeta title="Reset password" noIndex /><ForgotPassword /></>} />
<Route path="reset-password" element={<><PageMeta title="Choose a password" noIndex /><ResetPassword /></>} />
<Route path="verify-email" element={<><PageMeta title="Verify email" noIndex /><VerifyEmail /></>} />
<Route path="contact" element={<><PageMeta title="Contact" description="Contact the application team." /><Contact /></>} />
<Route path="privacy" element={<><PageMeta title="Privacy policy" /><Privacy /></>} />
<Route path="terms" element={<><PageMeta title="Terms of service" /><Terms /></>} />
<Route path="*" element={<><PageMeta title="Page not found" noIndex /><PageNotFound /></>} />
</Routes>
</div>
<Footer />
</>
</AuthProvider>
</BrowserRouter>
<a className="skipLink" href="#main-content">Skip to main content</a>
<Header />
<main id="main-content" className="pageContent" tabIndex="-1">
<Routes>
<Route index element={<><PageMeta /><Homepage /></>} />
{pages.map(([path, title, description]) => (
<Route key={path} path={path} element={<>
<PageMeta title={title} description={description} noIndex />
<RoutePlaceholder title={title} description={description} />
</>} />
))}
<Route path="*" element={<>
<PageMeta title="Page not found" noIndex />
<RoutePlaceholder title="Page not found" description="This page is not available. Use the navigation to explore BortStack." />
</>} />
</Routes>
</main>
<Footer />
</BrowserRouter>
</div>
);
};
export default App;
}
+16 -28
View File
@@ -1,33 +1,21 @@
import styles from "./Footer.module.scss";
import { Container } from "react-bootstrap";
import { NavLink } from "react-router-dom";
import { site } from "../../config/site";
import styles from "./Footer.module.scss";
const Footer = () => {
return (
<footer className={styles.footer}>
<nav className={styles.links} aria-label="Footer navigation">
<NavLink to="/contact">Contact</NavLink>
<NavLink to="/privacy">Privacy</NavLink>
<NavLink to="/terms">Terms</NavLink>
</nav>
<div className={styles.developerSlot}>
<a
href={site.developer.url}
aria-label={site.developer.linkLabel}
rel="noreferrer"
>
<img
src={site.developer.logoPath}
alt={site.developer.name}
className={styles.developerLogo}
/>
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>
</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>
<p className={styles.copyright}>
&copy; {new Date().getFullYear()} Web App
</p>
</footer>
);
};
export default Footer;
</Container>
</footer>;
}
+17 -23
View File
@@ -1,28 +1,22 @@
import { Container, Navbar } from "react-bootstrap";
import { useState } from "react";
import { Container, Nav, Navbar } from "react-bootstrap";
import { NavLink } from "react-router-dom";
import Logo from "../Logo/Logo";
import styles from "./Header.module.scss";
import PageNav from "../PageNav/PageNav"
import Logo from "../Logo/Logo"
import { useAuth } from "../../contexts/AuthContext";
import GuestNav from "../GuestNav/GuestNav";
const Header = () => {
const { user } = useAuth()
return (
<Navbar expand="sm" className={styles.header} variant="dark">
<Container>
export default function Header() {
const [expanded, setExpanded] = useState(false);
return <Navbar variant="dark" expand="md" expanded={expanded} onToggle={setExpanded} className={styles.header} aria-label="Main navigation">
<Container>
<Navbar.Brand as="div"><Logo /></Navbar.Brand>
<Navbar.Toggle aria-controls="navbar-nav" />
<Navbar.Collapse id="navbar-nav" className={styles.navbarCollapse}>
{
user ? <PageNav /> : <GuestNav />
}
<Navbar.Toggle aria-controls="main-navigation" aria-expanded={expanded} />
<Navbar.Collapse id="main-navigation" className={styles.navbarCollapse}>
<Nav>
{["Services", "Projects", "About", "Contact"].map(label => (
<Nav.Link as={NavLink} key={label} to={`/${label.toLowerCase()}`} onClick={() => setExpanded(false)}>{label}</Nav.Link>
))}
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
)
</Container>
</Navbar>;
}
export default Header
+1 -1
View File
@@ -2,7 +2,7 @@ export const site = Object.freeze({
name: "BortStack",
defaultTitle: "BortStack",
titleTemplate: "%s | BortStack",
description: "A reusable Flask and React web application foundation.",
description: "Custom software, websites, APIs, hosting and ongoing maintenance for businesses and research projects.",
developer: Object.freeze({
name: "roborto.net",
url: "https://roborto.net/",
+7 -17
View File
@@ -1,18 +1,8 @@
import styles from "./Homepage.module.scss";
const Homepage = () => {
return (
<main className={styles.homepage}>
<section>
<p>Reusable Flask and React application foundation</p>
<h1>Build your application from here</h1>
<p>
Replace this placeholder with the generated project&apos;s
purpose, primary action, and product-specific content.
</p>
</section>
</main>
)
import { Container } from "react-bootstrap";
export default function Homepage() {
return <Container className="routePlaceholder">
<p className="eyebrow">BortStack · Website in development</p>
<h1>Software development for real-world needs</h1>
<p>The approved BortStack homepage is being prepared.</p>
</Container>;
}
export default Homepage
+33
View File
@@ -0,0 +1,33 @@
import { fireEvent, render, screen, within } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import App from "../App";
afterEach(() => { window.history.replaceState({}, "", "/"); vi.unstubAllGlobals(); });
describe("public marketing routes", () => {
it.each([
["/services", "Services"], ["/projects", "Projects"],
["/projects/example", "Project details"], ["/about", "About BortStack"],
["/contact", "Contact"], ["/privacy", "Privacy policy"],
["/login", "Page not found"], ["/register", "Page not found"], ["/dashboard", "Page not found"],
])("loads %s without account infrastructure", (path, heading) => {
const fetchMock = vi.fn();
vi.stubGlobal("fetch", fetchMock);
window.history.replaceState({}, "", path);
render(<App />);
expect(screen.getByRole("heading", { level: 1, name: heading })).toBeInTheDocument();
expect(fetchMock).not.toHaveBeenCalled();
expect(screen.queryByRole("link", { name: /login|register|dashboard/i })).not.toBeInTheDocument();
});
it("exposes the four marketing links and closes navigation on selection", async () => {
render(<App />);
const nav = screen.getByRole("navigation", { name: "Main navigation" });
fireEvent.click(screen.getByRole("button", { name: "Toggle navigation" }));
await within(nav).findByRole("link", { name: "Services" });
for (const name of ["Services", "Projects", "About", "Contact"]) {
expect(within(nav).getByRole("link", { name })).toBeInTheDocument();
}
fireEvent.click(within(nav).getByRole("link", { name: "Services" }));
expect(screen.getByRole("button", { name: "Toggle navigation" })).toHaveAttribute("aria-expanded", "false");
expect(screen.getByRole("heading", { name: "Services" })).toBeInTheDocument();
});
});
+2 -2
View File
@@ -9,9 +9,9 @@ import Terms from "./Legal/Terms";
afterEach(() => vi.unstubAllGlobals());
describe("generic public pages", () => {
it("marks homepage content as replaceable", () => {
it("shows the marketing homepage shell", () => {
render(<MemoryRouter><Homepage /></MemoryRouter>);
expect(screen.getByRole("heading", { name: /build your application/i })).toBeInTheDocument();
expect(screen.getByRole("heading", { name: /software development for real-world needs/i })).toBeInTheDocument();
});
it("marks legal pages as placeholders", () => {
+13
View File
@@ -0,0 +1,13 @@
import PropTypes from "prop-types";
import { Container } from "react-bootstrap";
import { Link } from "react-router-dom";
export default function RoutePlaceholder({ title, description }) {
return <Container className="routePlaceholder">
<p className="eyebrow">BortStack · Website in development</p>
<h1>{title}</h1>
<p>{description}</p>
<Link to="/">Back to homepage <span aria-hidden="true">→</span></Link>
</Container>;
}
RoutePlaceholder.propTypes = { title: PropTypes.string.isRequired, description: PropTypes.string.isRequired };