-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathdesktop-tip-modal.tsx
More file actions
143 lines (132 loc) · 3.89 KB
/
desktop-tip-modal.tsx
File metadata and controls
143 lines (132 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
"use client";
import { useEffect, useSyncExternalStore } from "react";
const DISMISSED_KEY = "desktop-tip-dismissed";
let listeners: Array<() => void> = [];
function emitChange() {
listeners.forEach((l) => l());
}
export function DesktopTipModal() {
const notDismissed = useSyncExternalStore(
(listener) => {
listeners.push(listener);
return () => {
listeners = listeners.filter((l) => l !== listener);
};
},
() => {
try { return !sessionStorage.getItem(DISMISSED_KEY); }
catch { return false; }
},
() => false,
);
const dismiss = () => {
try { sessionStorage.setItem(DISMISSED_KEY, "1"); }
catch { /* privacy-restricted context */ }
emitChange();
};
useEffect(() => {
if (!notDismissed) return;
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") dismiss();
};
document.addEventListener("keydown", handleKeyDown);
return () => document.removeEventListener("keydown", handleKeyDown);
});
if (!notDismissed) return null;
return (
<div
onClick={dismiss}
className="fixed inset-0 z-[9999] flex items-center justify-center p-6 sm:hidden"
style={{
background: "rgba(0,0,0,0.45)",
backdropFilter: "blur(6px)",
WebkitBackdropFilter: "blur(6px)",
}}
>
<div
onClick={(e) => e.stopPropagation()}
style={{
background: "var(--color-glass-dark, rgba(255,255,255,0.9))",
backdropFilter: "blur(16px)",
WebkitBackdropFilter: "blur(16px)",
border: "1px solid var(--color-border-glass, rgba(255,255,255,0.3))",
borderRadius: "var(--radius-xl, 16px)",
boxShadow: "var(--shadow-glass, 0 4px 30px rgba(0,0,0,0.1))",
padding: "32px 28px",
maxWidth: 340,
width: "100%",
textAlign: "center",
fontFamily: "var(--font-family)",
}}
>
{/* Monitor icon */}
<div
style={{
width: 56,
height: 56,
margin: "0 auto 20px",
borderRadius: 14,
background: "linear-gradient(135deg, rgba(190,194,255,0.15), rgba(133,224,206,0.12))",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<svg
width="28"
height="28"
viewBox="0 0 24 24"
fill="none"
stroke="var(--color-lilac-dark, #9599CC)"
strokeWidth="1.8"
strokeLinecap="round"
strokeLinejoin="round"
>
<rect x="2" y="3" width="20" height="14" rx="2" />
<path d="M8 21h8" />
<path d="M12 17v4" />
</svg>
</div>
<h2
style={{
fontSize: 18,
fontWeight: 700,
color: "var(--text-primary, #374151)",
margin: "0 0 8px",
letterSpacing: "-0.01em",
}}
>
Best viewed on desktop
</h2>
<p
style={{
fontSize: 14,
color: "var(--text-secondary, #6b7280)",
margin: "0 0 24px",
lineHeight: 1.5,
}}
>
This experience includes interactive visualizations that work best on larger screens.
</p>
<button
onClick={dismiss}
style={{
width: "100%",
padding: "10px 20px",
borderRadius: 999,
fontSize: 14,
fontWeight: 600,
fontFamily: "var(--font-family)",
color: "#fff",
background: "linear-gradient(135deg, var(--color-lilac-dark, #9599CC), var(--color-mint-dark, #1B936F))",
border: "none",
boxShadow: "0 1px 4px rgba(149,153,204,0.3)",
cursor: "pointer",
}}
>
Continue anyway
</button>
</div>
</div>
);
}