diff --git a/web-next/app/globals.css b/web-next/app/globals.css index a6700c4..2254e79 100644 --- a/web-next/app/globals.css +++ b/web-next/app/globals.css @@ -262,6 +262,52 @@ textarea:focus { border-color: #5c2b2b; color: #d98c8c; } +.uw-cookie-btn-save { + border-color: #b17c02; + color: #f0b93f; +} +.uw-cookie-btn-save:hover { + background: hsla(40, 90%, 45%, 0.15); + color: #fff; +} + +/* Panel «Personalizar» del banner (checkboxes por categoría). */ +.uw-cookie-details { + margin-top: 14px; + padding-top: 12px; + border-top: 1px solid #352e2b; +} +.uw-cookie-category { + margin-bottom: 10px; +} +.uw-cookie-category label { + display: flex; + align-items: center; + gap: 8px; + cursor: pointer; +} +.uw-cookie-category input[type='checkbox'] { + width: 16px; + height: 16px; + accent-color: #d79602; + cursor: pointer; +} +.uw-cookie-category input[type='checkbox']:disabled { + cursor: default; +} +.uw-cookie-cat-name { + color: #ebdec2; + font-size: 15px; +} +.uw-cookie-category p { + color: #b1997f; + font-size: 13px; + margin: 2px 0 0 24px; + line-height: 18px; +} +.uw-cookie-actions-detail { + margin-top: 8px; +} /* Panel «Tu estado de consentimiento» en /cookies (datos de la API de Zaraz). */ .uw-consent-status { diff --git a/web-next/components/CookieConsent.tsx b/web-next/components/CookieConsent.tsx index f67c728..016e1b1 100644 --- a/web-next/components/CookieConsent.tsx +++ b/web-next/components/CookieConsent.tsx @@ -27,12 +27,11 @@ declare global { } // Categorías de consentimiento (necesarias siempre activas). -type Category = { key: string; label: string; always?: boolean } +type Category = { key: string; label: string; always?: boolean; desc?: string } export const CONSENT_CATEGORIES: readonly Category[] = [ - { key: 'necessary', label: 'Necesarias', always: true }, - { key: 'preferences', label: 'Preferencias' }, - { key: 'analytics', label: 'Analíticas' }, - { key: 'marketing', label: 'Marketing' }, + { key: 'necessary', label: 'Necesarias', always: true, desc: 'Esenciales para el funcionamiento del sitio. No se pueden desactivar.' }, + { key: 'analytics', label: 'Analíticas', desc: 'Nos ayudan a entender cómo usas el sitio para mejorarlo.' }, + { key: 'marketing', label: 'Marketing', desc: 'Se utilizan para mostrarte anuncios relevantes.' }, ] type Consent = Record @@ -79,12 +78,6 @@ function acceptAll() { function rejectAll() { writeConsent(allFlags(false)) } -/** Abre el modal granular de Zaraz; si no está, lleva a la página de cookies. */ -function customize() { - const c = zaraz() - if (c) c.modal = true - else if (typeof window !== 'undefined') window.location.href = '/cookies' -} function showBanner() { window.dispatchEvent(new CustomEvent(SHOW_EVENT)) } @@ -101,12 +94,22 @@ function revokeConsent() { // --------------------------------------------------------------------------- export function CookieBanner() { const [visible, setVisible] = useState(false) + const [details, setDetails] = useState(false) + // Estado de los checkboxes granulares (categorías no necesarias). + const [prefs, setPrefs] = useState({ analytics: false, marketing: false }) useEffect(() => { window.UWCookies = { showBanner, revokeConsent, acceptAll, rejectAll } - // Aparece si aún no hay decisión guardada. - if (!readConsent()) setVisible(true) - const onShow = () => setVisible(true) + // Precarga los checkboxes con lo ya guardado (si lo hay). + const saved = readConsent() + if (saved) setPrefs({ analytics: !!saved.analytics, marketing: !!saved.marketing }) + else setVisible(true) // Aparece si aún no hay decisión guardada. + const onShow = () => { + const cur = readConsent() + if (cur) setPrefs({ analytics: !!cur.analytics, marketing: !!cur.marketing }) + setDetails(false) + setVisible(true) + } const onChange = () => { if (readConsent()) setVisible(false) } @@ -120,16 +123,50 @@ export function CookieBanner() { if (!visible) return null + function savePrefs() { + writeConsent({ necessary: true, analytics: !!prefs.analytics, marketing: !!prefs.marketing }) + setVisible(false) + } + return (

Utilizamos cookies

Este sitio utiliza cookies propias y de terceros para garantizar el funcionamiento del sitio, analizar el tráfico y ofrecerte publicidad personalizada. Consulta nuestra política de cookies para más información.

Política de Cookies + + {details && ( +
+
+ +

Esenciales para el funcionamiento del sitio. No se pueden desactivar.

+
+
+ +

Nos ayudan a entender cómo usas el sitio para mejorarlo.

+
+
+ +

Se utilizan para mostrarte anuncios relevantes.

+
+
+ +
+
+ )}
- +