freezmo/components/CookieConsent.tsx
Martin Dvorak e56653dae1 Frutiger Aero theme, pixel-measured contrast fixes, sheet surfaces
Frutiger Aero (Settings -> Theme): a third theme, not a dark/light variant.
A sky gradient with a strip of grass, the glacier blobs become clouds, the
orbs soap bubbles, glass gets the classic horizon gloss and the buttons a
glossy aqua. The light/dark toggles (header, rail, chat header) hide while it
is on and the picker says why; the pre-paint script applies the class before
first paint and the PWA status bar follows (#3fa3e0). Its muted/frost text is
darker than Light's because those labels sit directly on the sky.

Contrast, measured on real pixels (tests/contrast.mjs, now covering aero):
- The light settings sheet was translucent over a dark scrim, so its muted
  text measured ~2.8:1. Sheets and dialogs now use --glass-sheet-bg (a more
  opaque surface), and Light's --text-muted is a touch darker.
- Result: 0 below-minimum findings and 0 axe violations across every screen,
  all three themes, phone and desktop.

Also: the suites now seed the cookie notice as already dismissed (they run as
a returning user); the regression suite opts out to test the notice itself —
the previous deploy failed its gate because the notice blocked a chat chip
click. The notice also hides during immersive sessions (overlay-open), so it
can never cover a study feed.

Version 0.1.8, SW -> freezmo-v54.
2026-10-12 22:10:16 +00:00

62 lines
1.8 KiB
TypeScript

"use client";
import Link from "next/link";
import { useEffect, useState } from "react";
import { useI18n } from "@/lib/i18n";
const STORAGE_KEY = "freezmo.consent.v1";
/**
* The cookie notice. There are no cookies (see /cookies), so this is an
* honest "here is what we store in your browser" line, dismissed once and
* remembered. It sits below the immersive feeds in the stack (z-44) so it can
* never cover a study session, and above the phone tab bar.
*/
export function CookieConsent() {
const { t } = useI18n();
const [visible, setVisible] = useState(false);
useEffect(() => {
try {
setVisible(window.localStorage.getItem(STORAGE_KEY) === null);
} catch {
/* private mode: no storage, no banner */
}
}, []);
if (!visible) return null;
const dismiss = () => {
try {
window.localStorage.setItem(STORAGE_KEY, JSON.stringify({ at: Date.now() }));
} catch {
/* private mode */
}
setVisible(false);
};
return (
<div className="cookie-notice pointer-events-none fixed inset-x-0 bottom-[calc(env(safe-area-inset-bottom,0px)+5.25rem)] z-[44] flex justify-center px-4 sm:bottom-6">
<div
role="region"
aria-label={t("consent.title")}
className="card pointer-events-auto flex max-w-xl flex-wrap items-center gap-3 p-3"
>
<p className="min-w-0 flex-1 text-[12.5px] leading-snug text-[var(--text-muted)]">
{t("consent.body")}{" "}
<Link href="/cookies" className="font-semibold text-[var(--text)] underline decoration-dotted">
{t("consent.link")}
</Link>
</p>
<button
type="button"
onClick={dismiss}
className="btn-primary touch-target h-10 shrink-0 rounded-xl px-4 text-[13px] font-semibold"
>
{t("consent.ok")}
</button>
</div>
</div>
);
}