From 3821174be4ba4282963f62c2eeb039c96cde496e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Tue, 1 Dec 2026 12:08:00 +0100 Subject: [PATCH] Cookie button never moves; the footer gets room under its last row while the button is shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: ) 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 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 --- docs/CHANGELOG.md | 31 +- docs/agent/AGENT.md | 2 +- docs/agent/skills/iapl-consent-check/SKILL.md | 12 +- .../skills/iapl-reference/resources/api.md | 5 +- docs/agent/skills/iapl-upgrade/SKILL.md | 14 +- docs/consent.md | 45 +- docs/dev/PROGRAMISTA.md | 2 +- .../skills/iapl-consent-check/SKILL.md | 12 +- .../skills/iapl-reference/resources/api.md | 5 +- .../.agents/skills/iapl-upgrade/SKILL.md | 14 +- reference/e2e/smoke.spec.ts | 172 +++++--- src/exports/client.ts | 7 +- src/index.ts | 1 + src/modules/consent/CookieButton.tsx | 152 +++---- src/modules/consent/client.ts | 4 +- src/modules/consent/cookieButtonSpace.ts | 171 ++++++++ src/modules/consent/firstPaint.ts | 17 +- src/modules/consent/index.ts | 2 +- test/consentFirstPaint.test.ts | 8 +- test/cookieButtonPlacement.test.ts | 408 ++++++++++++------ 20 files changed, 763 insertions(+), 321 deletions(-) create mode 100644 src/modules/consent/cookieButtonSpace.ts diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 547660e..17b1c94 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,21 +12,26 @@ once there are more than 20. ## 1.17.2 — (draft, not released) ### Changed -- **What an existing site's visitors see: the "cookie settings" button stays in the bottom corner of the window** - ([consent.md → Where the cookie button sits](./consent.md#where-the-cookie-button-sits-1172)). Until now it moved - up by the visible part of the footer: on a phone with a tall footer it ended at the top of the screen (over the - header), on a short page in the middle of it. Now it is in the same corner on every page and at every scroll - position. Only at the very end of the page, where it would keep a footer link or a button covered with no way to - scroll past, it steps up just above it (on the reference site: 71 px on a phone, nothing on desktop). No layout - shift, same look, keyboard and screen-reader access unchanged; the side inset now adds the device's safe-area inset. - **Nothing to do; an existing site gets it by updating.** The placement before: - `` (on `SiteProviders`: `cookieButton={…}`). A site that already passes - `avoid` (a selector, or `false` = never move) or `className` keeps its behaviour. A project e2e test that expects the - button above the footer needs an update. +- **What an existing site's visitors see: the "cookie settings" button stays in the bottom corner of the window and + never moves; the footer is a little taller while it is shown** + ([consent.md → Where the cookie button sits](./consent.md#where-the-cookie-button-sits-1172)). Until now the button + moved up by the visible part of the footer: on a phone with a tall footer it ended at the top of the screen (over + the header), on a short page in the middle of it. Now it is in the same corner on every page and at every scroll + position. So that it covers nothing at the very end of a page, the footer gets bottom padding while the button is + shown — just enough for its last row to end above the button (measured: the footer's own padding counts, an empty + corner gets nothing; on the reference site 42–43 px on phones and desktop). Not before a decision, not while the + banner is open. No layout shift: for a returning visitor the room is made before the first paint. Same look, + keyboard and screen-reader access unchanged; the side inset now adds the device's safe-area inset. + **Nothing to do; an existing site gets it by updating.** No room: ``; an amount of + your own: `--ipal-cookie-button-space` on the footer (`0` = none, also per breakpoint); the placement before: + `` (on `SiteProviders`: `cookieButton={…}`). A site that passes a + selector in `avoid` keeps its behaviour. A project e2e test that expects the button above the footer, or an exact + footer height after a decision, needs an update. ### Added -- `CookieButton` prop `clear` (selector of controls freed at the end of the page; `false` = off), `COOKIE_BUTTON_CLEAR`, - `stepAbove` (`/client`). +- `CookieButton` prop `reserve` (the block that gets the room; `false` = off); `COOKIE_BUTTON_RESERVE`, + `COOKIE_BUTTON_SPACE_ATTRIBUTE`, `reserveCookieButtonSpace` (`/client`, type `CookieButtonSpaceOptions`); + `consentDecidedScript` (root); the token `--ipal-cookie-button-space`. ## 1.17.1 — security fixes from the IAWL review; the panel's sign-in look; the sending method is chosen diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index 54746f1..b26d11a 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -1161,7 +1161,7 @@ project → **plugin gap**, not a copy. |---|---|---| | Banner, settings, cookie button | `}>`, `CookieButton`, `useConsent` | consent.md | | Compliance defaults (1.17.0): Global Privacy Control honoured (no banner, no tracker request, opt-in from the cookie button wins), "Reject" like "Accept all", consent log on, withdrawal tells Meta / TikTok / Clarity and clears listed storage keys | built in; opt-outs: `SiteProviders gpc="ask"` / `gpc={false}`, `CookieBanner equalChoice={false}`, `iapl({ consentLog: false })` / `logEndpoint={false}`, `maxAgeDays` (re-ask, default 180); building blocks `resolveConsent`, `gpcFromHeaders`, `gpcFromNavigator`, `GPC_CATEGORIES`, `GPC_HEADER`, `CONSENT_LOG_PATH`, `gpcWellKnown` (`/.well-known/gpc.json`), `readEffectiveConsent`, `signalVendors`, `clarityConsent` (`/client`). Check: `iapl-consent-check` (5 runs incl. GPC, equal prominence, withdrawal), `iapl-doctor` (`consent-banner`, `consent-log-migration`) | consent.md → "Compliance defaults", consent-behaviour-spec.md | -| Cookie button placement | built in: bottom corner of the window on every page, never in or above the footer; at the page end it steps above a link it would keep covered. `CookieButton side` / `clear` / `avoid` (`avoid={COOKIE_BUTTON_AVOID}` = above the footer, as before 1.17.2; `false` = never move), tokens `--ipal-cookie-button-offset` / `-inset`. Do not render the button inside the footer or write a scroll handler for it | consent.md → "Where the cookie button sits" | +| Cookie button placement | built in: bottom corner of the window on every page, never moves, never in or above the footer; the footer gets room under its last row while the button is shown, so nothing is covered at the page end. `CookieButton side` / `reserve` (`false` = no room) / `avoid` (`avoid={COOKIE_BUTTON_AVOID}` = above the footer, as before 1.17.2), tokens `--ipal-cookie-button-offset` / `-inset`, amount by hand `--ipal-cookie-button-space` on the footer. Do not render the button inside the footer, write a scroll handler for it, or add bottom padding for it by hand | consent.md → "Where the cookie button sits" | | Banner at first paint (not after hydration; LCP) | built in: `CookieBanner firstPaint` (default on), `SiteProviders nonce` under a nonce CSP; off: `firstPaint={false}`; server-exact HTML on a dynamic site: `SiteProviders consentCookie` / `ConsentProvider cookieValue`; your own banner: `consentBannerScript`. Check: `curl -s \| grep -c 'data-ipal="banner-script"'` → 1 and the response still has `s-maxage` | consent.md → "First paint" | | Settings window: in the bar / small / large with cookie details | `` — do not build your own window or cookie list | consent.md → "Large window with details" | | A consent-dependent script | `ConsentScript` | consent.md | diff --git a/docs/agent/skills/iapl-consent-check/SKILL.md b/docs/agent/skills/iapl-consent-check/SKILL.md index b7d462c..71dcc81 100644 --- a/docs/agent/skills/iapl-consent-check/SKILL.md +++ b/docs/agent/skills/iapl-consent-check/SKILL.md @@ -56,11 +56,13 @@ before analytics or marketing consent — check the project's choice in "Project decision is from an older Policy version must see it at once. A click on a button before hydration counts (the checks above click as soon as the button is visible). 7. Cookie button (1.17.2, consent.md → "Where the cookie button sits"): after a decision, on a long page, a short - page and a page with a form, desktop and phone width — the button is in the bottom corner of the window at the - top, in the middle and with the footer in view (it must not ride up on the footer); scrolled to the very end it - lies on no link or button (it may step up a little); Tab reaches it and Enter reopens the banner. A footer whose - corner is all links: `side="right"` or a larger `--ipal-cookie-button-offset`. A project scroll handler or a - button rendered inside the footer → remove (AGENT.md §7). + page and a page with a form, desktop and phone width (also 360 px) — the button is in the bottom corner of the + window at the top, in the middle, with the footer in view and at the very end: it must not move at all. At the + very end nothing of the footer is under it and the last footer link can be tapped (the footer has grown a little: + `[data-ipal-cookie-space]` on it). Before a decision and while the banner is open the footer has its own padding + only. Tab reaches the button and Enter reopens the banner. A project scroll handler, a button rendered inside + the footer or hand-made bottom padding for it → remove (AGENT.md §7). Too much or too little room: + `--ipal-cookie-button-space` on the footer; none: `reserve={false}`. The script needs buttons with `data-ipal="accept"` / `"reject"` — the plugin's `CookieBanner` has them in every `settings` mode (`inline`, `modal`, `detailed`). A custom banner in the project violates AGENT.md §7. diff --git a/docs/agent/skills/iapl-reference/resources/api.md b/docs/agent/skills/iapl-reference/resources/api.md index d31d116..caafe9e 100644 --- a/docs/agent/skills/iapl-reference/resources/api.md +++ b/docs/agent/skills/iapl-reference/resources/api.md @@ -165,9 +165,10 @@ Fifteen ready blocks and ten page templates. **Use a library block (or a variant |---|---|---| | `ConsentProvider` | `@intecion/ipal-kit/client` | Consent provider: `{ texts, cookieMap?, logEndpoint?, nonce?, cookieValue?, gpc?, maxAgeDays? }` (`gpc`: Global Privacy Control `'honour'` default / `'ask'` / `false`; `maxAgeDays`: re-ask period, default 180; withdrawal also removes the panel's listed storage keys and tells Meta / TikTok / Clarity) (`nonce`: CSP nonce for the banner's first-paint script; `cookieValue`: optional server-read consent cookie → exact HTML, dynamic pages) — consent state, cookie, Consent Mode, deleting cookies after consent is withdrawn, optional POST of the decision to the log (`'/api/ipal/consent'`). Wrap the layout once; required by the banner, `Analytics`, `ConsentScript`. | | `CookieBanner` | `@intecion/ipal-kit/client` | Consent banner + category settings: `settings: 'inline' \| 'modal' \| 'detailed'`, `controls`, `equalChoice` (recommended `true`), `order`, `settingsActions`, `icon`, `classNames`, `firstPaint` (default `true`: in the server HTML, decided before the first paint by an inline script; pages stay static), `nonce`; colours from `--ipal-*` CSS vars. Do not write your own banner. | -| `CookieButton` | `@intecion/ipal-kit/client` | Floating button that reopens the cookie settings (withdrawing consent); hidden while the banner is visible. Fixed in the bottom corner of the window on every page (1.17.2: it no longer climbs above the footer); at the very end of the page it steps just above a link or button it would keep covered. Props `className`, `side` (`'left' \| 'right'`), `clear` (selector of controls to free at the page end, default `COOKIE_BUTTON_CLEAR`; `false`), `avoid` (placement before 1.17.2: selector it lifts above — `COOKIE_BUTTON_AVOID` = footer; `false` = never move). Tokens `--ipal-cookie-button-offset`, `--ipal-cookie-button-inset`. Type `CookieButtonProps`. | +| `CookieButton` | `@intecion/ipal-kit/client` | Floating button that reopens the cookie settings (withdrawing consent); hidden while the banner is visible. Fixed in the bottom corner of the window on every page and never moves (1.17.2: it no longer climbs above the footer). While it is shown the footer gets just enough bottom padding for its last row to end above the button (measured; the footer's own padding counts; nothing where the corner is empty; made before the first paint for a returning visitor). Props `className`, `side` (`'left' \| 'right'`), `reserve` (selector of the block that gets the room, default `COOKIE_BUTTON_RESERVE` = footer; `false` = none), `avoid` (placement before 1.17.2: selector it lifts above — `COOKIE_BUTTON_AVOID`). Amount by hand: `--ipal-cookie-button-space` on the footer (`0` = none). Tokens `--ipal-cookie-button-offset`, `--ipal-cookie-button-inset`. Type `CookieButtonProps`. | | `COOKIE_BUTTON_AVOID`, `bottomOverlap(tops, viewportHeight)` | `@intecion/ipal-kit/client` | Footer selector for the placement before 1.17.2 (``); pixels the footer covers at the bottom of the screen (how far the button moves up then) | -| `COOKIE_BUTTON_CLEAR`, `stepAbove(button, obstacles, max)` | `@intecion/ipal-kit/client` | Default selector of controls the cookie button frees at the end of the page; how far a box must move up to lie on none of the given boxes (0 = stays, also when no free place within `max`) | +| `COOKIE_BUTTON_RESERVE`, `COOKIE_BUTTON_SPACE_ATTRIBUTE`, `reserveCookieButtonSpace(options)` | `@intecion/ipal-kit/client` | Default selector of the block that gets room for the cookie button (the footer); the attribute that marks it while the room is there; the function that measures and applies (or, with `release: true`, removes) it — options type `CookieButtonSpaceOptions` (`selector`, `side`, `button?`, `release?`, `sheet?`). For a button of your own | +| `consentDecidedScript({ version?, gpc?, cookieName? })` | `@intecion/ipal-kit` | JavaScript statements for an inline script: leave `true` in `d` when the browser holds a current consent decision (as `readConsentRecord` decides). The shared start of the plugin's pre-paint scripts | | `TOTP_TEXTS`, `TOTP_VIEW_TITLE` | `@intecion/ipal-kit` | en/pl texts of the 2FA screens (`totpPlugin:*`, merged by `twoFactor`) and their tab title | | `ConsentScript` | `@intecion/ipal-kit/client` | Loads an external script (`src` or `code`) only after consent for `category` — for vendors without Consent Mode (chat, Plausible etc.). Inside `ConsentProvider`. | | `CookieTable` | `@intecion/ipal-kit/rsc` | Server Component: cookie table for the cookie policy page — `{ rows, labels?, locale?, categories?, caption?, classNames?, storageColumn?, storageTypes? }`; `rows` from `getCookieTable()`; a **Type** column when a row is local / session storage (`storageColumn: 'auto' \| boolean`). | diff --git a/docs/agent/skills/iapl-upgrade/SKILL.md b/docs/agent/skills/iapl-upgrade/SKILL.md index 67cc71b..2a6920c 100644 --- a/docs/agent/skills/iapl-upgrade/SKILL.md +++ b/docs/agent/skills/iapl-upgrade/SKILL.md @@ -26,12 +26,14 @@ the MANDATORY SET (GEO: llms-full, Markdown, MCP; R2; Turnstile through not an extra. Skip one only with a client decision in `AGENTS.md` (`iapl-audit-skip:`). **→ 1.17.2, cookie button (CHANGELOG 1.17.2; PROGRAMISTA §6, item 83; consent.md "Where the cookie button sits") — nothing is required:** -visitors now see the "cookie settings" button in the bottom corner of the window on every page; it no longer moves up -above the footer. Look at the end of a page on a phone: the button must lie on no link (it steps up by itself; a -footer corner full of links → `side="right"` or a larger `--ipal-cookie-button-offset`). The placement before: -`cookieButton={}` on `SiteProviders`. A project that passes `avoid` (a -selector or `false`) or `className` keeps what it had. A project e2e that expects the button above the footer: -update it. +visitors now see the "cookie settings" button in the bottom corner of the window on every page; it never moves and +no longer rides up above the footer. While it is shown the footer is a little taller (about 40 px on the reference +site), so its last row ends above the button. Check the end of a page on a phone and on desktop: nothing under the +button, the last footer link can be tapped. Bottom padding a project added by hand for the button: remove it (the +plugin counts existing padding, so it is not doubled, but it is no longer needed). Amount by hand: +`--ipal-cookie-button-space` on the footer (`0` = none); no room: `reserve={false}`. The placement before: +`cookieButton={}` on `SiteProviders`. A project e2e that expects the button +above the footer, or an exact footer height after a decision: update it. **→ 1.17.1:** (1) `src/proxy.ts`: replace the matcher literal with `['/((?!(?:api|admin|_next)(?:/|$)|.*\\..*).*)']` (i18n.md "Next matcher"; `iapl-doctor` rule `proxy-matcher`). diff --git a/docs/consent.md b/docs/consent.md index 31b2da0..c87235e 100644 --- a/docs/consent.md +++ b/docs/consent.md @@ -116,22 +116,37 @@ takes `locale` and optional `labels`; defaults: `COOKIE_TABLE_LABELS` (`@intecio ### Where the cookie button sits (1.17.2) `CookieButton` is fixed in the **bottom corner of the window** — on every page, long or short, at every scroll -position, on desktop and phone. It is a child of `` (never inside the footer) and it no longer climbs above -the footer when the footer scrolls into view (1.12.x–1.17.1 did that: on a phone with a tall footer the button ended -at the top of the screen, on a short page in the middle of it). +position, on desktop and phone — and it **never moves**. It is a child of `` (never inside the footer) and it +no longer climbs above the footer when the footer scrolls into view (1.12.x–1.17.1 did that: on a phone with a tall +footer the button ended at the top of the screen, on a short page in the middle of it). -One exception keeps every control reachable: **at the very end of the page**, where a visitor cannot scroll a -covered link out from under a fixed button, the button steps up just far enough to lie on no link, button or form -field (`stepAbove`; 8 px gap; never more than half the window, otherwise it stays in the corner). It then usually -rests on plain text of the footer (the copyright line). Anywhere above the end of the page it stays in the corner: a -covered control is one scroll away. The step is a `transform` — no layout shift. +**Room under the footer.** A fixed button would, at the very end of a page, lie on whatever is in that corner — the +first link of the footer's last row — and a visitor could not scroll it free. So while the button is shown, the +plugin gives the page's last block (the footer) **bottom padding: just enough for its last row to end above the +button** (`reserveCookieButtonSpace`). The footer's background continues through it. + +| | | +|---|---| +| How much | measured, not fixed: the button's height + its distance from the bottom + the device's safe area + 8 px, **minus what is already free** under the lowest text or control in the button's column. The footer's own bottom padding counts first — never double space. On the reference site: 42–43 px on phones and desktop | +| Where nothing is in the corner | nothing is added (a centred footer on a wide screen, the button on the other side) — so there is no breakpoint to configure | +| When | only while the button is shown: not before a decision, not while the banner is open (the footer is as the project made it), gone when the button is turned off (`cookieButton={false}`) | +| No layout shift | on a static page the HTML carries a small inline script next to the button's place: for a visitor who already decided it makes the room **before the first paint** (in a style sheet, so React hydrates the server's markup untouched), and the button's own measurement after hydration gives the same size. After a click in the banner the room appears with the button. Later changes (fonts, a form that grows, a resize) are followed | +| Which block | the last element matching `reserve` (default `COOKIE_BUTTON_RESERVE` = `'footer, [role="contentinfo"]'`); none on the page → `` | | Prop | Default | What it does | |---|---|---| | `side` | `'left'` | corner: `'left'` or `'right'` | -| `clear` | `COOKIE_BUTTON_CLEAR` (links, buttons, form fields) | CSS selector of controls the button frees at the end of the page; `false` = stay in the corner whatever is under it | -| `avoid` | — | placement before 1.17.2: a CSS selector the button lifts above while it is on screen — `avoid={COOKIE_BUTTON_AVOID}` (`'footer, [role="contentinfo"]'`) is exactly the old default (`bottomOverlap`). `false` = never move at all (also turns `clear` off) | -| `className` | — | replaces the default classes; position is then yours too (the `clear` step applies only while your classes keep it `position: fixed`) | +| `reserve` | `COOKIE_BUTTON_RESERVE` | CSS selector of the block that gets the room (the last match); `false` = no room — the button then covers what is in the corner at the end of the page | +| `avoid` | — | placement before 1.17.2: a CSS selector the button lifts above while it is on screen — `avoid={COOKIE_BUTTON_AVOID}` (`'footer, [role="contentinfo"]'`) is exactly the old default (`bottomOverlap`); no room is reserved then. `false` = the default (kept for sites that set it) | +| `className` | — | replaces the default classes; position is then yours too (room is measured from the real button once it is on the page, and only while it is `position: fixed`) | + +**Set the amount yourself:** `--ipal-cookie-button-space` on the footer — any length, added to the footer's own +padding instead of the measured amount; `0` = none, also per breakpoint: + +```css +footer { --ipal-cookie-button-space: 4rem; } +@media (min-width: 64rem) { footer { --ipal-cookie-button-space: 0; } } /* nothing on desktop */ +``` Position tokens: `--ipal-cookie-button-offset` (from the bottom, default `1rem`), `--ipal-cookie-button-inset` (from the side, default `1rem`); the device's safe-area insets (bottom and the chosen side) are added. z-index @@ -139,8 +154,10 @@ Position tokens: `--ipal-cookie-button-offset` (from the bottom, default `1rem`) Hidden while the banner is showing. Keyboard: a `