Add GoogleMapsEmbed.tsx — consent-gated Maps embed, prepared but unused

Uses Klaro's own built-in contextual-consent mechanism (not
loadTrackingCode.ts's script-injection path) — the iframe renders
with data-name="google-maps" and its real src; Klaro's DOM scan finds
it after mount and blanks/restores src based on that service's
consent state, showing its own placeholder (styled via
KlaroConsentManager.tsx's KlaroTheme) in the meantime.

No map embedded anywhere in the app yet — this is prep work only, per
explicit request ahead of an actual page needing one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-08-01 21:58:19 +00:00
parent 417bbd430e
commit ac6c3d6b71
6 changed files with 122 additions and 2 deletions
+21
View File
@@ -28,7 +28,16 @@ export type KlaroConfig = {
}[];
};
// "google-maps" is a fixed name, not id-based like every other provider —
// GoogleMapsEmbed.tsx has to hardcode a `data-name` matching this exact
// string for Klaro's own contextual-consent DOM scan
// (renderContextualConsentNotices in node_modules/klaro) to find it, and
// there's no per-row distinguishing ID the way GA/FB/GTM each have one
// (a Maps embed URL is per-page, not stored on this row at all — see
// TrackingCodes.ts's own field comment). Only ever create ONE
// google-maps row in the admin; a second one would collide on this name.
export function serviceName(code: TrackingCode): string {
if (code.provider === "google-maps") return "google-maps";
return `tracking-code-${code.id}`;
}
@@ -40,6 +49,8 @@ function providerTitle(code: TrackingCode): string {
return "Facebook Pixel";
case "google-tag-manager":
return "Google Tag Manager";
case "google-maps":
return "Google Maps";
default:
return "Sonstiges Tracking-Skript";
}
@@ -116,6 +127,7 @@ export function buildKlaroConfig(codes: TrackingCode[], onAccept: (code: Trackin
necessary: "Notwendig",
analytics: "Analyse",
marketing: "Marketing",
content: "Inhalte",
},
...serviceTranslations,
},
@@ -126,6 +138,15 @@ export function buildKlaroConfig(codes: TrackingCode[], onAccept: (code: Trackin
purposes: [code.consentCategory],
required: code.consentCategory === "necessary",
default: code.consentCategory === "necessary",
// For "google-maps", `onAccept` below is a no-op (see
// loadTrackingCode.ts) — an embed's src isn't a script this app
// injects, Klaro's OWN contextual-consent DOM scan
// (renderContextualConsentNotices, runs as part of Klaro.render())
// finds any `data-name="google-maps"` iframe on the page and
// blanks/restores its `src` itself, purely by service name +
// consent state. This service entry's only job is telling Klaro
// that name exists and which purpose gates it.
//
// A restock/page-reload shouldn't re-fire the loader for a service
// the visitor already accepted in an earlier session within this
// same page load — Klaro still calls `callback` once per accepted