BS-001 Initialize BortStack foundation and project workflow

This commit is contained in:
rob
2026-11-10 14:02:50 +00:00
parent 1ec90a082f
commit 52265961cb
119 changed files with 10298 additions and 64 deletions
+33
View File
@@ -0,0 +1,33 @@
import styles from "./Footer.module.scss";
import { NavLink } from "react-router-dom";
import { site } from "../../config/site";
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}
/>
</a>
</div>
<p className={styles.copyright}>
&copy; {new Date().getFullYear()} Web App
</p>
</footer>
);
};
export default Footer;
@@ -0,0 +1,41 @@
@use "sass:map";
@use "../../styles/colors";
.footer {
padding: 10px;
min-height: 70px;
background-color: map.get(colors.$theme-colors, "footer-bg");
text-align: center;
}
.links {
display: flex;
justify-content: center;
gap: 1rem;
margin-bottom: 0.5rem;
a {
color: inherit;
}
}
.developerSlot {
display: flex;
justify-content: center;
margin: 0 auto 0.5rem;
a {
display: inline-flex;
border-radius: 0.25rem;
}
}
.developerLogo {
display: block;
width: min(210px, 70vw);
height: auto;
}
.copyright {
margin: 0;
}
@@ -0,0 +1,17 @@
import { render, screen } 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", () => {
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");
});
});
@@ -0,0 +1,20 @@
import { Nav } from "react-bootstrap";
import { NavLink } from "react-router-dom";
const GuestNav = () => {
return (
<Nav>
<Nav.Link as={NavLink} to="/contact">
Contact
</Nav.Link>
<Nav.Link as={NavLink} to="/login">
Login
</Nav.Link>
<Nav.Link as={NavLink} to="/register">
Register
</Nav.Link>
</Nav>
);
};
export default GuestNav;
+28
View File
@@ -0,0 +1,28 @@
import { Container, Navbar } from "react-bootstrap";
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>
<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.Collapse>
</Container>
</Navbar>
)
}
export default Header
@@ -0,0 +1,12 @@
@use "sass:map";
@use "../../styles/colors";
.header {
min-height: 70px;
padding: 10px;
background-color: map.get(colors.$theme-colors, "header-bg");
}
.navbarCollapse {
justify-content: flex-end !important;
}
+12
View File
@@ -0,0 +1,12 @@
import styles from "./Logo.module.scss";
import { Link } from "react-router-dom";
function Logo() {
return (
<Link to="/" className={styles.link}>
<span className={styles.logo}>BortStack</span>
</Link>
);
}
export default Logo;
@@ -0,0 +1,9 @@
.link {
text-decoration: none;
color: unset;
}
.logo {
font-size: 1.25rem;
font-weight: 700;
}
@@ -0,0 +1,29 @@
import { useEffect } from "react";
import PropTypes from "prop-types";
import { pageTitle, site } from "../../config/site";
function upsertMeta(name, content) {
let element = document.head.querySelector(`meta[name="${name}"]`);
if (!element) {
element = document.createElement("meta");
element.setAttribute("name", name);
document.head.appendChild(element);
}
element.setAttribute("content", content);
}
export default function PageMeta({ title, description = site.description, noIndex = false }) {
useEffect(() => {
document.title = pageTitle(title);
upsertMeta("description", description);
upsertMeta("robots", noIndex ? "noindex, nofollow" : "index, follow");
}, [description, noIndex, title]);
return null;
}
PageMeta.propTypes = {
title: PropTypes.string,
description: PropTypes.string,
noIndex: PropTypes.bool,
};
@@ -0,0 +1,19 @@
import { render, waitFor } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import PageMeta from "./PageMeta";
import { pageTitle } from "../../config/site";
describe("page metadata", () => {
it("sets public page title, description, and indexing policy", async () => {
render(<PageMeta title="Contact" description="Contact the application team." />);
await waitFor(() => expect(document.title).toBe(pageTitle("Contact")));
expect(document.head.querySelector('meta[name="description"]')).toHaveAttribute("content", "Contact the application team.");
expect(document.head.querySelector('meta[name="robots"]')).toHaveAttribute("content", "index, follow");
});
it("prevents indexing for account and protected pages", async () => {
render(<PageMeta title="Dashboard" noIndex />);
await waitFor(() => expect(document.title).toBe(pageTitle("Dashboard")));
expect(document.head.querySelector('meta[name="robots"]')).toHaveAttribute("content", "noindex, nofollow");
});
});
+20
View File
@@ -0,0 +1,20 @@
import { NavLink } from "react-router-dom";
import { Nav } from "react-bootstrap";
import { useAuth } from "../../contexts/AuthContext";
const PageNav = () => {
const { logout } = useAuth();
return (
<Nav>
<Nav.Link as={NavLink} to="dashboard">
Dashboard
</Nav.Link>
<Nav.Link as={NavLink} onClick={logout} to="/">
Logout
</Nav.Link>
</Nav>
);
};
export default PageNav;