feat(consent): integrate c15t v2 cookie consent with custom styling#278
feat(consent): integrate c15t v2 cookie consent with custom styling#278
Conversation
Adds a GDPR/TTDSG-compliant cookie consent layer on top of the existing design system, powered by @c15t/nextjs v2 and tuned to match the hero and newsletter sections of the site. Additions - ConsentManager provider (src/components/helpers/ConsentManager.tsx) with custom theme tokens/slots mirroring tailwind.config.ts, bilingual (EN/DE) copy via c15t i18n, legal-link wiring and opt-in GA4/gtag integration through @c15t/scripts (Google Consent Mode v2). - CookieControlCenter inline widget reusing the rounded two-column card from NewsletterCTA for consistent look & feel. - Dedicated /cookies page with a best-practice cookie policy (categories, legal basis per TTDSG/GDPR, retention, rights). - Script blocker is active by default: optional scripts only load after consent for their category; cfg via NEXT_PUBLIC_GA_ID. - CookieSettingsButton in footer + new Cookie Policy link. - Privacy page now cross-links to /cookies, embeds the control center and updates the legal basis for cookies. Infrastructure - Stylesheet import @c15t/nextjs/styles.tw3.css plus postcss-import so Tailwind 3 ordering stays valid. - Jest mocks for @c15t/nextjs and @c15t/scripts/* so existing component tests keep running under jsdom. - tsconfig moduleResolution bumped to 'bundler' to resolve the package's export map. Env - NEXT_PUBLIC_C15T_MODE, NEXT_PUBLIC_C15T_BACKEND_URL, NEXT_PUBLIC_GA_ID documented in .env.example (defaults to offline mode for zero-config). Co-authored-by: Domenik Töfflinger <dmnktoe@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #278 +/- ##
==========================================
- Coverage 64.77% 62.45% -2.33%
==========================================
Files 67 73 +6
Lines 758 807 +49
Branches 155 163 +8
==========================================
+ Hits 491 504 +13
- Misses 267 303 +36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Adds a GDPR/TTDSG-compliant cookie consent layer on top of the existing SENTIMENT design system, powered by
@c15t/nextjsv2. Styling is fully driven through c15t's theme tokens/slots so the banner, dialog and inline widget match the hero and newsletter section of the site (rounded cards onprimary/5, hover onprimary/20,CircularStdtypography, light/dark palette fromtailwind.config.ts).What the user gets
ConsentDialogwith category toggles, opened from the banner's "Customize" button or the footer's "Cookie settings" pill.theme.consentActions(accept = filled primary, customize = ghost, reject = neutral stroke)./cookiespage and on the existing privacy page (/privacy). Mirrors the newsletter CTA (NewsletterCTA) two-column rounded card, wrappingConsentWidgeton the right with explicit "Accept all / Reject non-essential / Reset my choice" actions on the left./cookies) — best-practice copy covering definition, legal basis (Art. 6 (1) lit. a/f GDPR, § 25 TTDSG), categories (necessary, measurement, marketing), third-party scripts, retention and user rights.c15tscript loader). Example wired in: Google Analytics via@c15t/scripts/google-tagwith automatic Google Consent Mode v2 defaults (denieduntil measurement is granted).Implementation details
New / touched files
src/components/helpers/ConsentManager.tsx— provider with custom theme (tokens + slots), bilingual (en/de) copy viaoptions.i18n, legal-link wiring, optional GA4 via@c15t/scripts/google-tag, and abuildOptions()helper that letsNEXT_PUBLIC_C15T_MODEtoggle betweenoffline(default, zero-config) andhosted.src/components/templates/CookiePolicy.tsx+src/app/cookies/page.tsx— dedicated/cookiesroute with the policy + inline control center.src/components/templates/CookieControlCenter.tsx— inline widget reusing the newsletter visual language.src/components/ui/CookieSettingsButton.tsx— small pill button that callssetActiveUI('dialog')to reopen preferences anywhere.src/components/layout/Footer.tsx— added a "Cookie settings" button and a "Cookie Policy" link.src/components/templates/Privacy.tsx— rewrote the cookies section, added section 3a with the inline control center.src/constant/consent.ts— readsNEXT_PUBLIC_C15T_MODE,NEXT_PUBLIC_C15T_BACKEND_URL,NEXT_PUBLIC_GA_ID.src/styles/globals.css+postcss.config.js— adds@import "@c15t/nextjs/styles.tw3.css"between@tailwind components;and@tailwind utilities;and installspostcss-importso the@importis inlined before the CSS nesting rules are generated.src/app/layout.tsx— wraps the tree with<ConsentManager>below theThemeProviderso the c15t store can observe the dark-mode class set bynext-themes..env.example— documents the new env vars.tsconfig.json—moduleResolutionbumped fromnodetobundlerso the c15t subpath exports (@c15t/scripts/google-tag) resolve.src/__mocks__/c15t-nextjs.tsx+src/__mocks__/c15t-scripts.ts+jest.config.js— jest mocks so the jsdom test environment does not try to loadnext/cachethrough the real package.Design tokens
Custom
Themeuses the SENTIMENT palette:primary#FF5C24#FF5C24surface#ffffff#121212surfaceHover#f2f2f2#222222text#121212#f5f5f5textMuted#8b9094#9ca3afSlots override
consentBannerCard,consentBannerFooter,consentDialogCard,consentWidgetAccordion,consentWidgetFooter,toggle, etc. to match the rounded/soft-shadow aesthetic.Consent categories
Three categories are exposed:
necessary,measurement,marketing. Mapping to Google Consent Mode v2 happens automatically via@c15t/scripts/google-tag.Environment
Verification
pnpm typecheck— ✓pnpm test— ✓ (378 tests, 30 suites)npx eslint src— ✓pnpm format:check— ✓pnpm buildfails only on the existing/articles/[slug]page because no Strapi CMS is reachable from the cloud VM; the CSS pipeline and all new routes compile cleanly.Next steps (optional, not in this PR)
NEXT_PUBLIC_C15T_MODE=hostedand pointNEXT_PUBLIC_C15T_BACKEND_URLat a consent.io instance (or self-hosted deployment) for durable consent records and jurisdiction auto-detection.NEXT_PUBLIC_GA_IDto activate GA4; no additional code change required.