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:
@@ -42,6 +42,23 @@ once there are more than 20.
|
||||
- Not built (owner's Q3 answer (a), planned for 2.0): a plugin-wide default for the project's own entities and for
|
||||
Payload's `payload-locked-documents`.
|
||||
|
||||
### 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:
|
||||
`<CookieButton avoid={COOKIE_BUTTON_AVOID} />` (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.
|
||||
|
||||
### Added
|
||||
- `CookieButton` prop `clear` (selector of controls freed at the end of the page; `false` = off), `COOKIE_BUTTON_CLEAR`,
|
||||
`stepAbove` (`/client`).
|
||||
|
||||
## 1.17.1 — security fixes from the IAWL review; the panel's sign-in look; the sending method is chosen
|
||||
|
||||
> **Read before upgrading.** **MongoDB: no migration. Postgres / SQLite: one migration** — a new column for the
|
||||
|
||||
@@ -1167,6 +1167,7 @@ project → **plugin gap**, not a copy.
|
||||
|---|---|---|
|
||||
| Banner, settings, cookie button | `<SiteProviders banner={<CookieBanner …/>}>`, `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" |
|
||||
| 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 <page> \| 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 | `<CookieBanner settings="inline" \| "modal" \| "detailed">` — do not build your own window or cookie list | consent.md → "Large window with details" |
|
||||
| A consent-dependent script | `ConsentScript` | consent.md |
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -168,8 +168,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.
|
||||
|
||||
+28
-6
@@ -113,12 +113,34 @@ takes `locale` and optional `labels`; defaults: `COOKIE_TABLE_LABELS` (`@intecio
|
||||
| `controls` | `'checkbox'` | `'checkbox' \| 'switch'` |
|
||||
| `settingsActions` | `['back', 'save']` | buttons under the categories (`'accept' \| 'back' \| 'reject' \| 'save'`) |
|
||||
|
||||
`CookieButton` props: `className` (replaces the default classes; position is then yours too),
|
||||
`side` (`'left'` default or `'right'`), `avoid` (CSS selector, default `COOKIE_BUTTON_AVOID` =
|
||||
`'footer, [role="contentinfo"]'`; `false` = never move). While the footer is on screen the button
|
||||
moves up by its visible part (`bottomOverlap`), so it never covers footer links. Position tokens:
|
||||
`--ipal-cookie-button-offset` (from the bottom, default `1rem`), `--ipal-cookie-button-inset` (from the
|
||||
side, default `1rem`); z-index `--ipal-z-header`. Type `CookieButtonProps`.
|
||||
### 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).
|
||||
|
||||
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.
|
||||
|
||||
| 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`) |
|
||||
|
||||
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
|
||||
`--ipal-z-header` (default 40): above the page, below the banner, the settings window and the lightbox (50).
|
||||
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.
|
||||
|
||||
## Compliance defaults (1.17.0)
|
||||
|
||||
|
||||
@@ -690,6 +690,7 @@ Do one item at a time, build, check. Order by importance:
|
||||
| 80 | **1.17.1 — the sign-in look** — after the update the login and 2FA screens show a dark panel with the logo or the site's name; an editor cannot change the logo or name; forgot / reset password look as before | Nothing required. `whiteLabel: { signIn: false }` (old screens), `{ brandAccess: 'editor' }`, `{ signIn: { logoPlate: true } }` (a dark logo), `{ signIn: { svgLogo: false } }`; the other screens: `signIn: { allScreens: true }` + `pnpm payload generate:importmap`. No `serverURL` → no logo in the link preview: set it | `iapl-upgrade` "→ 1.17.1, the sign-in look", white-label.md "The sign-in screens" |
|
||||
| 81 | **1.17.1 — proxy matcher** — `iapl-doctor` warns `proxy-matcher`; pages such as `/administracja` or `/apis` get no locale redirect or proxy CSP | `src/proxy.ts`: `matcher: ['/((?!(?:api|admin|_next)(?:/|$)|.*\\..*).*)']` (i18n.md "Next matcher") | `iapl-upgrade` "→ 1.17.1" |
|
||||
| 82 | **1.17.1 — e-mail: "Sending method" is a choice** — Site integrations → E-mail sending shows "IWSN (built-in)", "Own SMTP server" or "Microsoft Graph (deprecated)" as selected; or, on Postgres / SQLite, the start log says the column for `emailMethod` is missing and the Site integrations page does not open; or mail fails with `smtp-incomplete` / `graph-not-set-up` | MongoDB: nothing. Postgres / SQLite: `pnpm payload migrate:create`, commit, apply at start. Nothing changes until another option is picked and saved; a chosen method that cannot be used fails loudly (no other transport): fill in SMTP, set `GRAPH_*`, or pick another method | `iapl-upgrade` "→ 1.17.1, e-mail", email.md "Which transport a send takes" |
|
||||
| 83 | **1.17.2 — cookie button** — after the update the "cookie settings" button no longer sits above the footer; or at the end of a page on a phone it rests a little above the corner | Intended: it stays in the bottom corner of the window on every page and, at the very end of the page, steps just above a link or button it would keep covered. Nothing to run. The placement before: `<CookieButton avoid={COOKIE_BUTTON_AVOID} />`; never move: `avoid={false}`; other corner: `side="right"`; distance: `--ipal-cookie-button-offset` | consent.md "Where the cookie button sits", `iapl-upgrade` "→ 1.17.2, cookie button" |
|
||||
|
||||
After updating the package: `pnpm exec iapl-skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
|
||||
`node_modules/@intecion/ipal-kit/dist`.
|
||||
|
||||
@@ -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/)
|
||||
|
||||
@@ -24,10 +24,12 @@ export {
|
||||
ConsentProvider,
|
||||
ConsentScript,
|
||||
COOKIE_BUTTON_AVOID,
|
||||
COOKIE_BUTTON_CLEAR,
|
||||
CookieBanner,
|
||||
CookieButton,
|
||||
readEffectiveConsent,
|
||||
signalVendors,
|
||||
stepAbove,
|
||||
useConsent,
|
||||
useConsentContext,
|
||||
} from '../modules/consent/client.js'
|
||||
|
||||
@@ -6,17 +6,30 @@ import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { useConsentContext } from './ConsentContext.js'
|
||||
|
||||
/** Elements the button moves up for, so it never covers footer links. */
|
||||
/**
|
||||
* The site footer: the selector of the placement before 1.17.2, when the button moved up by the visible part of
|
||||
* the footer. `<CookieButton avoid={COOKIE_BUTTON_AVOID} />` brings that placement back.
|
||||
*/
|
||||
export const COOKIE_BUTTON_AVOID = 'footer, [role="contentinfo"]'
|
||||
|
||||
/** Controls the button never stays on top of once the page cannot be scrolled any further. */
|
||||
export const COOKIE_BUTTON_CLEAR = 'a[href], button, input, select, textarea, summary, [role="button"], [role="link"]'
|
||||
|
||||
export type CookieButtonProps = {
|
||||
/**
|
||||
* CSS selector of elements the button lifts above while they are on screen
|
||||
* (default: the site footer). `false` = never move.
|
||||
* Placement before 1.17.2: a CSS selector of elements the button lifts above while they are on screen
|
||||
* (`COOKIE_BUTTON_AVOID` = the site footer). Default: none — the button stays in the bottom corner of the
|
||||
* window. `false` = never move at all (also turns `clear` off).
|
||||
*/
|
||||
avoid?: false | string
|
||||
/** Replaces the default classes (look and position). The lift above `avoid` still applies. */
|
||||
/** Replaces the default classes (look and position). The lift above `avoid` and the step of `clear` still apply. */
|
||||
className?: string
|
||||
/**
|
||||
* CSS selector of controls the button must not keep covered. Only at the very end of the page (where a visitor
|
||||
* cannot scroll a covered link out from under it) the button steps up just far enough to free them. Default
|
||||
* `COOKIE_BUTTON_CLEAR` (links, buttons, form fields). `false` = stay in the corner whatever is under it.
|
||||
*/
|
||||
clear?: false | string
|
||||
/** Corner. Default 'left'. */
|
||||
side?: 'left' | 'right'
|
||||
}
|
||||
@@ -26,15 +39,20 @@ export type CookieButtonProps = {
|
||||
* after deciding (GDPR: withdrawing consent must be as easy as giving it).
|
||||
* Hidden while the banner is showing.
|
||||
*
|
||||
* Placement (1.17.2): fixed in the bottom corner of the window, on every page and at every scroll position — it
|
||||
* does not climb above the footer any more. At the very end of the page, if it would lie on a link or a button
|
||||
* there (a footer link in that corner), it steps up just above it, so nothing stays unreachable. The placement
|
||||
* before 1.17.2 (riding on the footer's top edge): `avoid={COOKIE_BUTTON_AVOID}`.
|
||||
*
|
||||
* Colours follow the same design tokens as CookieBanner (--ipal-surface,
|
||||
* --ipal-border, --ipal-hover, --ipal-text). Position: --ipal-cookie-button-offset
|
||||
* (distance from the bottom, default 1rem), --ipal-cookie-button-inset (from the
|
||||
* side, default 1rem), z-index --ipal-z-header. When the footer scrolls into
|
||||
* view the button moves up by the visible part of it, so footer links stay free.
|
||||
* side, default 1rem), both plus the device's safe-area inset; z-index --ipal-z-header (below the banner and dialogs).
|
||||
*/
|
||||
export function CookieButton({ avoid = COOKIE_BUTTON_AVOID, className, side = 'left' }: CookieButtonProps = {}) {
|
||||
export function CookieButton({ avoid, className, clear = COOKIE_BUTTON_CLEAR, side = 'left' }: CookieButtonProps = {}) {
|
||||
const { decided, reopen, texts } = useConsentContext()
|
||||
const lift = useLiftAbove(avoid, decided)
|
||||
const buttonRef = useRef<HTMLButtonElement>(null)
|
||||
const lift = useLift({ active: decided, avoid: avoid ?? false, buttonRef, clear: avoid === undefined ? clear : false })
|
||||
|
||||
// `decided` is the server's value while hydrating (no decision on a static page, so nothing is rendered — or the
|
||||
// cookie the server read, <ConsentProvider cookieValue>, and then the button is in the HTML), the browser's after.
|
||||
@@ -50,7 +68,7 @@ export function CookieButton({ avoid = COOKIE_BUTTON_AVOID, className, side = 'l
|
||||
: {
|
||||
bottom: 'calc(var(--ipal-cookie-button-offset, 1rem) + env(safe-area-inset-bottom, 0px))',
|
||||
position: 'fixed',
|
||||
[side]: 'var(--ipal-cookie-button-inset, 1rem)',
|
||||
[side]: `calc(var(--ipal-cookie-button-inset, 1rem) + env(safe-area-inset-${side}, 0px))`,
|
||||
zIndex: 'var(--ipal-z-header, 40)' as unknown as number,
|
||||
}
|
||||
|
||||
@@ -61,6 +79,7 @@ export function CookieButton({ avoid = COOKIE_BUTTON_AVOID, className, side = 'l
|
||||
className={cls}
|
||||
data-ipal="cookie-button"
|
||||
onClick={reopen}
|
||||
ref={buttonRef}
|
||||
style={{ ...position, ...(lift ? { transform: `translateY(-${lift}px)` } : {}) }}
|
||||
type="button"
|
||||
>
|
||||
@@ -79,16 +98,67 @@ export function bottomOverlap(tops: number[], viewportHeight: number): number {
|
||||
return Math.max(0, Math.min(viewportHeight - top, viewportHeight - 96))
|
||||
}
|
||||
|
||||
function useLiftAbove(selector: false | string, active: boolean): number {
|
||||
type Box = { bottom: number; left: number; right: number; top: number }
|
||||
|
||||
/** Space kept between the button and a control it stepped above. */
|
||||
const CLEAR_GAP = 8
|
||||
|
||||
/**
|
||||
* How far the button must move up so that it lies on none of `obstacles` (boxes in viewport pixels; `button` is the
|
||||
* button's box in its resting place). 0 when nothing is under it — and 0 when no free place exists within `max`:
|
||||
* better in its corner than wandering over the page.
|
||||
*/
|
||||
export function stepAbove(button: Box, obstacles: Box[], max: number): number {
|
||||
let lift = 0
|
||||
// each pass clears the lowest control still under the button; a control is passed at most once
|
||||
for (let pass = 0; pass <= obstacles.length; pass++) {
|
||||
const top = button.top - lift
|
||||
const bottom = button.bottom - lift
|
||||
const hit = obstacles.filter((o) => o.right > button.left && o.left < button.right && o.bottom > top && o.top < bottom)
|
||||
if (!hit.length) {return lift}
|
||||
lift = button.bottom - Math.min(...hit.map((o) => o.top)) + CLEAR_GAP
|
||||
if (lift > max) {return 0}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type LiftOptions = {
|
||||
active: boolean
|
||||
avoid: false | string
|
||||
buttonRef: { current: HTMLButtonElement | null }
|
||||
clear: false | string
|
||||
}
|
||||
|
||||
function useLift({ active, avoid, buttonRef, clear }: LiftOptions): number {
|
||||
const [lift, setLift] = useState(0)
|
||||
const applied = useRef(0)
|
||||
const frame = useRef(0)
|
||||
useEffect(() => {
|
||||
if (!selector || !active) {return}
|
||||
if (!active || (!avoid && !clear)) {return}
|
||||
const set = (value: number) => {
|
||||
applied.current = value
|
||||
setLift(value)
|
||||
}
|
||||
const measure = () => {
|
||||
cancelAnimationFrame(frame.current)
|
||||
frame.current = requestAnimationFrame(() => {
|
||||
const tops = [...document.querySelectorAll(selector)].map((el) => el.getBoundingClientRect().top)
|
||||
setLift(bottomOverlap(tops, window.innerHeight))
|
||||
if (avoid) {
|
||||
const tops = [...document.querySelectorAll(avoid)].map((el) => el.getBoundingClientRect().top)
|
||||
return set(bottomOverlap(tops, window.innerHeight))
|
||||
}
|
||||
const button = buttonRef.current
|
||||
const page = document.documentElement
|
||||
// Anywhere else a covered control is one scroll away; at the end of the page it would stay covered.
|
||||
const atEnd = window.innerHeight + window.scrollY >= page.scrollHeight - 2
|
||||
if (!button || !clear || !atEnd || getComputedStyle(button).position !== 'fixed') {return set(0)}
|
||||
const now = button.getBoundingClientRect()
|
||||
// the resting place: the measured box without the step the button has already taken
|
||||
const rest = { bottom: now.bottom + applied.current, left: now.left, right: now.right, top: now.top + applied.current }
|
||||
const obstacles = [...document.querySelectorAll(clear)]
|
||||
.filter((el) => el !== button && !button.contains(el))
|
||||
.map((el) => el.getBoundingClientRect())
|
||||
.filter((box) => box.width > 0 && box.height > 0)
|
||||
set(stepAbove(rest, obstacles, window.innerHeight / 2))
|
||||
})
|
||||
}
|
||||
measure()
|
||||
@@ -102,6 +172,6 @@ function useLiftAbove(selector: false | string, active: boolean): number {
|
||||
window.removeEventListener('resize', measure)
|
||||
observer?.disconnect()
|
||||
}
|
||||
}, [selector, active])
|
||||
return selector ? lift : 0
|
||||
}, [active, avoid, buttonRef, clear])
|
||||
return active && (avoid || clear) ? lift : 0
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ export { ConsentScript } from './ConsentScript.js'
|
||||
export { readEffectiveConsent } from './consentStore.js'
|
||||
export { CookieBanner } from './CookieBanner.js'
|
||||
export type { CookieBannerAction, CookieBannerClassNames, CookieSettingsAction } from './CookieBanner.js'
|
||||
export { bottomOverlap, COOKIE_BUTTON_AVOID, CookieButton } from './CookieButton.js'
|
||||
export { bottomOverlap, COOKIE_BUTTON_AVOID, COOKIE_BUTTON_CLEAR, CookieButton, stepAbove } from './CookieButton.js'
|
||||
export type { CookieButtonProps } from './CookieButton.js'
|
||||
// Client-only consent exports — hook, provider, and UI components.
|
||||
export { DEFAULT_COOKIE_MAP, useConsent } from './useConsent.js'
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
// @vitest-environment happy-dom
|
||||
/**
|
||||
* Where <CookieButton> sits (1.17.2): the bottom corner of the window, always — it does not climb above the footer.
|
||||
* Only at the very end of the page it steps above a control it would keep covered. The placement before 1.17.2
|
||||
* (above the footer) and "never move" stay available.
|
||||
*/
|
||||
import { act, createElement, type ReactElement } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { ConsentProvider } from '../src/modules/consent/ConsentContext.js'
|
||||
import { resetConsentStore } from '../src/modules/consent/consentStore.js'
|
||||
import { COOKIE_BUTTON_AVOID, COOKIE_BUTTON_CLEAR, CookieButton, stepAbove } from '../src/modules/consent/CookieButton.js'
|
||||
import { CONSENT_FALLBACK } from '../src/modules/consent/getConsentTexts.js'
|
||||
import { CONSENT_COOKIE, serializeConsent } from '../src/modules/consent/storage.js'
|
||||
|
||||
const h = createElement as unknown as (type: unknown, props?: null | object, ...children: unknown[]) => ReactElement
|
||||
|
||||
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
||||
|
||||
const box = (top: number, bottom: number, left = 16, right = 60) => ({ bottom, left, right, top })
|
||||
/** The button's resting place in an 800 px high window: 44 px, 16 px from the bottom and the left. */
|
||||
const REST = box(740, 784)
|
||||
|
||||
describe('stepAbove', () => {
|
||||
test('nothing under the button: stays', () => {
|
||||
expect(stepAbove(REST, [], 400)).toBe(0)
|
||||
expect(stepAbove(REST, [box(700, 730), box(750, 780, 200, 300), box(790, 800)], 400)).toBe(0)
|
||||
})
|
||||
|
||||
test('a link under it: just above the link, with a gap', () => {
|
||||
expect(stepAbove(REST, [box(760, 780, 30, 120)], 400)).toBe(784 - 760 + 8)
|
||||
})
|
||||
|
||||
test('two rows of links: above both, onto text', () => {
|
||||
// social links at 760–780, legal links at 724–744: clearing the first lands on the second
|
||||
expect(stepAbove(REST, [box(760, 780, 30, 120), box(724, 744, 30, 200)], 400)).toBe(784 - 724 + 8)
|
||||
})
|
||||
|
||||
test('no free place within the limit: back to the corner', () => {
|
||||
const wall = Array.from({ length: 20 }, (_, i) => box(780 - (i + 1) * 30, 780 - i * 30))
|
||||
expect(stepAbove(REST, wall, 400)).toBe(0)
|
||||
expect(stepAbove(REST, [box(300, 790)], 400)).toBe(0)
|
||||
})
|
||||
|
||||
test('the default list of controls', () => {
|
||||
for (const selector of ['a[href]', 'button', 'input', 'select', 'textarea', 'summary']) {expect(COOKIE_BUTTON_CLEAR).toContain(selector)}
|
||||
})
|
||||
})
|
||||
|
||||
describe('placement', () => {
|
||||
let container: HTMLDivElement
|
||||
let root: Root
|
||||
let rects: Map<Element, ReturnType<typeof box>>
|
||||
let page: { height: number; scrollY: number }
|
||||
|
||||
const setRect = (el: Element, r: ReturnType<typeof box>) => rects.set(el, r)
|
||||
const button = () => document.querySelector<HTMLButtonElement>('[data-ipal="cookie-button"]')!
|
||||
const lift = () => /translateY\(-(?<px>[\d.]+)px\)/.exec(button().style.transform)?.groups?.px ?? '0'
|
||||
const frame = () => act(() => new Promise((resolve) => setTimeout(resolve, 40)))
|
||||
const scrollTo = async (y: number) => {
|
||||
page.scrollY = y
|
||||
window.dispatchEvent(new Event('scroll'))
|
||||
await frame()
|
||||
}
|
||||
const add = (html: string) => {
|
||||
const el = document.createElement('div')
|
||||
el.innerHTML = html
|
||||
document.body.appendChild(el)
|
||||
return el.firstElementChild!
|
||||
}
|
||||
const mount = async (props: object = {}) => {
|
||||
act(() => root.render(h(ConsentProvider, { texts: CONSENT_FALLBACK }, h(CookieButton, props))))
|
||||
setRect(button(), REST)
|
||||
window.dispatchEvent(new Event('resize'))
|
||||
await frame()
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
resetConsentStore()
|
||||
document.cookie = `${CONSENT_COOKIE}=${serializeConsent({ analytics: false, functional: false, marketing: false, necessary: true })};path=/`
|
||||
rects = new Map()
|
||||
page = { height: 3000, scrollY: 0 }
|
||||
vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {
|
||||
const r = rects.get(this) ?? { bottom: 0, left: 0, right: 0, top: 0 }
|
||||
// like the browser: the measured box includes the transform the button carries
|
||||
const moved = this === document.querySelector('[data-ipal="cookie-button"]') ? Number(/translateY\(-([\d.]+)px\)/.exec((this as HTMLElement).style.transform)?.[1] ?? 0) : 0
|
||||
return { ...r, bottom: r.bottom - moved, height: r.bottom - r.top, top: r.top - moved, width: r.right - r.left, x: r.left, y: r.top - moved } as DOMRect
|
||||
})
|
||||
vi.spyOn(window, 'innerHeight', 'get').mockReturnValue(800)
|
||||
vi.spyOn(window, 'scrollY', 'get').mockImplementation(() => page.scrollY)
|
||||
vi.spyOn(document.documentElement, 'scrollHeight', 'get').mockImplementation(() => page.height)
|
||||
container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
root = createRoot(container)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
act(() => root.unmount())
|
||||
document.body.innerHTML = ''
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
test('default: fixed in the bottom corner with the safe-area insets, below dialogs', async () => {
|
||||
await mount()
|
||||
const style = button().style
|
||||
expect(style.position).toBe('fixed')
|
||||
expect(style.bottom).toBe('calc(var(--ipal-cookie-button-offset, 1rem) + env(safe-area-inset-bottom, 0px))')
|
||||
expect(style.left).toBe('calc(var(--ipal-cookie-button-inset, 1rem) + env(safe-area-inset-left, 0px))')
|
||||
expect(style.zIndex).toBe('var(--ipal-z-header, 40)')
|
||||
expect(button().getAttribute('aria-label')).toBe(CONSENT_FALLBACK.settingsTitle)
|
||||
expect(button().type).toBe('button')
|
||||
})
|
||||
|
||||
test('side="right": the right corner and its safe-area inset', async () => {
|
||||
await mount({ side: 'right' })
|
||||
expect(button().style.right).toBe('calc(var(--ipal-cookie-button-inset, 1rem) + env(safe-area-inset-right, 0px))')
|
||||
expect(button().style.left).toBe('')
|
||||
})
|
||||
|
||||
test('default: the footer on screen does not move it (before 1.17.2 it rode up by 300 px here)', async () => {
|
||||
setRect(add('<footer>company</footer>'), box(500, 1100, 0, 1280))
|
||||
await mount()
|
||||
await scrollTo(1500)
|
||||
expect(lift()).toBe('0')
|
||||
})
|
||||
|
||||
test('avoid={COOKIE_BUTTON_AVOID}: the placement before 1.17.2, above the footer', async () => {
|
||||
setRect(add('<footer>company</footer>'), box(500, 1100, 0, 1280))
|
||||
await mount({ avoid: COOKIE_BUTTON_AVOID })
|
||||
expect(lift()).toBe('300')
|
||||
})
|
||||
|
||||
test('end of the page, a footer link in the corner: steps just above it; scrolling back up: returns to the corner', async () => {
|
||||
const link = add('<a href="/x">Instagram</a>')
|
||||
setRect(link, box(760, 780, 30, 120))
|
||||
await mount()
|
||||
await scrollTo(1000) // mid-page: a covered link is one scroll away, the button stays
|
||||
expect(lift()).toBe('0')
|
||||
await scrollTo(2200) // 2200 + 800 = the end
|
||||
expect(lift()).toBe('32')
|
||||
await scrollTo(2200) // measured again while lifted: the same step, no creeping
|
||||
expect(lift()).toBe('32')
|
||||
await scrollTo(1000)
|
||||
expect(lift()).toBe('0')
|
||||
})
|
||||
|
||||
test('a page shorter than the window is always at its end', async () => {
|
||||
page.height = 800
|
||||
setRect(add('<button>Send</button>'), box(750, 790, 20, 140))
|
||||
await mount()
|
||||
expect(lift()).toBe('42')
|
||||
})
|
||||
|
||||
test('end of the page, nothing under it (text only): stays in the corner', async () => {
|
||||
setRect(add('<p>© Example</p>'), box(760, 780, 30, 400))
|
||||
setRect(add('<a href="/y">Terms</a>'), box(760, 780, 900, 960))
|
||||
await mount()
|
||||
await scrollTo(2200)
|
||||
expect(lift()).toBe('0')
|
||||
})
|
||||
|
||||
test('clear={false} and avoid={false}: never moves', async () => {
|
||||
setRect(add('<a href="/x">Instagram</a>'), box(760, 780, 30, 120))
|
||||
setRect(add('<footer>company</footer>'), box(500, 1100, 0, 1280))
|
||||
await mount({ clear: false })
|
||||
await scrollTo(2200)
|
||||
expect(lift()).toBe('0')
|
||||
act(() => root.render(h(ConsentProvider, { texts: CONSENT_FALLBACK }, h(CookieButton, { avoid: false }))))
|
||||
await scrollTo(2200)
|
||||
expect(lift()).toBe('0')
|
||||
})
|
||||
|
||||
test('a selector of your own in clear', async () => {
|
||||
setRect(add('<a href="/x">Instagram</a>'), box(760, 780, 30, 120))
|
||||
setRect(add('<div class="chat">chat</div>'), box(700, 790, 10, 70))
|
||||
await mount({ clear: '.chat' })
|
||||
await scrollTo(2200)
|
||||
expect(lift()).toBe(String(784 - 700 + 8))
|
||||
})
|
||||
|
||||
test('className (the project positions it, here not fixed): no step', async () => {
|
||||
setRect(add('<a href="/x">Instagram</a>'), box(760, 780, 30, 120))
|
||||
await mount({ className: 'in-the-footer' })
|
||||
expect(button().style.position).toBe('')
|
||||
await scrollTo(2200)
|
||||
expect(lift()).toBe('0')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user