Files
ipal-kit/src/modules/consent/CookieButton.tsx
T
radoslaw.smolinskiandClaude Opus 5.5 ab854ef37a MCP site tools, Turnstile key alert, required 2FA injection, a11y, more tests
- MCP: new get_site_info and list_pages tools (public by design, published
  and indexable content only); search results collapse the homepage to root.
  New listContent() helper shared with searchContent.
- Dashboard alert when Turnstile is half-configured (it is silently off then).
- twoFactor.plugin is now required; the dynamic-import fallback (which never
  worked under Next and caused a Turbopack warning) is gone.
- a11y: cookie category checkboxes are labelled, buttons have type, test-email
  input is labelled; tab labels keep localized collection labels.
- IPAL_IP_HEADER: one-time production warning when unset, opt-in
  ipalEnvRules({ ipHeader: true }).
- Tests: SEO/robots/sitemap/hreflang, CSP, Markdown, consent, MCP, and a real
  Payload + SQLite integration test for forms and the roles guard (74 total).
- Drop unused mongodb-memory-server; dev .env.example for SQLite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 01:15:19 +02:00

48 lines
1.8 KiB
TypeScript

'use client'
import { Cookie } from 'lucide-react'
import { useConsentContext } from './ConsentContext.js'
import { useIsMounted } from './useIsMounted.js'
/**
* Floating "cookie settings" button — lets visitors reopen the consent panel
* after deciding (GDPR: withdrawing consent must be as easy as giving it).
* Hidden while the banner is showing.
*
* Colours follow the same CSS custom properties as CookieBanner
* (--ipal-surface, --ipal-border, --ipal-hover, --ipal-text), so a client's
* palette applies to both without touching either component. Pass className to
* replace the styling outright.
*/
export function CookieButton({ className }: { className?: string } = {}) {
const isMounted = useIsMounted()
const { decided, reopen, texts } = useConsentContext()
// Render nothing until mounted — prevents hydration mismatch (no project
// ConsentWrapper workaround needed).
if (!isMounted) {return null}
if (!decided) {return null}
const cls =
className ??
'fixed bottom-4 left-4 z-40 flex h-11 w-11 items-center justify-center rounded-full border shadow-md transition-colors ' +
'bg-[var(--ipal-surface,#fff)] border-[var(--ipal-border,#e5e5e5)] hover:bg-[var(--ipal-hover,#f5f5f5)] ' +
'dark:bg-[var(--ipal-surface-dark,#171717)] dark:border-[var(--ipal-border-dark,#262626)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]'
return (
<button
// a11y label per locale: the panel's "settings title" (Cookie Settings global)
aria-label={texts.settingsTitle}
className={cls}
data-ipal="cookie-button"
onClick={reopen}
type="button"
>
<Cookie
aria-hidden="true"
className="h-5 w-5 text-[var(--ipal-text,#525252)] dark:text-[var(--ipal-text-dark,#d4d4d4)]"
/>
</button>
)
}