-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
111 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,83 @@ | ||
<script> | ||
import { onMount } from 'svelte'; | ||
let consentGiven = false; | ||
let settingsOpen = false; // To toggle the settings view | ||
onMount(() => { | ||
consentGiven = localStorage.getItem('cookieConsent') === 'true'; | ||
}); | ||
function giveConsent() { | ||
localStorage.setItem('cookieConsent', 'true'); | ||
consentGiven = true; | ||
import { onMount } from 'svelte'; | ||
let consentGiven = false; | ||
onMount(() => { | ||
consentGiven = localStorage.getItem('cookieConsent') === 'true'; | ||
}); | ||
/* eslint-disable */ | ||
function initializeGA4() { | ||
// Load the GA4 script dynamically | ||
var script = document.createElement('script'); | ||
script.async = true; | ||
script.src = | ||
'https://www.googletagmanager.com/gtag/js?id={{ GA_TRACKING_ID }}'; | ||
document.head.appendChild(script); | ||
// Initialize GA4 tracking | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag() { | ||
dataLayer.push(arguments); | ||
} | ||
function rejectCookies() { | ||
localStorage.setItem('cookieConsent', 'false'); | ||
consentGiven = false; | ||
} | ||
function toggleSettings() { | ||
settingsOpen = !settingsOpen; | ||
} | ||
</script> | ||
|
||
{#if !consentGiven} | ||
gtag('js', new Date()); | ||
gtag('config', '{{ GA_TRACKING_ID }}'); | ||
} | ||
/* eslint-enable */ | ||
function giveConsent() { | ||
localStorage.setItem('cookieConsent', 'true'); | ||
consentGiven = true; | ||
} | ||
function rejectCookies() { | ||
localStorage.setItem('cookieConsent', 'false'); | ||
consentGiven = false; | ||
} | ||
$: if (consentGiven) { | ||
initializeGA4(); | ||
} | ||
</script> | ||
|
||
<style> | ||
.cookie-banner { | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
background-color: #f4f4f4; | ||
padding: 20px; | ||
text-align: center; | ||
box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1); | ||
} | ||
.cookie-banner p { | ||
margin: 0 0 10px 0; | ||
} | ||
.cookie-banner button { | ||
padding: 10px 20px; | ||
background-color: #007bff; | ||
color: white; | ||
border: none; | ||
cursor: pointer; | ||
margin-right: 10px; | ||
} | ||
.cookie-settings { | ||
margin-top: 20px; | ||
background-color: #e9ecef; | ||
padding: 10px; | ||
border-radius: 5px; | ||
} | ||
</style> | ||
|
||
{#if !consentGiven} | ||
<div class="cookie-banner"> | ||
<p>We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.</p> | ||
<button on:click={toggleSettings}>Manage cookie settings</button> | ||
<p> | ||
We use cookies to enhance your experience, by continuing to visit this | ||
site you agree to our use of cookies. <a href="https://www.mozilla.org/en-US/privacy/websites/#cookies" target="_blank">Learn More</a>. | ||
</p> | ||
<button on:click={giveConsent}>Accept</button> | ||
<button on:click={rejectCookies}>Reject</button> | ||
|
||
{#if settingsOpen} | ||
<div class="cookie-settings"> | ||
<!-- Placeholder for detailed settings from Mozilla org--> | ||
<p>Cookie settings panel...</p> | ||
</div> | ||
{/if} | ||
</div> | ||
{/if} | ||
|
||
<style> | ||
.cookie-banner { | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
background-color: #f4f4f4; | ||
padding: 20px; | ||
text-align: center; | ||
box-shadow: 0 -2px 4px rgba(0,0,0,0.1); | ||
} | ||
.cookie-banner p { | ||
margin: 0 0 10px 0; | ||
} | ||
.cookie-banner button { | ||
padding: 10px 20px; | ||
background-color: #007bff; | ||
color: white; | ||
border: none; | ||
cursor: pointer; | ||
margin-right: 10px; | ||
} | ||
.cookie-settings { | ||
margin-top: 20px; | ||
background-color: #e9ecef; | ||
padding: 10px; | ||
border-radius: 5px; | ||
} | ||
</style> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,6 @@ | |
} | ||
</style> | ||
|
||
|
||
<div class="graphic-body__content"> | ||
<CookieBanner /> | ||
<div> | ||
|