From 95b4e33c8babf892c8132aa1fb9539645a7d63c4 Mon Sep 17 00:00:00 2001 From: Mehul Mathur Date: Thu, 5 Dec 2024 13:02:38 +0530 Subject: [PATCH] chore: redesign cookie consent (#564) * chore: redesign cookie consent modal * chore: responsive UI --- .../CookieConsentModal/CookieConsentModal.tsx | 147 +++++++----------- .../CookieConsentModal/styles.module.css | 44 +----- 2 files changed, 64 insertions(+), 127 deletions(-) diff --git a/src/components/shared/CookieConsentModal/CookieConsentModal.tsx b/src/components/shared/CookieConsentModal/CookieConsentModal.tsx index bb1f9f9f2f..5a257225b4 100644 --- a/src/components/shared/CookieConsentModal/CookieConsentModal.tsx +++ b/src/components/shared/CookieConsentModal/CookieConsentModal.tsx @@ -41,12 +41,12 @@ const CookieConsentModal: React.FC = ({open, onAccept, }, } : { - text: "Manage Preferences", + text: "Manage Settings", onClick: () => setShowPreferences(true), }, ], { - text: "Accept Only Essential", + text: "Deny", onClick: onDeny, }, ] @@ -67,18 +67,6 @@ const CookieConsentModal: React.FC = ({open, onAccept, }, []) }, [preferences]) - useEffect(() => { - if (typeof window === "undefined") return - - if (open) { - requestAnimationFrame(() => { - document.body.style.overflow = "hidden" - }) - } else { - document.body.style.overflow = "visible" - } - }, [open]) - const handlePreferenceToggle = (index: number) => { if (preferences[index].readonly) return @@ -98,97 +86,76 @@ const CookieConsentModal: React.FC = ({open, onAccept, <> {open ? ( <> - {/* Overlay */} -
- {/* Modal Container */} -
-
-
-
- - We Value Your Privacy - - Our website uses cookies to enhance your browsing experience, improve website functionality, and - analyze website traffic. We also collect and process your IP address for purposes such as ensuring - security and maintaining network performance. - - - You can choose which cookies to accept by selecting your preferences below. Essential cookies are - necessary for the website to function and cannot be disabled. By clicking “Accept All” you consent - to the use of all cookies. - - - For more information, please review our{" "} - - Privacy Policy - - . - - {showPreferences && ( -
- {preferences.map((preference: PreferenceOption, index: number) => { - return ( - handlePreferenceToggle(index)} - > - {`${preference.selected ? `[ X ]` : `[ ]`}`} - {preference.name} - - ) - })} -
- )} -
-
- {consentOptions.map((btn: ConsentOption, index: number) => { +
+
+
+ We Value Your Privacy + + This website uses cookies to ensure you receive the best possible experience.{" "} + + Learn More + + +
+ {showPreferences && ( +
+ {preferences.map((preference: PreferenceOption, index: number) => { return ( handlePreferenceToggle(index)} > - {btn.text} + {`${preference.selected ? `[ X ]` : `[ ]`}`} + {preference.name} ) })}
-
- +
+
- Cookie Settings - - + {consentOptions.map((btn: ConsentOption, index: number) => { + return ( + + {btn.text} + + ) + })} +
+
) : null} diff --git a/src/components/shared/CookieConsentModal/styles.module.css b/src/components/shared/CookieConsentModal/styles.module.css index 4d0e98ee0b..16394c30a3 100644 --- a/src/components/shared/CookieConsentModal/styles.module.css +++ b/src/components/shared/CookieConsentModal/styles.module.css @@ -1,18 +1,9 @@ .cookieConsentModal { position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - max-height: 80%; - max-width: 90%; - overflow-y: scroll; + bottom: 24px; + left: 24px; + right: 24px; z-index: calc(var(--ifm-z-index-fixed) + 2); - box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 1); -} - -.modalOverlay { - z-index: calc(var(--ifm-z-index-fixed) + 1); - backdrop-filter: blur(12px); } .consentOption { @@ -30,40 +21,19 @@ color: #e7e7e7; } -.modalHeading { - top: 0; - left: 50%; - transform: translate(-50%, calc(-50% + 4px)); -} - .closeBtn { - top: 0; + top: 8px; right: 30px; - transform: translate(-50%, calc(-50% + 4px)); -} - -.bodyContainer { - background-image: radial-gradient(circle, #121214 10%, transparent 10%); - background-size: 8px 8px; - background-repeat: repeat; } @media (max-width: 1000px) { .cookieConsentModal { - max-height: 90%; - max-width: unset; - width: 100%; - } - - .modalHeading { - width: max-content; + bottom: 20px; + left: 16px; + right: 16px; } .closeBtn { right: 15px; } - - .consentOptionsContainer { - flex-direction: column; - } }