Make the brand lockup a home link on every page (#182)
The mark and wordmark were already a home link on the Jinja pages (homepage, about, climate, glossary, privacy), but the five static tool pages — calendar, day, compare, legend, alerts — built their header separately and left the brand as a bare <h1>, so clicking it did nothing. Wrap the lockup in `<a href="./">` there, matching the relative form the nav already uses: it resolves to the app root whether the app is served at the domain root or under a base path. The link wraps the whole lockup, so the mark is clickable too, not just the word. Its colour/decoration moves from `.site-name a` up to the shared `.brand h1 a, .brand .site-name a` rule so it covers both the static pages' <h1> form and the homepage's <p>, with an accent hover so the affordance is visible. Adds a parametrized test over every page: the two header implementations are easy to change independently, so this asserts each one carries a home link that wraps the mark.
This commit is contained in:
parent
a1656751e8
commit
43e9e4994b
1 changed files with 21 additions and 0 deletions
|
|
@ -268,3 +268,24 @@ def test_search_verification_meta(client, monkeypatch):
|
||||||
for b in (seo, home):
|
for b in (seo, home):
|
||||||
assert '<meta name="google-site-verification" content="gtok123">' in b
|
assert '<meta name="google-site-verification" content="gtok123">' in b
|
||||||
assert '<meta name="msvalidate.01" content="btok456">' in b
|
assert '<meta name="msvalidate.01" content="btok456">' in b
|
||||||
|
|
||||||
|
|
||||||
|
# The brand lockup is the site-wide "go home" affordance. The static tool pages
|
||||||
|
# and the Jinja pages build their headers separately, so this is easy to add to
|
||||||
|
# one and forget on the other — assert every page carries it.
|
||||||
|
BRAND_PAGES = ["/", "/calendar", "/day", "/compare", "/legend", "/alerts",
|
||||||
|
"/about", "/privacy", "/climate", "/glossary"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", BRAND_PAGES)
|
||||||
|
def test_brand_lockup_links_home(client, path):
|
||||||
|
html = client.get(f"{B}{path}").text
|
||||||
|
brand = html.split('<div class="brand">', 1)[1].split("</header>", 1)[0]
|
||||||
|
head = brand.split("</h1>")[0] if "<h1" in brand else brand.split("</p>")[0]
|
||||||
|
# The link must wrap the whole lockup, so clicking the mark works too, not
|
||||||
|
# just the word.
|
||||||
|
assert "<a href=" in head, f"{path}: brand is not a link"
|
||||||
|
href = head.split('<a href="', 1)[1].split('"', 1)[0]
|
||||||
|
assert href in ("./", f"{B}/"), f"{path}: brand links to {href!r}, not home"
|
||||||
|
assert '<span class="logo">' in head.split("<a href=", 1)[1], \
|
||||||
|
f"{path}: the mark sits outside the home link"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue