From b7e72ae6aafad53b230d221c875748e377031681 Mon Sep 17 00:00:00 2001 From: Patternflow Bot Date: Sun, 15 Nov 2026 11:07:08 +0900 Subject: [PATCH 1/3] web: the home page's nav is a row of its own on a phone From Patternflow-lab/Patternflow#405 --- web/src/app/globals.css | 118 +++++++++++------- web/src/app/homePhoneCss.test.ts | 105 ++++++++++++++++ .../journal/HeroJournalLink.test.tsx | 17 ++- .../components/journal/HeroJournalLink.tsx | 8 +- .../InsideGlobe/GlobeViewer.module.css | 4 + .../sections/InsidePanel.module.css | 34 +++++ .../sections/PatternPanel.module.css | 3 +- .../components/sections/RightPanel.test.tsx | 15 +++ web/src/components/sections/RightPanel.tsx | 6 +- 9 files changed, 258 insertions(+), 52 deletions(-) create mode 100644 web/src/app/homePhoneCss.test.ts diff --git a/web/src/app/globals.css b/web/src/app/globals.css index 5ad748f3b..25218bd57 100644 --- a/web/src/app/globals.css +++ b/web/src/app/globals.css @@ -494,8 +494,8 @@ /* At laptop height the column — wordmark, video, the two facts, the buttons — can be taller than the window with the full 80px above it, and the buttons' note falls below the fold. Take the difference from the top. The nav is out - of flow, top-right, and goes up 8px with it, so the Shop box keeps clear - of the wordmark's f and l. */ + of flow, top-right, and goes up 8px with it, so the Instagram mark keeps + clear of the wordmark's f and l. */ @media (min-width: 901px) and (max-height: 860px) { .hero { padding-top: 48px; } .hero .hero-top-links { top: 16px; } @@ -511,19 +511,28 @@ .hero-cta { width: 100%; } } @media (max-width: 900px) { + /* Its first child is the nav, a 44px row in the flow (the rules are at + the end of this file), so nothing is kept clear over the wordmark and + there is no gap between the row and the copy. */ .hero { display: flex; flex-direction: column; align-items: stretch; - padding: 36px 0 60px; - gap: 24px; + padding: 0 0 60px; + gap: 0; min-height: auto; } - .hero-copy h1 { font-size: 50px; margin-bottom: 12px; } - .hero-copy .kicker { font-size: 20px; margin-bottom: 8px; } - .hero-spec { font-size: 14.5px; margin: 0 0 20px; } - .hero-copy p.lede { font-size: 17.5px; margin-bottom: 12px; } + /* 10 and 14, not 12 and 20: the nav row put the wordmark 8px lower, and + these give the 8px back, so Get One is still on the first screen of a + 667px-tall phone. */ + .hero-copy h1 { font-size: 50px; margin-bottom: 10px; } + /* Each of these is two lines on a phone, and the second was a word or + two: "them.", "we make.", "so far." Balanced, the two lines share the + words, and the kicker breaks between its two sentences. */ + .hero-copy .kicker { font-size: 20px; margin-bottom: 8px; text-wrap: balance; } + .hero-spec { font-size: 14.5px; margin: 0 0 14px; text-wrap: balance; } + .hero-copy p.lede { font-size: 17.5px; margin-bottom: 12px; text-wrap: balance; } /* Single column — keep the note directly under Get One rather than letting it fall to the bottom of the stack. */ .hero-cta-row { gap: 8px; grid-template-columns: 1fr; margin-top: 20px; } @@ -911,9 +920,19 @@ color: var(--ink-muted); } footer em { font-style: italic; font-weight: 400; } - /* Same reasoning as .sponsor above — matches .hero dropping to a 0 gutter. */ + /* Same reasoning as .sponsor above — matches .hero dropping to a 0 gutter. + Terms & Privacy is the footer's one link, and it shows that only under a + pointer. A phone has none, so here it carries its line all the time, and + 12px above and below for a finger. */ @media (max-width: 900px) { footer { padding-left: 0; padding-right: 0; } + footer .foot-row a { + display: inline-block; + padding: 12px 0; + text-decoration: underline; + text-underline-offset: 3px; + text-decoration-thickness: 1px; + } } @media (max-width: 640px) { footer { padding: 30px 0 34px; } @@ -961,22 +980,6 @@ fill: currentColor; display: block; } - /* The shop: an outline box in ink, filled on hover like Build it — GitHub. - The accent stays for live signals. The negative margin puts its word on - the same line as Guide, Journal and Community, which sit 2px off the - bottom. */ - .hero-top-links .shop-link { - color: var(--ink); - border: 1px solid var(--ink); - padding: 4px 9px 3px; - margin-bottom: -2px; - transition: background-color 0.15s ease, color 0.15s ease; - } - .hero-top-links .shop-link:hover { - background: var(--ink); - color: var(--cream); - text-decoration: none; - } /* Business */ .business-page { @@ -2073,7 +2076,9 @@ font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; - color: var(--ink-muted); + /* Ink, not muted: on a phone this bar is the one way to Build, Pattern + and Inside, and in the grey of a caption it read as a footer. */ + color: var(--ink); cursor: pointer; transition: color 0.2s ease, background-color 0.2s ease; } @@ -2084,6 +2089,12 @@ color: var(--cream); background: var(--ink); } + /* The open tab's ✕: a second tap on it closes the section. */ + .mobile-bottom-nav .mb-close { + margin-right: 8px; + font-size: 11px; + letter-spacing: 0; + } /* Hero (closed): keep the footer clear of the parked nav at the bottom. */ .content-panel { padding-bottom: calc(var(--mb-nav-h) + env(safe-area-inset-bottom, 0px)); @@ -2094,32 +2105,55 @@ padding-bottom: 40px; } - /* Force mobile override for top header links by placing it at the end of the file */ + /* The site's pages are the hero's first row on a phone: in the flow above + the wordmark, from the column's left edge to its right, Instagram last. + They were 11px words in the corner over the wordmark, 18px tall to a + finger. Each entry is 44px tall now and the words are 12px. The 6px at + each side of an entry is finger room too, and the row's negative margin + puts the first and last word back on the column's edges. These rules + are at the end of the file so that they follow the desktop ones. */ .hero-top-links { - position: absolute !important; - top: 14px !important; - right: -8px !important; - font-size: 11px !important; - gap: 12px !important; + position: static; + justify-content: space-between; + align-items: center; + gap: 0; + margin: 0 -6px; + /* The copy under it stops at 580px, and so does the row on a tablet: + 580px and the 6px it reaches out at each side. */ + max-width: 592px; + font-size: 12px; + } + .hero-top-links a { + display: inline-flex; + align-items: center; + min-height: 44px; + padding: 0 6px; } .hero-top-links .instagram-link svg { - width: 20px !important; - height: 20px !important; + width: 22px; + height: 22px; } - /* Shorter on a phone, where the nav sits right over the wordmark. Its - word still lines up with the others, now with no margin to do it. */ - .hero-top-links .shop-link { - padding: 2px 6px 1px; - margin-bottom: 0; + /* One gutter. A tab's panel had 22px of its own inside .deck-content's + 24px (40px inside it from 761px up), so Build, Pattern and Inside began + 46px from a phone's edge and the hero and the journal 24px. At 390px + that was a 298px column, and it is 342px now. */ + .pf-section-panel { + padding-left: 0; + padding-right: 0; } } - /* Five entries need about 270px. Below 340px the gaps close up so the row - still starts inside the screen at 280px, a folded phone's width. */ + /* Five entries need about 290px at 12px. Below 340px the words go back to + 11px, set closer, with 3px at each side, and the row fits a 280px screen, + a folded phone's width. */ @media (max-width: 340px) { .hero-top-links { - gap: 8px !important; + margin: 0 -3px; + font-size: 11px; letter-spacing: 0.04em; } + .hero-top-links a { + padding: 0 3px; + } } diff --git a/web/src/app/homePhoneCss.test.ts b/web/src/app/homePhoneCss.test.ts new file mode 100644 index 000000000..3728c54a3 --- /dev/null +++ b/web/src/app/homePhoneCss.test.ts @@ -0,0 +1,105 @@ +// jsdom applies no stylesheet, so the home view's phone rules are read from +// globals.css. On 15 November 2026, at 390px, the site's nav was 11px words +// 18px tall in the corner over the wordmark, and Build, Pattern and Inside +// began 46px from the screen's edge where the hero began 24px. The shop had a +// box in the nav and a poster under the hero's buttons, and had sold next to +// nothing. + +import { readFileSync } from 'node:fs'; +import path from 'node:path'; +import { describe, expect, it } from 'vitest'; + +const css = readFileSync(path.resolve(__dirname, 'globals.css'), 'utf8').replace(/\/\*[\s\S]*?\*\//g, ''); + +interface Rule { + selectors: string[]; + body: string; + /** Where the rule starts in the stylesheet, for "this one comes later". */ + at: number; +} + +function rules(source: string, offset = 0): Rule[] { + return [...source.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => ({ + selectors: m[1].split(',').map((s) => s.trim().replace(/\s+/g, ' ')), + body: m[2], + at: offset + (m.index ?? 0), + })); +} + +/** The rules inside every `@media (max-width: 900px)` block, by matching braces. */ +function below900(): Rule[] { + const out: Rule[] = []; + const open = /@media \(max-width: 900px\)\s*\{/g; + for (let m = open.exec(css); m; m = open.exec(css)) { + const start = m.index + m[0].length; + let depth = 1; + let i = start; + while (depth > 0 && i < css.length) { + if (css[i] === '{') depth++; + if (css[i] === '}') depth--; + i++; + } + out.push(...rules(css.slice(start, i - 1), start)); + } + return out; +} + +function declaration(body: string, property: string) { + return body.match(new RegExp(`(?:^|;)\\s*${property}:\\s*([^;]+)`))?.[1].trim(); +} + +const phone = below900(); +const own = (selector: string) => phone.filter((r) => r.selectors.includes(selector)); + +describe('the home view on a phone', () => { + it('puts the site nav in the flow, as a row over the wordmark', () => { + const nav = own('.hero-top-links'); + expect(nav.some((r) => declaration(r.body, 'position') === 'static')).toBe(true); + expect(nav.some((r) => declaration(r.body, 'justify-content') === 'space-between')).toBe(true); + // No rule pins it back over the wordmark. + expect(css).not.toMatch(/position:\s*absolute\s*!important/); + }); + + it('makes each nav entry 44px tall to a finger', () => { + expect(own('.hero-top-links a').some((r) => declaration(r.body, 'min-height') === '44px')).toBe(true); + }); + + it('keeps nothing clear over the wordmark, now the nav is a row of its own', () => { + const hero = own('.hero').find((r) => declaration(r.body, 'padding')); + expect(declaration(hero!.body, 'padding')).toBe('0 0 60px'); + expect(declaration(hero!.body, 'gap')).toBe('0'); + }); + + it('gives a tab panel no side padding of its own, after the rules that gave it some', () => { + const [flat] = own('.pf-section-panel'); + expect(flat, 'no .pf-section-panel rule below 900px').toBeDefined(); + expect(declaration(flat.body, 'padding-left')).toBe('0'); + expect(declaration(flat.body, 'padding-right')).toBe('0'); + const padded = rules(css).filter( + (r) => r.selectors.includes('.pf-section-panel') && declaration(r.body, 'padding'), + ); + expect(padded.length).toBeGreaterThan(0); + for (const rule of padded) expect(flat.at).toBeGreaterThan(rule.at); + }); + + it('draws the section bar in ink, and its open tab reversed', () => { + const [tab] = own('.mobile-bottom-nav .mb-tab'); + expect(declaration(tab.body, 'color')).toBe('var(--ink)'); + const [active] = own('.mobile-bottom-nav .mb-tab.active'); + expect(declaration(active.body, 'color')).toBe('var(--cream)'); + expect(declaration(active.body, 'background')).toBe('var(--ink)'); + }); + + it('underlines the footer link, which a phone cannot hover over', () => { + const [link] = own('footer .foot-row a'); + expect(declaration(link.body, 'text-decoration')).toBe('underline'); + expect(declaration(link.body, 'padding')).toBe('12px 0'); + }); +}); + +describe('the shop on the home view', () => { + it('has no box in the nav and no poster in the hero', () => { + expect(css).not.toContain('.shop-link'); + expect(css).not.toContain('.hero-shop'); + }); +}); diff --git a/web/src/components/journal/HeroJournalLink.test.tsx b/web/src/components/journal/HeroJournalLink.test.tsx index b717f2057..536856e5d 100644 --- a/web/src/components/journal/HeroJournalLink.test.tsx +++ b/web/src/components/journal/HeroJournalLink.test.tsx @@ -4,8 +4,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; import { fireEvent, render, screen, within } from '@testing-library/react'; import HeroJournalLink from './HeroJournalLink'; -// The site's nav, top right of the hero on a desktop and on a phone. The shop -// is on its own host and opens in a new tab, as Get One does. +// The site's nav, top right of the hero on a desktop and the hero's first row +// on a phone. The shop is on its own host and opens in a new tab, as Get One +// does. It is an experiment, so it is drawn as the other words are: no box, +// which is to say no class of its own. vi.mock('next/link', () => ({ default: ({ @@ -35,7 +37,14 @@ describe('HeroJournalLink', () => { expect(shop.getAttribute('href')).toBe('https://shop.patternflow.work'); expect(shop.getAttribute('target')).toBe('_blank'); expect(shop.getAttribute('rel')).toBe('noopener'); - expect(shop.className).toBe('shop-link'); + }); + + it('draws the shop as it draws the pages', () => { + render(); + const words = ['Guide', 'Journal', 'Community', 'Shop'].map((name) => + within(nav()).getByRole('link', { name }), + ); + expect(words.map((a) => a.className)).toEqual(['', '', '', '']); }); it('puts the shop after the pages and before Instagram', () => { @@ -52,6 +61,6 @@ describe('HeroJournalLink', () => { it('sends the shop link from the server', () => { const html = renderToString(); - expect(html).toContain('Shop'); + expect(html).toContain('Shop'); }); }); diff --git a/web/src/components/journal/HeroJournalLink.tsx b/web/src/components/journal/HeroJournalLink.tsx index 9f96b8737..f3c3c1871 100644 --- a/web/src/components/journal/HeroJournalLink.tsx +++ b/web/src/components/journal/HeroJournalLink.tsx @@ -16,9 +16,10 @@ function InstagramIcon() { // Global nav, so it carries what someone needs from anywhere. Community is a // whole platform on its own host and was only reachable from inside the Pattern // panel; Contact moved to the Inside panel's join band, next to the other ways -// of reaching us. The shop opened at shop.patternflow.work in October 2026 and -// had no link from the site. It is the one entry drawn as a box, the hero's -// outline button at the nav's size, and it opens in a new tab as Get One does. +// of reaching us. The shop opened at shop.patternflow.work in October 2026 as +// an experiment. It was a box here and a poster under the hero's buttons until +// November, and sold next to nothing, so it is a word like the other three +// now. It opens in a new tab as Get One does. export default function HeroJournalLink() { return (