Cookie button never moves; the footer gets room under its last row while the button is shown

Owner, 2026-12-01, after the review of fb92b35: option 3, "miejsce pod stopką" — the button stays in its corner at
all times and covers nothing; the page gets room under its last row.

- Removed: the step up at the end of the page (`clear`, COOKIE_BUTTON_CLEAR, stepAbove; never released).
- New: while the button is shown, the last footer (`reserve`, COOKIE_BUTTON_RESERVE; no footer: <body>) gets bottom
  padding, measured: button height + offset + safe area + 8 px, minus what is already free under the lowest text or
  control in the button's column. The footer's own padding counts (no double space); an empty corner gets nothing.
  Not before a decision, not while the banner is open, gone with the button; `reserve={false}` turns it off,
  `--ipal-cookie-button-space` on the footer sets the amount (0 = none, per breakpoint).
- No layout shift: on a static page <CookieButton> renders an inline script that makes the room before the first
  paint for a visitor who already decided — in a constructed style sheet, so the server's markup is untouched and
  React hydrates without a mismatch; after hydration the same function moves it onto the element.
- consentDecidedScript: the shared start of the banner's and the button's pre-paint scripts.
- avoid={COOKIE_BUTTON_AVOID} is still the placement before 1.17.2 (no room then).

Tests: test/cookieButtonPlacement.test.ts rewritten (24); reference e2e on desktop, 390 px and 360 px phones, light
and dark, five pages: the corner at every scroll position, nothing under the button at the very end, every footer
link clickable, layout shift < 0.001, the room before hydration.
Docs: consent.md, AGENT.md, skills, PROGRAMISTA item 83, changelog draft 1.17.2.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 12:08:00 +01:00
co-authored by Claude Fable 5.2
parent fb92b357e8
commit 3821174be4
20 changed files with 763 additions and 321 deletions
+5 -3
View File
@@ -168,7 +168,7 @@ describe('server render', () => {
test('firstPaint={false}: nothing in the HTML, as before 1.17.0', () => {
const html = renderToString(tree({ banner: { firstPaint: false } }))
expect(html).not.toContain('data-ipal="banner"')
expect(html).not.toContain('<script')
expect(html).not.toContain('data-ipal="banner-script"')
})
test('nonce: from the provider, or the banner prop', () => {
@@ -444,9 +444,11 @@ describe('tags: nothing earlier than before', () => {
const pixels = { clarityProjectId: 'clar', consentMode: 'basic', gtmContainerId: 'GTM-TEST', metaPixelId: '123' }
const layer = () => [...((window.dataLayer ?? []))].map((entry) => (Object.prototype.toString.call(entry) === '[object Arguments]' ? Array.from(entry as ArrayLike<unknown>) : entry))
test('the server HTML holds one script, the banner one, and it names no tag', () => {
test("the server HTML holds two scripts, the banner's and the cookie button's (1.17.2), and neither names a tag", () => {
const html = renderToString(tree({ analytics: pixels }))
expect(html.match(/<script/g)).toHaveLength(1)
expect(html.match(/<script[^>]*data-ipal="(?:banner|cookie-button)-script"/g)).toHaveLength(2)
expect(html.match(/<script/g)).toHaveLength(2)
expect(html).not.toMatch(/createElement\(["']script|\.src\s*=|fetch\(|XMLHttpRequest|dataLayer|document\.cookie\s*=[^=]/)
expect(html).not.toMatch(/googletagmanager|facebook|clarity|GTM-TEST/)
})