Skip to content

Commit 06ef973

Browse files
mrimekclaude
andcommitted
feat(consent): redesign cookie banner to be more compact and friendly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent af45f47 commit 06ef973

1 file changed

Lines changed: 31 additions & 59 deletions

File tree

app/components/GDPRConsentPanel.tsx

Lines changed: 31 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use client';
22

3-
import { X } from 'lucide-react';
43
import { useEffect, useState } from 'react';
54

65
import { CONSENT_STORAGE_KEY, CONSENT_VERSION, ConsentSettings, gdprConsentStore } from '@lib/gdpr-consent-store';
@@ -33,81 +32,54 @@ export default function GDPRConsentPanel() {
3332
}, []);
3433

3534
const handleAcceptAll = () => {
36-
const allConsent: ConsentSettings = {
37-
necessary: true,
38-
analytics: true,
39-
marketing: true,
40-
preferences: true,
41-
};
42-
saveConsent(allConsent);
35+
saveConsent({ necessary: true, analytics: true, marketing: true, preferences: true });
4336
};
4437

4538
const handleRejectAll = () => {
46-
const minimalConsent: ConsentSettings = {
47-
necessary: true,
48-
analytics: false,
49-
marketing: false,
50-
preferences: false,
51-
};
52-
saveConsent(minimalConsent);
39+
saveConsent({ necessary: true, analytics: false, marketing: false, preferences: false });
5340
};
5441

5542
const saveConsent = (settings: ConsentSettings) => {
5643
localStorage.setItem(
5744
CONSENT_STORAGE_KEY,
58-
JSON.stringify({
59-
version: CONSENT_VERSION,
60-
timestamp: new Date().toISOString(),
61-
settings,
62-
})
45+
JSON.stringify({ version: CONSENT_VERSION, timestamp: new Date().toISOString(), settings })
6346
);
6447
setIsVisible(false);
6548
setIsManuallyOpened(false);
6649
};
6750

68-
const handleClose = () => {
69-
setIsVisible(false);
70-
setIsManuallyOpened(false);
71-
};
72-
7351
if (!isVisible) return null;
7452

7553
return (
76-
<div className="fixed bottom-0 left-0 right-0 z-50 p-4 sm:p-6 max-w-[100vw]">
77-
<div className="mx-auto max-w-7xl">
78-
<div className="bg-white dark:bg-gray-900 rounded-lg shadow-lg border border-gray-200 dark:border-gray-800 p-4 sm:p-6 relative">
79-
{isManuallyOpened && (
80-
<button
81-
onClick={handleClose}
82-
className="absolute top-2 right-2 text-gray-400 hover:text-gray-500 dark:hover:text-gray-300"
83-
aria-label="Close"
84-
>
85-
<X className="h-5 w-5" />
86-
</button>
87-
)}
88-
<div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
89-
<div className="flex-1 pr-6 md:pr-0">
90-
<p className="text-sm text-gray-600 dark:text-gray-300">
91-
We use cookies to enhance your browsing experience and analyze our traffic. By clicking "Accept All",
92-
you consent to our use of cookies.
93-
</p>
94-
</div>
95-
<div className="flex gap-3 flex-wrap">
96-
<button
97-
onClick={handleRejectAll}
98-
className="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors flex-1 md:flex-none whitespace-nowrap"
99-
>
100-
Only Necessary
101-
</button>
102-
<button
103-
onClick={handleAcceptAll}
104-
className="px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors flex-1 md:flex-none whitespace-nowrap"
105-
>
106-
Accept All
107-
</button>
108-
</div>
109-
</div>
54+
<div className="fixed bottom-4 left-1/2 -translate-x-1/2 z-50 w-full max-w-md px-4">
55+
<div className="bg-white rounded-2xl shadow-xl border border-gray-100 px-5 py-4 flex items-center gap-4">
56+
<span className="text-2xl select-none" aria-hidden="true">🍪</span>
57+
<p className="flex-1 text-sm text-gray-500 leading-snug">
58+
We use cookies to understand how people use Archestra and make it better.
59+
</p>
60+
<div className="flex items-center gap-2 flex-shrink-0">
61+
<button
62+
onClick={handleRejectAll}
63+
className="text-sm text-gray-400 hover:text-gray-600 transition-colors px-1 whitespace-nowrap"
64+
>
65+
No thanks
66+
</button>
67+
<button
68+
onClick={handleAcceptAll}
69+
className="text-sm font-semibold text-white bg-gray-900 hover:bg-gray-700 transition-colors rounded-lg px-4 py-2 whitespace-nowrap"
70+
>
71+
Accept
72+
</button>
11073
</div>
74+
{isManuallyOpened && (
75+
<button
76+
onClick={() => { setIsVisible(false); setIsManuallyOpened(false); }}
77+
className="absolute top-2 right-2 text-gray-300 hover:text-gray-500 transition-colors"
78+
aria-label="Close"
79+
>
80+
×
81+
</button>
82+
)}
11183
</div>
11284
</div>
11385
);

0 commit comments

Comments
 (0)