Skip to content

Commit

Permalink
Merge pull request #27 from xeptagondev/undp-compass-192
Browse files Browse the repository at this point in the history
cookie-consent mobile reponsive
  • Loading branch information
janithr1 authored Apr 15, 2024
2 parents 6983bd4 + 7a46674 commit 0fd0e70
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions ui/components/cookie-consent.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
import { useState, useEffect } from 'react';
import { useState, useEffect } from "react";

const CookieConsent = () => {
const [isVisible, setIsVisible] = useState(false);
const [isVisible, setIsVisible] = useState(false);

useEffect(() => {
const cookieConsent = localStorage.getItem('cookieConsent');
if (!cookieConsent) {
setIsVisible(true);
}
}, []);
useEffect(() => {
const cookieConsent = localStorage.getItem("cookieConsent");
if (!cookieConsent) {
setIsVisible(true);
}
}, []);

const handleAccept = () => {
localStorage.setItem('cookieConsent', 'true');
setIsVisible(false);
};
const handleAccept = () => {
localStorage.setItem("cookieConsent", "true");
setIsVisible(false);
};

if (!isVisible) return null;
if (!isVisible) return null;

return (
<div className="fixed inset-x-0 bottom-0 cookie-bg-color text-white p-4 flex justify-between items-center">
<div className="max-w-[calc(100%-250px)]"> {/* Adjust max-width accordingly */}
<p>We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.</p>
</div>
<div className="flex items-center space-x-2">
<button onClick={handleAccept} className="bg-white hover:bg-brand-blue text-brand-blue-dark hover:text-white font-semibold py-2 px-4 rounded">
Accept All
</button>
<a href="https://www.undp.org/copyright-terms-use" target='_blank' >
Cookie Settings
</a>
</div>
</div>
);
return (
<div className="fixed inset-x-0 bottom-0 cookie-bg-color text-white p-4 flex flex-col md:flex-row justify-between items-center">
<div className="max-w-full md:max-w-[calc(100%-250px)] space-y-4 md:space-y-0">
<p>
We use cookies on our website to give you the most relevant experience
by remembering your preferences and repeat visits. By clicking “Accept
All”, you consent to the use of ALL the cookies. However, you may
visit "Cookie Settings" to provide a controlled consent.
</p>
</div>
<div className="flex flex-wrap items-center space-x-2 mt-4 md:mt-0">
<button
onClick={handleAccept}
className="bg-white hover:bg-brand-blue text-brand-blue-dark hover:text-white font-semibold py-2 px-4 rounded"
>
Accept All
</button>
<a href="https://www.undp.org/copyright-terms-use" target="_blank">
Cookie Settings
</a>
</div>
</div>
);
};

export default CookieConsent;
export default CookieConsent;

0 comments on commit 0fd0e70

Please sign in to comment.