Merge claude/cookie-button-bottom: the cookie button never moves; the footer keeps room under its last row (owner's option 3)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 12:08:57 +01:00
co-authored by Claude Opus 5.5
20 changed files with 763 additions and 321 deletions
+31 -14
View File
@@ -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 `<body>` (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 `<body>` (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 → `<body>` |
| 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 `<button>` in the tab order with an `aria-label` from the panel.
Type `CookieButtonProps`.
A footer that is full of links in that corner: choose `side="right"`, raise `--ipal-cookie-button-offset`, or give
the footer's last row some bottom padding — the button then rests there.
Nonce CSP: the inline script takes the nonce given to `SiteProviders` / `ConsentProvider`; refused, the room is made
when the button appears (a footer pinned to the bottom of a page shorter than the window then moves once).
Building blocks: `reserveCookieButtonSpace({ selector, side, button?, release? })`, `COOKIE_BUTTON_SPACE_ATTRIBUTE`
(`/client`), `consentDecidedScript` (root).
## Compliance defaults (1.17.0)
@@ -471,7 +488,7 @@ New fields in the global = a migration in projects on Postgres/SQLite (`payload
The elements also have stable `data-ipal` handles for CSS and e2e tests (used by
`iapl-consent-check`): `banner` (while it waits for the first-paint script it carries `hidden`; a button clicked before hydration:
`data-ipal-pending`; live: `data-ipal-ready`), `banner-script`, `cookie-button` and the buttons `settings`, `reject`,
`data-ipal-pending`; live: `data-ipal-ready`), `banner-script`, `cookie-button` (`cookie-button-script`: its inline script in the server HTML; `data-ipal-cookie-space` on the footer while it holds the button's room) and the buttons `settings`, `reject`,
`accept`, `back`, `save`; in modal mode also `consent-overlay`, `consent-dialog`, `close`; in detailed mode
additionally `category-<category>` (card) and `cookies` (expandable list).