Merge claude/cookie-button-bottom: the cookie button stays in the bottom corner of the window
Conflicts in the 1.17.2 changelog draft and the upgrade skill: both sides kept (rewritten into one entry at release). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -55,6 +55,12 @@ before analytics or marketing consent — check the project's choice in "Project
|
||||
`nonce` to `<SiteProviders>`. A visitor who decided must never see the banner on reload; one whose
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
@@ -165,8 +165,9 @@ 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. Props `className`, `side` (`'left' \| 'right'`), `avoid` (selector it lifts above, default `COOKIE_BUTTON_AVOID` = footer; `false`). Tokens `--ipal-cookie-button-offset`, `--ipal-cookie-button-inset`. Type `CookieButtonProps`. |
|
||||
| `COOKIE_BUTTON_AVOID`, `bottomOverlap(tops, viewportHeight)` | `@intecion/ipal-kit/client` | Default footer selector; pixels the footer covers at the bottom of the screen (how far the button moves up) |
|
||||
| `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`. |
|
||||
| `COOKIE_BUTTON_AVOID`, `bottomOverlap(tops, viewportHeight)` | `@intecion/ipal-kit/client` | Footer selector for the placement before 1.17.2 (`<CookieButton avoid={COOKIE_BUTTON_AVOID} />`); 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`) |
|
||||
| `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`). |
|
||||
|
||||
@@ -34,6 +34,14 @@ the header, 200 with it. (2) A front end that posted to `/api/form-submissions`
|
||||
(3) A site with a visitor login collection: `iapl-doctor --url …` lists `visitor-writes`; give each listed collection
|
||||
and global its own write rule (`adminOrEditor`). (4) If the project has `tests/routes.ts`: `update`, judge, commit.
|
||||
|
||||
**→ 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={<CookieButton avoid={COOKIE_BUTTON_AVOID} />}` 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.
|
||||
|
||||
**→ 1.17.1:** (1) `src/proxy.ts`: replace the matcher literal with
|
||||
`['/((?!(?:api|admin|_next)(?:/|$)|.*\\..*).*)']` (i18n.md "Next matcher"; `iapl-doctor` rule `proxy-matcher`).
|
||||
The old one skipped every page whose first segment only starts with `api`, `admin` or `_next` (`/administracja`):
|
||||
@@ -261,7 +269,7 @@ and the browser tab shows the same separator.
|
||||
cookie banner only through `--ipal-*-dark`: check the banner in the dark theme.
|
||||
4. Optional: the block library, block by block (block-library.md); after turning blocks on: `pnpm generate:types`,
|
||||
`pnpm payload generate:importmap`, Postgres/SQLite `migrate:create`.
|
||||
5. **CookieButton** lifts above the footer — check a site with its own fixed footer bar; `avoid={false}` keeps it fixed.
|
||||
5. **CookieButton** lifts above the footer — check a site with its own fixed footer bar; `avoid={false}` keeps it fixed. (Since 1.17.2 it stays in the bottom corner by default; the lift is `avoid={COOKIE_BUTTON_AVOID}`.)
|
||||
6. `pnpm exec iapl-skills` (new **iapl-doctor**; updated iapl-reference, iapl-setup, iapl-site, iapl-audit).
|
||||
7. Run `pnpm exec iapl-doctor` (and `--url https://<site>`), fix or silence each finding with a reason in
|
||||
`iapl-doctor.json`. `IAPL_DOCTOR_TOKEN` (≥ 32 characters) only if the deep check runs against production.
|
||||
|
||||
@@ -493,6 +493,70 @@ test('consent: withdrawal — reopen, reject: analytics cookies and listed stora
|
||||
expect((await consentRecord(context))!.state).toMatchObject({ analytics: false, functional: false, marketing: false })
|
||||
})
|
||||
|
||||
// The "cookie settings" button stays in the bottom corner of the window (1.17.2): it does not climb above the footer.
|
||||
// At the very end of the page it steps above a link it would keep covered.
|
||||
for (const device of [
|
||||
{ name: 'desktop', viewport: { height: 800, width: 1280 } },
|
||||
{ name: 'phone', viewport: { height: 844, width: 390 } },
|
||||
]) {
|
||||
test(`cookie button, ${device.name}: bottom corner on long and short pages, never on a link at the page end, no layout shift`, async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: device.viewport })
|
||||
const page = await context.newPage()
|
||||
await page.addInitScript(() => {
|
||||
const w = window as unknown as { __cls: number }
|
||||
w.__cls = 0
|
||||
new PerformanceObserver((list) => {
|
||||
for (const entry of list.getEntries() as unknown as { hadRecentInput: boolean; value: number }[]) {
|
||||
if (!entry.hadRecentInput) {w.__cls += entry.value}
|
||||
}
|
||||
}).observe({ buffered: true, type: 'layout-shift' })
|
||||
})
|
||||
await page.goto('/pl')
|
||||
await page.locator('[data-ipal="reject"]').click()
|
||||
const button = page.locator('[data-ipal="cookie-button"]')
|
||||
const probe = () =>
|
||||
button.evaluate((b: HTMLElement) => {
|
||||
const r = b.getBoundingClientRect()
|
||||
b.style.pointerEvents = 'none'
|
||||
const covered = [[r.left + 4, r.top + 4], [r.right - 4, r.top + 4], [r.left + 4, r.bottom - 4], [r.right - 4, r.bottom - 4], [r.left + r.width / 2, r.top + r.height / 2]]
|
||||
.map(([x, y]) => document.elementFromPoint(x, y)?.closest('a, button, input, select, textarea, summary'))
|
||||
.filter(Boolean)
|
||||
.map((el) => (el!.textContent ?? '').trim().slice(0, 30))
|
||||
b.style.pointerEvents = ''
|
||||
return { covered, gap: Math.round(window.innerHeight - r.bottom), inFooter: !!b.closest('footer'), left: Math.round(r.left), position: getComputedStyle(b).position }
|
||||
})
|
||||
for (const path of ['/pl', '/pl/regulamin', '/pl/kontakt']) {
|
||||
await page.goto(path)
|
||||
await expect(button).toBeVisible()
|
||||
const shifts = () => page.evaluate(() => (window as unknown as { __cls: number }).__cls)
|
||||
await page.waitForTimeout(300)
|
||||
const before = await shifts()
|
||||
const height = await page.evaluate(() => document.documentElement.scrollHeight)
|
||||
for (const y of [0, Math.max(0, (height - device.viewport.height) / 2)]) {
|
||||
await page.evaluate((to) => window.scrollTo(0, to), y)
|
||||
await page.waitForTimeout(350)
|
||||
if (y + device.viewport.height < height - 2) {
|
||||
// anywhere above the end of the page: exactly in the corner, the footer in view or not
|
||||
expect(await probe(), `${path} at ${Math.round(y)}`).toMatchObject({ gap: 16, inFooter: false, left: 16, position: 'fixed' })
|
||||
}
|
||||
}
|
||||
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight))
|
||||
await page.waitForTimeout(450)
|
||||
const end = await probe()
|
||||
expect(end, `${path} at the end`).toMatchObject({ covered: [], inFooter: false, left: 16, position: 'fixed' })
|
||||
expect(end.gap, `${path}: still at the bottom, not above the footer`).toBeLessThan(120)
|
||||
expect((await shifts()) - before, `${path}: layout shift while scrolling`).toBeLessThan(0.001)
|
||||
}
|
||||
// keyboard: reachable and it reopens the banner
|
||||
await button.focus()
|
||||
await expect(button).toBeFocused()
|
||||
await page.keyboard.press('Enter')
|
||||
await expect(page.locator('[data-ipal="banner"]')).toBeVisible()
|
||||
await expect(button).toHaveCount(0)
|
||||
await context.close()
|
||||
})
|
||||
}
|
||||
|
||||
test('admin: sign in through 2FA, agency credit, panel link preview', async ({ page, request }) => {
|
||||
const head = await (await request.get('/admin/login')).text()
|
||||
expect(head).toMatch(/noindex/)
|
||||
|
||||
Reference in New Issue
Block a user