wemathallday 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.html +1964 -1961
- package/package.json +2 -1
- package/yap.html +4475 -0
package/yap.html
ADDED
|
@@ -0,0 +1,4475 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
6
|
+
<title>yap</title>
|
|
7
|
+
<meta name="description" content="Yap — say it in a snap. Stories, yaps and a feed, on the web." />
|
|
8
|
+
<meta name="color-scheme" content="dark" />
|
|
9
|
+
<meta name="theme-color" content="#000000" />
|
|
10
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='9' fill='%232f6bff'/%3E%3Cpath d='M9 11h14v8.5a2 2 0 0 1-2 2h-6l-4 3.2v-3.2H9z' fill='%23fff'/%3E%3C/svg%3E" />
|
|
11
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
12
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
13
|
+
<link href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@700;800&family=Figtree:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
/* =========================================================================
|
|
17
|
+
YAP UI — blue-tinted night, playful, springy.
|
|
18
|
+
Sections: tokens · base · controls · avatars/badges · shell · routebar ·
|
|
19
|
+
context · feed · chats · camera · profile · admin · overlays ·
|
|
20
|
+
auth · responsive · reduced motion
|
|
21
|
+
========================================================================= */
|
|
22
|
+
|
|
23
|
+
/* ---------------------------------------------------------------- tokens */
|
|
24
|
+
:root {
|
|
25
|
+
--bg: #000000; --s1: #0E0E11; --s2: #16161A; --s3: #232329;
|
|
26
|
+
--line: rgb(255 255 255 / .08); --line-2: rgb(255 255 255 / .14);
|
|
27
|
+
--t1: #F5F5F7; --t2: #A1A1A6; --t3: #8E8E93;
|
|
28
|
+
--yap: #2F6BFF; --yap-hi: #5C8DFF; --sky: #3CC8FF; --yap-deep: #1D4FD7; --yap-lite: #6B9FFF;
|
|
29
|
+
--grad: linear-gradient(180deg, #6B9FFF, #2F6BFF 55%, #1D4FD7);
|
|
30
|
+
--ring: conic-gradient(from 0deg, #9DC4FF, #3CC8FF, #2F6BFF, #6B9FFF, #9DC4FF);
|
|
31
|
+
|
|
32
|
+
/* glossy inflated shadow recipe (shared by primary buttons, bubbles, badges) */
|
|
33
|
+
--candy-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 8px 22px -6px rgb(47 107 255 / .7);
|
|
34
|
+
--glass-bg: rgb(255 255 255 / .05);
|
|
35
|
+
--glass-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 10px 32px rgb(0 0 0 / .4);
|
|
36
|
+
|
|
37
|
+
/* aliases: the JS writes these names into inline styles */
|
|
38
|
+
--tx-1: var(--t1); --tx-2: var(--t2); --tx-3: var(--t3);
|
|
39
|
+
--blue: var(--yap); --blue-hi: var(--yap-hi); --accent-hi: var(--yap-hi);
|
|
40
|
+
--r-1: 12px; --r-2: 16px; --r-3: 22px;
|
|
41
|
+
|
|
42
|
+
--font-display: "Bricolage Grotesque", Figtree, system-ui, sans-serif;
|
|
43
|
+
--font-body: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
44
|
+
--spring: cubic-bezier(.34, 1.56, .64, 1);
|
|
45
|
+
--ease: cubic-bezier(.22, 1, .36, 1);
|
|
46
|
+
--r-input: 16px; --r-card: 24px; --r-pill: 999px;
|
|
47
|
+
--rail-w: 240px; --center-w: 600px; --ctx-w: 330px; --gap: 40px;
|
|
48
|
+
--topbar-h: 76px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* ------------------------------------------------------------------ base */
|
|
52
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
53
|
+
[hidden], .hidden { display: none !important; }
|
|
54
|
+
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
|
|
55
|
+
body {
|
|
56
|
+
margin: 0; min-height: 100dvh; background: var(--bg); color: var(--t1);
|
|
57
|
+
font: 15px/1.5 var(--font-body);
|
|
58
|
+
-webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
|
|
59
|
+
}
|
|
60
|
+
body::before {
|
|
61
|
+
content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
|
|
62
|
+
background:
|
|
63
|
+
radial-gradient(680px 420px at 85% 2%, rgb(47 107 255 / .11), transparent 70%),
|
|
64
|
+
radial-gradient(720px 520px at 8% 108%, rgb(47 107 255 / .07), transparent 70%);
|
|
65
|
+
}
|
|
66
|
+
h1, h2, h3, p { margin: 0; }
|
|
67
|
+
button, input, textarea { font: inherit; color: inherit; }
|
|
68
|
+
button { border: 0; background: none; padding: 0; cursor: pointer; text-align: inherit; }
|
|
69
|
+
button:disabled { cursor: not-allowed; }
|
|
70
|
+
a { color: inherit; }
|
|
71
|
+
img, svg, video { display: block; }
|
|
72
|
+
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
|
|
73
|
+
::selection { background: rgb(47 107 255 / .5); color: var(--t1); }
|
|
74
|
+
::placeholder { color: var(--t3); opacity: 1; }
|
|
75
|
+
* { scrollbar-width: thin; scrollbar-color: var(--s3) transparent; }
|
|
76
|
+
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
77
|
+
::-webkit-scrollbar-thumb { background: var(--s3); border-radius: var(--r-pill); }
|
|
78
|
+
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
79
|
+
|
|
80
|
+
svg.ico { width: 20px; height: 20px; flex: none; fill: none; stroke-width: 1.75; }
|
|
81
|
+
.tnum, .count { font-variant-numeric: tabular-nums; }
|
|
82
|
+
.mono { font-family: inherit; font-size: 13px; }
|
|
83
|
+
.small { font-size: 14px; }
|
|
84
|
+
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
85
|
+
code { padding: 2px 6px; border-radius: 6px; background: var(--s2); font: inherit; font-size: 13px; }
|
|
86
|
+
|
|
87
|
+
.route-title, .page-title, .prof-name, .auth-h1, .auth-title, .empty h3,
|
|
88
|
+
.sheet h3, .drawer-head h3, .section-head h3, .grid2 .k, .stat .num,
|
|
89
|
+
.rail-word, .auth-brand, #storyview .cap {
|
|
90
|
+
font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* -------------------------------------------------------------- controls */
|
|
94
|
+
.btn {
|
|
95
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
|
96
|
+
height: 42px; padding: 0 18px; border-radius: var(--r-pill);
|
|
97
|
+
font-size: 14px; font-weight: 600; white-space: nowrap; text-align: center;
|
|
98
|
+
transition: transform 120ms var(--spring), background-color 160ms var(--ease), color 160ms var(--ease), box-shadow 160ms var(--ease), border-color 160ms var(--ease), filter 160ms var(--ease);
|
|
99
|
+
}
|
|
100
|
+
.btn:not(:disabled):hover { transform: translateY(-1px); }
|
|
101
|
+
.btn:not(:disabled):active { transform: scale(.94); }
|
|
102
|
+
.btn.sm { height: 36px; padding: 0 14px; }
|
|
103
|
+
.btn.lg { height: 50px; font-size: 15px; }
|
|
104
|
+
.btn .ico { width: 18px; height: 18px; }
|
|
105
|
+
.btn.primary { background: var(--grad); color: #fff; box-shadow: var(--candy-shadow); }
|
|
106
|
+
.btn.primary:not(:disabled):hover { filter: brightness(1.08); }
|
|
107
|
+
.btn.primary:disabled { background: var(--s2); color: var(--t3); box-shadow: none; }
|
|
108
|
+
.btn.ghost, .btn.quiet { color: var(--t1); background: rgb(255 255 255 / .08); border: 0; box-shadow: inset 0 1px 0 rgb(255 255 255 / .18), inset 0 0 0 1px rgb(255 255 255 / .08); }
|
|
109
|
+
.btn.ghost:hover, .btn.quiet:hover { background: rgb(255 255 255 / .14); }
|
|
110
|
+
.btn.ghost:disabled { opacity: .5; }
|
|
111
|
+
.btn.danger { color: var(--t1); background: transparent; border: 1px solid rgb(255 255 255 / .22); }
|
|
112
|
+
.btn.danger:hover { background: rgb(255 255 255 / .12); }
|
|
113
|
+
#composer-send:not(:disabled):not([data-seen-once]) { animation: pop-in 280ms var(--spring); }
|
|
114
|
+
@keyframes pop-in { 0% { transform: scale(.8); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
|
|
115
|
+
|
|
116
|
+
.iconbtn {
|
|
117
|
+
display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px;
|
|
118
|
+
border-radius: var(--r-pill); color: var(--t2);
|
|
119
|
+
transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--spring);
|
|
120
|
+
}
|
|
121
|
+
.iconbtn:hover { background: var(--s2); color: var(--t1); transform: translateY(-1px); }
|
|
122
|
+
.iconbtn:active { transform: scale(.9); }
|
|
123
|
+
|
|
124
|
+
.lbl { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500; color: var(--t2); }
|
|
125
|
+
.field {
|
|
126
|
+
display: block; width: 100%; min-height: 46px; padding: 10px 14px;
|
|
127
|
+
border: 1px solid var(--line); border-radius: var(--r-input); background: rgb(255 255 255 / .06);
|
|
128
|
+
color: var(--t1); outline: 0; caret-color: var(--yap-hi);
|
|
129
|
+
transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), background-color 160ms var(--ease);
|
|
130
|
+
}
|
|
131
|
+
.field:hover { border-color: var(--line-2); }
|
|
132
|
+
.field:focus { border-color: var(--yap-hi); box-shadow: 0 0 0 3px rgb(92 141 255 / .28); }
|
|
133
|
+
textarea.field { resize: none; }
|
|
134
|
+
|
|
135
|
+
.spinner {
|
|
136
|
+
display: inline-block; width: 16px; height: 16px; border-radius: 50%;
|
|
137
|
+
border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
|
|
138
|
+
}
|
|
139
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
140
|
+
|
|
141
|
+
.skeleton { display: grid; gap: 14px; padding: 24px 0; }
|
|
142
|
+
.skeleton i {
|
|
143
|
+
display: block; height: 14px; border-radius: 7px;
|
|
144
|
+
background: linear-gradient(100deg, var(--s2) 38%, var(--s3) 50%, var(--s2) 62%);
|
|
145
|
+
background-size: 220% 100%; animation: shimmer 1.3s linear infinite;
|
|
146
|
+
}
|
|
147
|
+
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
|
|
148
|
+
|
|
149
|
+
.empty { display: grid; justify-items: center; gap: 8px; padding: 64px 16px; text-align: center; }
|
|
150
|
+
.empty .obj { width: 96px; height: 96px; margin-bottom: 6px; }
|
|
151
|
+
.empty h3 { font-size: 20px; }
|
|
152
|
+
.empty p { max-width: 36ch; color: var(--t2); font-size: 15px; }
|
|
153
|
+
.empty .btn { margin-top: 8px; }
|
|
154
|
+
.muted-line { padding: 20px 0; color: var(--t3); }
|
|
155
|
+
|
|
156
|
+
/* ------------------------------------------------------- avatars/badges */
|
|
157
|
+
.avatar {
|
|
158
|
+
--av: var(--yap); --av-fg: #fff;
|
|
159
|
+
position: relative; display: grid; place-items: center; flex: none; width: 40px; height: 40px; overflow: visible;
|
|
160
|
+
border-radius: 50%; background: var(--av); color: var(--av-fg);
|
|
161
|
+
font-size: 14px; font-weight: 700; line-height: 1; letter-spacing: 0; text-transform: uppercase;
|
|
162
|
+
}
|
|
163
|
+
.avatar > img:not(.avdecor) { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
|
|
164
|
+
.avatar .avdecor {
|
|
165
|
+
position: absolute; left: 50%; top: 50%; z-index: 3; width: 128%; height: 128%;
|
|
166
|
+
max-width: none; object-fit: contain; pointer-events: none; transform: translate(-50%, -50%);
|
|
167
|
+
}
|
|
168
|
+
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }
|
|
169
|
+
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
|
|
170
|
+
.avatar.lg { width: 112px; height: 112px; font-size: 34px; }
|
|
171
|
+
.avatar[data-frame="ring"] { outline: 3px solid var(--yap); outline-offset: 3px; }
|
|
172
|
+
.avatar[data-frame="verified"] { outline: 3px solid var(--sky); outline-offset: 3px; }
|
|
173
|
+
|
|
174
|
+
.badge {
|
|
175
|
+
display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
|
|
176
|
+
border: 1px solid var(--line-2); border-radius: var(--r-pill);
|
|
177
|
+
font-size: 13px; font-weight: 500; line-height: 1; color: var(--t2); white-space: nowrap;
|
|
178
|
+
}
|
|
179
|
+
.badge .ico { width: 14px; height: 14px; }
|
|
180
|
+
.badge.support { color: var(--t2); border-color: rgb(255 255 255 / .22); }
|
|
181
|
+
.badge.verified { padding: 0; border: 0; gap: 0; font-size: 0; width: 18px; height: 18px; justify-content: center;
|
|
182
|
+
border-radius: 50%; background: var(--yap); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .4), inset 0 -1px 0 rgb(0 0 0 / .2); }
|
|
183
|
+
.badge.verified .ico { width: 11px; height: 11px; stroke-width: 2.6; }
|
|
184
|
+
.badge.admin { color: var(--yap-hi); border-color: color-mix(in srgb, var(--yap) 45%, transparent); }
|
|
185
|
+
.badge.banned { color: var(--t3); border-color: var(--line-2); }
|
|
186
|
+
.pill {
|
|
187
|
+
display: inline-flex; align-items: center; height: 24px; padding: 0 10px; white-space: nowrap;
|
|
188
|
+
border: 1px solid var(--line-2); border-radius: var(--r-pill); font-size: 13px; color: var(--t2);
|
|
189
|
+
}
|
|
190
|
+
.unread {
|
|
191
|
+
display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
|
|
192
|
+
border-radius: var(--r-pill); background: var(--grad); color: #fff;
|
|
193
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -1px 0 rgb(0 0 0 / .18);
|
|
194
|
+
font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.seg { position: relative; display: flex; padding: 3px; border-radius: var(--r-pill); background: var(--s2); border: 1px solid var(--line); }
|
|
198
|
+
.seg button { position: relative; z-index: 1; flex: 1; height: 38px; border-radius: var(--r-pill); text-align: center; font-size: 14px; font-weight: 500; color: var(--t2); transition: color 160ms var(--ease); }
|
|
199
|
+
.seg button:hover { color: var(--t1); }
|
|
200
|
+
.seg button.on { color: var(--t1); }
|
|
201
|
+
.seg-pill { position: absolute; left: 3px; top: 3px; bottom: 3px; width: 0; border-radius: var(--r-pill); background: var(--s3); border: 1px solid var(--line-2); transition: transform 260ms var(--spring), width 260ms var(--spring); }
|
|
202
|
+
|
|
203
|
+
/* ----------------------------------------------------------------- shell */
|
|
204
|
+
.shell {
|
|
205
|
+
display: grid; grid-template-columns: var(--rail-w) minmax(0, var(--center-w)) var(--ctx-w);
|
|
206
|
+
column-gap: var(--gap); justify-content: center; min-height: 100dvh; padding: 0 24px;
|
|
207
|
+
}
|
|
208
|
+
body[data-ctx="off"] .shell { grid-template-columns: var(--rail-w) minmax(0, calc(var(--center-w) + var(--ctx-w) + var(--gap))); }
|
|
209
|
+
body[data-ctx="off"] .context { display: none; }
|
|
210
|
+
|
|
211
|
+
/* left rail */
|
|
212
|
+
.rail {
|
|
213
|
+
position: sticky; top: 0; z-index: 30; align-self: start;
|
|
214
|
+
display: flex; flex-direction: column; align-items: stretch; gap: 4px;
|
|
215
|
+
height: 100dvh; padding: 14px 12px;
|
|
216
|
+
}
|
|
217
|
+
.rail-logo, .auth-brand {
|
|
218
|
+
display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; text-decoration: none;
|
|
219
|
+
font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--t1);
|
|
220
|
+
}
|
|
221
|
+
.logo-mark { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--grad); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 4px 16px -4px rgb(47 107 255 / .6); }
|
|
222
|
+
.logo-mark .ico { width: 18px; height: 18px; }
|
|
223
|
+
|
|
224
|
+
.rail-nav { position: relative; display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
|
|
225
|
+
.rail-nav button {
|
|
226
|
+
position: relative; z-index: 1; display: flex; align-items: center; gap: 14px;
|
|
227
|
+
height: 48px; padding: 0 16px; border-radius: var(--r-pill);
|
|
228
|
+
font-size: 16px; font-weight: 500; color: var(--t2);
|
|
229
|
+
transition: color 160ms var(--ease), transform 120ms var(--spring);
|
|
230
|
+
}
|
|
231
|
+
.rail-nav button .ico { width: 22px; height: 22px; }
|
|
232
|
+
.rail-nav button:hover { color: var(--t1); }
|
|
233
|
+
.rail-nav button:active { transform: scale(.97); }
|
|
234
|
+
.rail-nav button[aria-current="page"] { color: var(--t1); font-weight: 600; }
|
|
235
|
+
.rail-nav button[aria-current="page"] .ico { animation: nav-pop 300ms var(--spring); }
|
|
236
|
+
@keyframes nav-pop { 40% { transform: translateY(-4px) scale(1.12); } }
|
|
237
|
+
.rail-pill {
|
|
238
|
+
position: absolute; left: 0; top: 0; width: 0; height: 48px; border-radius: var(--r-pill);
|
|
239
|
+
background: var(--s2); border: 1px solid var(--line);
|
|
240
|
+
transition: transform 260ms var(--spring), width 260ms var(--spring), height 260ms var(--spring), opacity 160ms;
|
|
241
|
+
}
|
|
242
|
+
.rail-badge {
|
|
243
|
+
margin-left: auto; display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
|
|
244
|
+
border-radius: var(--r-pill); background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
|
|
245
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -1px 0 rgb(0 0 0 / .18);
|
|
246
|
+
}
|
|
247
|
+
.rail-badge.hidden { display: none; }
|
|
248
|
+
.rail-new {
|
|
249
|
+
display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
250
|
+
height: 52px; margin-top: 18px; border-radius: var(--r-pill);
|
|
251
|
+
background: var(--grad); color: #fff; font-size: 17px; font-weight: 700; font-family: var(--font-display);
|
|
252
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 8px 28px -8px rgb(47 107 255 / .6);
|
|
253
|
+
transition: transform 130ms var(--spring), filter 160ms var(--ease);
|
|
254
|
+
}
|
|
255
|
+
.rail-new:hover { transform: translateY(-2px); filter: brightness(1.1); }
|
|
256
|
+
.rail-new:active { transform: scale(.96); }
|
|
257
|
+
.rail-new .ico { width: 20px; height: 20px; stroke-width: 2.2; }
|
|
258
|
+
.rail-user {
|
|
259
|
+
margin-top: auto; display: flex; align-items: center; gap: 10px;
|
|
260
|
+
padding: 10px 12px; border-radius: var(--r-pill); text-align: left;
|
|
261
|
+
transition: background-color 160ms var(--ease), transform 120ms var(--spring);
|
|
262
|
+
}
|
|
263
|
+
.rail-user:hover { background: var(--s2); }
|
|
264
|
+
.rail-user:active { transform: scale(.97); }
|
|
265
|
+
.rail-user .who { flex: 1; min-width: 0; }
|
|
266
|
+
.rail-user .name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
267
|
+
.rail-user .handle { font-size: 13px; color: var(--t3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
268
|
+
.rail-user > .ico { width: 18px; height: 18px; color: var(--t3); }
|
|
269
|
+
|
|
270
|
+
/* center column + sticky routebar */
|
|
271
|
+
.route { min-width: 0; }
|
|
272
|
+
.routebar {
|
|
273
|
+
position: sticky; top: 0; z-index: 20;
|
|
274
|
+
display: flex; align-items: center; gap: 12px; min-height: var(--topbar-h);
|
|
275
|
+
padding: 10px 16px; margin: 0 -16px;
|
|
276
|
+
background: rgb(0 0 0 / .62);
|
|
277
|
+
-webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
|
|
278
|
+
border-bottom: 1px solid var(--line);
|
|
279
|
+
}
|
|
280
|
+
.route-logo, .mob-avatar { display: none; }
|
|
281
|
+
.route-text { flex: 1; min-width: 0; }
|
|
282
|
+
.route-title { font-size: 26px; line-height: 1.15; }
|
|
283
|
+
.route-sub { font-size: 13px; color: var(--t3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
284
|
+
.route-actions { display: flex; gap: 8px; }
|
|
285
|
+
|
|
286
|
+
#main { padding: 16px 0 80px; }
|
|
287
|
+
.view { display: none; }
|
|
288
|
+
.view.on { display: block; animation: view-in 220ms var(--ease); }
|
|
289
|
+
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
|
|
290
|
+
.feed-wrap, .cam-route, .profile-wrap, .admin-wrap, #chats-split { width: 100%; }
|
|
291
|
+
|
|
292
|
+
/* right column */
|
|
293
|
+
.context {
|
|
294
|
+
position: sticky; top: 0; align-self: start;
|
|
295
|
+
display: grid; gap: 16px; max-height: 100dvh; overflow: auto;
|
|
296
|
+
padding: calc(var(--topbar-h) + 8px) 0 40px; scrollbar-width: none;
|
|
297
|
+
}
|
|
298
|
+
.context::-webkit-scrollbar { display: none; }
|
|
299
|
+
/* liquid glass on every floating layer (MLV2 recipe): translucent white fill,
|
|
300
|
+
deep blur, inset top highlight, gradient hairline border via masked ::before */
|
|
301
|
+
.ctx-block, .list-pane, .thread-pane, .sheet, .drawer, .userpop, .toast, .auth-card, .stat, .prof-preview {
|
|
302
|
+
background: var(--glass-bg);
|
|
303
|
+
-webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
|
|
304
|
+
box-shadow: var(--glass-shadow);
|
|
305
|
+
}
|
|
306
|
+
.ctx-block, .sheet, .userpop, .toast, .auth-card, .stat, .prof-preview { position: relative; }
|
|
307
|
+
.ctx-block::before, .sheet::before, .userpop::before, .toast::before, .auth-card::before, .prof-preview::before {
|
|
308
|
+
content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
|
|
309
|
+
background: linear-gradient(135deg, rgb(255 255 255 / .16), rgb(255 255 255 / .03) 40%, rgb(255 255 255 / .03) 60%, rgb(255 255 255 / .09));
|
|
310
|
+
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
|
|
311
|
+
}
|
|
312
|
+
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
313
|
+
.ctx-block, .list-pane, .thread-pane, .sheet, .drawer, .userpop, .toast, .auth-card, .stat, .prof-preview { background: rgb(22 22 24 / .94); }
|
|
314
|
+
}
|
|
315
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
316
|
+
.ctx-block, .list-pane, .thread-pane, .sheet, .drawer, .userpop, .toast, .auth-card, .stat, .prof-preview {
|
|
317
|
+
-webkit-backdrop-filter: none; backdrop-filter: none; background: #161618;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
.ctx-block { padding: 16px; border: 0; border-radius: var(--r-card); }
|
|
321
|
+
.ctx-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
|
|
322
|
+
.ctx-label { margin-bottom: 8px; font-size: 15px; font-weight: 700; font-family: var(--font-display); }
|
|
323
|
+
.ctx-head .ctx-label { margin-bottom: 0; }
|
|
324
|
+
.ctx-more { font-size: 13px; font-weight: 600; color: var(--sky); border-radius: var(--r-pill); padding: 2px 6px; }
|
|
325
|
+
.ctx-more:hover { color: var(--t1); }
|
|
326
|
+
.ctx-row {
|
|
327
|
+
display: flex; align-items: center; gap: 10px; width: 100%;
|
|
328
|
+
padding: 9px 8px; margin: 0 -8px; width: calc(100% + 16px); border-radius: 14px; text-align: left;
|
|
329
|
+
transition: background-color 140ms var(--ease), transform 120ms var(--spring);
|
|
330
|
+
}
|
|
331
|
+
.ctx-row:hover { background: var(--s2); }
|
|
332
|
+
.ctx-row:active { transform: scale(.98); }
|
|
333
|
+
.ctx-row .ctx-who { flex: 1; min-width: 0; }
|
|
334
|
+
.ctx-row .name { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
|
|
335
|
+
.ctx-row .meta { font-size: 13px; color: var(--t3); }
|
|
336
|
+
.ctx-streak { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--yap-hi); }
|
|
337
|
+
.ctx-streak .ico { width: 13px; height: 13px; fill: currentColor; stroke: none; }
|
|
338
|
+
.ctx-row .unread { flex: none; }
|
|
339
|
+
|
|
340
|
+
/* ------------------------------------------------------------------ feed */
|
|
341
|
+
.stories { display: flex; gap: 18px; padding: 6px 4px 22px; overflow-x: auto; scrollbar-width: none; }
|
|
342
|
+
.stories::-webkit-scrollbar { display: none; }
|
|
343
|
+
.story { display: grid; justify-items: center; gap: 8px; flex: none; width: 76px; }
|
|
344
|
+
.story-ring {
|
|
345
|
+
position: relative; padding: 4.5px; border-radius: 50%; background: rgb(255 255 255 / .08);
|
|
346
|
+
transition: transform 140ms var(--spring);
|
|
347
|
+
}
|
|
348
|
+
.story[data-seen="false"] .story-ring { background: var(--ring); }
|
|
349
|
+
.story:hover .story-ring { transform: translateY(-3px) scale(1.02); }
|
|
350
|
+
.story:active .story-ring { transform: scale(.9); }
|
|
351
|
+
.story .avatar { width: 64px; height: 64px; font-size: 20px; box-shadow: 0 0 0 2px var(--bg); }
|
|
352
|
+
.story-plus {
|
|
353
|
+
position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center;
|
|
354
|
+
width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; border: 3px solid var(--bg); box-shadow: inset 0 1px 0 rgb(255 255 255 / .45);
|
|
355
|
+
}
|
|
356
|
+
.story-plus .ico { width: 12px; height: 12px; stroke-width: 2.6; }
|
|
357
|
+
.story-name { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--t2); }
|
|
358
|
+
.story[data-me="true"] .story-name { color: var(--t1); }
|
|
359
|
+
|
|
360
|
+
.composer {
|
|
361
|
+
display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; row-gap: 4px;
|
|
362
|
+
padding: 16px 4px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
|
|
363
|
+
}
|
|
364
|
+
.composer-top { display: contents; }
|
|
365
|
+
.composer-top > #composer-avatar { grid-column: 1; grid-row: 1; align-self: start; padding-top: 2px; }
|
|
366
|
+
.composer-top .avatar { width: 40px; height: 40px; font-size: 14px; }
|
|
367
|
+
.composer textarea {
|
|
368
|
+
grid-column: 2; grid-row: 1; width: 100%; min-height: 44px; max-height: 220px; padding: 9px 0;
|
|
369
|
+
border: 0; outline: 0; resize: none; background: transparent; color: var(--t1); font-size: 17px; line-height: 1.5;
|
|
370
|
+
}
|
|
371
|
+
.composer-tools { grid-column: 2; grid-row: 2; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
|
|
372
|
+
.composer-tools .grow { flex: 1; }
|
|
373
|
+
.composer-tools .iconbtn .ico { width: 20px; height: 20px; }
|
|
374
|
+
.composer-tools .iconbtn { color: var(--sky); }
|
|
375
|
+
.attach-note { grid-column: 2; grid-row: 3; display: flex; align-items: center; gap: 8px; color: var(--t2); font-size: 14px; }
|
|
376
|
+
|
|
377
|
+
.count-ring { width: 24px; height: 24px; align-self: center; margin-right: 4px; opacity: 0; transform: rotate(-90deg) scale(.8); transition: opacity 160ms var(--ease), transform 200ms var(--spring); }
|
|
378
|
+
.count-ring[data-show="true"] { opacity: 1; transform: rotate(-90deg) scale(1); }
|
|
379
|
+
.count-ring .track { fill: none; stroke: var(--s3); stroke-width: 3; }
|
|
380
|
+
.count-ring .val { fill: none; stroke: var(--yap-hi); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 120ms linear, stroke 160ms; }
|
|
381
|
+
.count-ring[data-warn="true"] .val { stroke: var(--sky); }
|
|
382
|
+
.count-ring[data-over="true"] .val { stroke: #fff; }
|
|
383
|
+
|
|
384
|
+
.new-pill {
|
|
385
|
+
position: sticky; top: calc(var(--topbar-h) + 12px); z-index: 5; display: block;
|
|
386
|
+
height: 38px; margin: 14px auto; padding: 0 18px; border-radius: var(--r-pill);
|
|
387
|
+
background: var(--grad); color: #fff; font-size: 14px; font-weight: 700;
|
|
388
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 8px 24px -6px rgb(47 107 255 / .55);
|
|
389
|
+
animation: drop-in 320ms var(--spring);
|
|
390
|
+
}
|
|
391
|
+
@keyframes drop-in { from { opacity: 0; transform: translateY(-16px) scale(.9); } }
|
|
392
|
+
|
|
393
|
+
.post {
|
|
394
|
+
position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 14px;
|
|
395
|
+
margin-inline: -12px; padding: 18px 12px; border-radius: 18px; transition: background-color 160ms var(--ease);
|
|
396
|
+
}
|
|
397
|
+
.post::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 1px; background: var(--line); }
|
|
398
|
+
.post:hover, .post:focus-within { background: rgb(255 255 255 / .04); }
|
|
399
|
+
.post.static:hover { background: transparent; }
|
|
400
|
+
.post-head { display: contents; }
|
|
401
|
+
.post-head > .avatar { grid-column: 1; grid-row: 1 / span 5; width: 44px; height: 44px; font-size: 15px; align-self: start; }
|
|
402
|
+
.post-who { grid-column: 2; grid-row: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; padding-right: 44px; }
|
|
403
|
+
.post-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
404
|
+
.post-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
405
|
+
.post-meta { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--t3); white-space: nowrap; }
|
|
406
|
+
.post-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--t3); }
|
|
407
|
+
.post-meta .you {
|
|
408
|
+
padding: 0 7px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--yap) 20%, transparent);
|
|
409
|
+
color: var(--sky); font-size: 11px; font-weight: 700; line-height: 18px;
|
|
410
|
+
}
|
|
411
|
+
.post-more { position: absolute; top: 12px; right: 12px; opacity: .35; }
|
|
412
|
+
.post:hover .post-more, .post:focus-within .post-more, .post-more:focus-visible { opacity: 1; }
|
|
413
|
+
.post-body { grid-column: 2; margin-top: 2px; max-width: 62ch; font-size: 16.5px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; text-wrap: pretty; }
|
|
414
|
+
.post-media { grid-column: 2; margin-top: 12px; max-width: 520px; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; cursor: zoom-in; }
|
|
415
|
+
.post-media img { width: 100%; height: auto; transition: transform 240ms var(--ease); }
|
|
416
|
+
.post-media:hover img { transform: scale(1.02); }
|
|
417
|
+
.post-acts { grid-column: 2; display: flex; gap: 4px; margin: 6px 0 -10px -10px; }
|
|
418
|
+
.act {
|
|
419
|
+
position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
|
|
420
|
+
border-radius: var(--r-pill); font-size: 14px; color: var(--t3);
|
|
421
|
+
transition: color 160ms var(--ease), background-color 160ms var(--ease), transform 120ms var(--spring);
|
|
422
|
+
}
|
|
423
|
+
button.act:hover { background: var(--s2); color: var(--t1); }
|
|
424
|
+
button.act:active { transform: scale(.92); }
|
|
425
|
+
.act .ico { width: 18px; height: 18px; }
|
|
426
|
+
.act[data-on="true"] { color: var(--yap-hi); }
|
|
427
|
+
.act[data-on="true"] .ico { fill: var(--yap-hi); }
|
|
428
|
+
.act .count { display: inline-flex; overflow: hidden; min-width: 1ch; }
|
|
429
|
+
.act.roll .count span { animation: roll 260ms var(--ease); }
|
|
430
|
+
@keyframes roll { from { transform: translateY(70%); opacity: 0; } }
|
|
431
|
+
.burst { position: absolute; left: 16px; top: 50%; pointer-events: none; }
|
|
432
|
+
.burst i {
|
|
433
|
+
position: absolute; left: 0; top: 0; width: 6px; height: 6px; border-radius: 50%;
|
|
434
|
+
background: var(--yap-hi); opacity: 0; transform: rotate(var(--a)) translateX(0);
|
|
435
|
+
}
|
|
436
|
+
.burst i:nth-child(2n) { background: var(--sky); width: 5px; height: 5px; }
|
|
437
|
+
.burst i:nth-child(3n) { background: #fff; }
|
|
438
|
+
.burst[data-go="true"] i { animation: burst-fly 560ms var(--ease) forwards; }
|
|
439
|
+
@keyframes burst-fly {
|
|
440
|
+
0% { opacity: 1; transform: rotate(var(--a)) translateX(4px) scale(1); }
|
|
441
|
+
100% { opacity: 0; transform: rotate(var(--a)) translateX(30px) scale(.4); }
|
|
442
|
+
}
|
|
443
|
+
.replies { grid-column: 2; }
|
|
444
|
+
.replies:not(.on) { display: none; }
|
|
445
|
+
.replies.on { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
|
|
446
|
+
.reply { display: flex; gap: 10px; padding: 6px 0; font-size: 15px; }
|
|
447
|
+
.reply .who { font-weight: 600; }
|
|
448
|
+
.reply .when { margin-left: auto; font-size: 13px; color: var(--t3); }
|
|
449
|
+
.reply-form { display: flex; gap: 8px; margin-top: 10px; }
|
|
450
|
+
.reply-form .field { min-height: 40px; }
|
|
451
|
+
|
|
452
|
+
/* ----------------------------------------------------------------- chats */
|
|
453
|
+
#chats-split { display: none; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; height: calc(100dvh - var(--topbar-h) - 32px); min-height: 420px; }
|
|
454
|
+
body[data-view="chats"] #chats-split, body[data-view="thread"] #chats-split { display: grid; }
|
|
455
|
+
#chats-split > .view { display: block; min-height: 0; height: 100%; }
|
|
456
|
+
#chats-split > .view.on { animation: none; }
|
|
457
|
+
.list-pane, .thread-pane {
|
|
458
|
+
display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden;
|
|
459
|
+
border: 1px solid var(--line); border-radius: var(--r-card);
|
|
460
|
+
}
|
|
461
|
+
.chat-search { flex: none; padding: 12px; border-bottom: 1px solid var(--line); }
|
|
462
|
+
#people-results:empty { display: none; }
|
|
463
|
+
#people-results { flex: none; max-height: 40%; overflow: auto; border-bottom: 1px solid var(--line); }
|
|
464
|
+
.chat-scroll { flex: 1; min-height: 0; overflow: auto; }
|
|
465
|
+
.chat-scroll .empty { padding: 48px 24px; }
|
|
466
|
+
|
|
467
|
+
.chatrow {
|
|
468
|
+
position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; column-gap: 12px; align-items: center;
|
|
469
|
+
width: 100%; min-height: 74px; padding: 0 16px; text-align: left;
|
|
470
|
+
transition: background-color 160ms var(--ease);
|
|
471
|
+
}
|
|
472
|
+
.chatrow:hover { background: var(--s2); }
|
|
473
|
+
.chatrow::before {
|
|
474
|
+
content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px;
|
|
475
|
+
background: var(--grad); opacity: 0; transition: opacity 160ms;
|
|
476
|
+
}
|
|
477
|
+
.chatrow[data-active="true"] { background: var(--s2); }
|
|
478
|
+
.chatrow[data-active="true"]::before { opacity: 1; }
|
|
479
|
+
.chatrow > .avatar { width: 46px; height: 46px; font-size: 15px; }
|
|
480
|
+
.chatrow .who { min-width: 0; }
|
|
481
|
+
.chatrow .name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
482
|
+
.chatrow .name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
483
|
+
.chatrow .badge.support { padding: 0; border: 0; gap: 0; font-size: 0; }
|
|
484
|
+
.chatrow .badge.support .ico { width: 14px; height: 14px; }
|
|
485
|
+
.chatrow .streak { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--yap-hi); }
|
|
486
|
+
.chatrow .streak .ico { width: 14px; height: 14px; fill: currentColor; stroke: none; }
|
|
487
|
+
.chatrow .streak[data-hot="true"] .ico { animation: flicker 1.6s ease-in-out infinite; }
|
|
488
|
+
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.15) rotate(-6deg); } }
|
|
489
|
+
.chatrow .snippet { margin-top: 1px; font-size: 14px; color: var(--t2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
490
|
+
.chatrow > .end { display: grid; justify-items: end; gap: 6px; }
|
|
491
|
+
.chatrow .time { font-size: 13px; color: var(--t3); }
|
|
492
|
+
#people-results .chatrow, .sheet .chatrow { min-height: 64px; }
|
|
493
|
+
|
|
494
|
+
body[data-view="chats"] .thread-pane > * { display: none; }
|
|
495
|
+
body[data-view="chats"] .thread-pane { align-items: center; justify-content: center; }
|
|
496
|
+
body[data-view="chats"] .thread-pane::before {
|
|
497
|
+
content: "pick a chat"; font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--t3);
|
|
498
|
+
}
|
|
499
|
+
.thread-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 0 20px; border-bottom: 1px solid var(--line); }
|
|
500
|
+
#thread-back { display: none; margin-left: -8px; }
|
|
501
|
+
#thread-head { flex: 1; min-width: 0; }
|
|
502
|
+
#thread-head .name { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; line-height: 1.3; }
|
|
503
|
+
#thread-head .handle { font-size: 13px; color: var(--t3); line-height: 1.3; }
|
|
504
|
+
.streak#thread-streak { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--yap-hi); }
|
|
505
|
+
#thread-streak .ico { width: 14px; height: 14px; fill: currentColor; stroke: none; }
|
|
506
|
+
#thread-streak:empty { display: none; }
|
|
507
|
+
|
|
508
|
+
#thread-list { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; padding: 20px 24px; }
|
|
509
|
+
#thread-list > .empty { margin: auto; }
|
|
510
|
+
.thread-scroll-inner { display: flex; flex-direction: column; margin-top: auto; }
|
|
511
|
+
.day-sep { align-self: center; margin: 16px 0 8px; font-size: 13px; color: var(--t3); }
|
|
512
|
+
.bubble {
|
|
513
|
+
display: flex; flex-direction: column; width: fit-content; max-width: 72%; margin-top: 3px; padding: 10px 14px;
|
|
514
|
+
border-radius: 22px; background: rgb(255 255 255 / .07); box-shadow: inset 0 1px 0 rgb(255 255 255 / .1);
|
|
515
|
+
font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; text-align: left;
|
|
516
|
+
}
|
|
517
|
+
.bubble.me { align-self: flex-end; background: var(--grad); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -2px 0 rgb(0 0 0 / .16); }
|
|
518
|
+
.bubble:not(.me) { align-self: flex-start; }
|
|
519
|
+
.bubble .when { display: none; margin-top: 2px; font-size: 13px; opacity: .65; }
|
|
520
|
+
.bubble[data-group="solo"] .when, .bubble[data-group="last"] .when { display: block; }
|
|
521
|
+
.bubble.me[data-group="first"], .bubble.me[data-group="mid"] { border-bottom-right-radius: 8px; }
|
|
522
|
+
.bubble.me[data-group="mid"], .bubble.me[data-group="last"] { border-top-right-radius: 8px; }
|
|
523
|
+
.bubble:not(.me)[data-group="first"], .bubble:not(.me)[data-group="mid"] { border-bottom-left-radius: 8px; }
|
|
524
|
+
.bubble:not(.me)[data-group="mid"], .bubble:not(.me)[data-group="last"] { border-top-left-radius: 8px; }
|
|
525
|
+
.bubble[data-group="first"], .bubble[data-group="solo"] { margin-top: 12px; }
|
|
526
|
+
.bubble.photo, .bubble.locked { flex-direction: row; align-items: center; gap: 8px; }
|
|
527
|
+
.bubble.photo .when { margin: 0 0 0 4px; }
|
|
528
|
+
.bubble.locked {
|
|
529
|
+
flex-direction: column; align-items: flex-start; gap: 2px; cursor: pointer;
|
|
530
|
+
border: 1.5px solid transparent;
|
|
531
|
+
background: linear-gradient(rgb(255 255 255 / .07), rgb(255 255 255 / .07)) padding-box, linear-gradient(rgb(16 16 20 / .96), rgb(16 16 20 / .96)) padding-box, var(--grad) border-box;
|
|
532
|
+
transition: transform 120ms var(--spring), filter 160ms;
|
|
533
|
+
}
|
|
534
|
+
.bubble.locked:hover { filter: brightness(1.2); transform: scale(1.02); }
|
|
535
|
+
.bubble.locked .locked-row { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
|
|
536
|
+
.bubble.locked .locked-row .ico { width: 17px; height: 17px; color: var(--sky); }
|
|
537
|
+
.bubble.locked .locked-sub { font-size: 13px; opacity: .7; }
|
|
538
|
+
.bubble.locked .when { display: block; }
|
|
539
|
+
.thread-state { align-self: flex-end; display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 13px; color: var(--t3); animation: fade-in 300ms var(--ease); }
|
|
540
|
+
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } }
|
|
541
|
+
.thread-state .ico { width: 12px; height: 12px; }
|
|
542
|
+
|
|
543
|
+
.threadbar { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
|
|
544
|
+
.threadbar .iconbtn { height: 44px; width: 44px; }
|
|
545
|
+
.threadbar textarea { flex: 1; min-height: 44px; max-height: 160px; overflow-y: auto; scrollbar-width: none; }
|
|
546
|
+
.threadbar textarea::-webkit-scrollbar { display: none; }
|
|
547
|
+
.send { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--grad); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 6px 18px -6px rgb(47 107 255 / .6); transition: filter 160ms var(--ease), transform 120ms var(--spring); }
|
|
548
|
+
.send:not(:disabled):hover { filter: brightness(1.15); }
|
|
549
|
+
.send:active:not(:disabled) { transform: scale(.9); }
|
|
550
|
+
.send[data-empty="true"], .send:disabled { background: var(--s2); color: var(--t3); }
|
|
551
|
+
|
|
552
|
+
/* ---------------------------------------------------------------- camera */
|
|
553
|
+
.cam-route {
|
|
554
|
+
--sh: min(calc(100dvh - var(--topbar-h) - 150px), 700px); --sw: calc(var(--sh) * .75);
|
|
555
|
+
display: flex; flex-direction: column; align-items: center;
|
|
556
|
+
}
|
|
557
|
+
.cam-route > * { width: var(--sw); max-width: 100%; }
|
|
558
|
+
.cam-stage {
|
|
559
|
+
position: relative; height: var(--sh); min-height: 320px; overflow: hidden;
|
|
560
|
+
border-radius: var(--r-card); background: #000; border: 1px solid var(--line-2);
|
|
561
|
+
}
|
|
562
|
+
.cam-stage video, .cam-stage .shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
|
563
|
+
.cam-stage::after {
|
|
564
|
+
content: ""; position: absolute; inset: 14px; z-index: 5; pointer-events: none;
|
|
565
|
+
--c: linear-gradient(var(--sky), var(--sky));
|
|
566
|
+
background:
|
|
567
|
+
var(--c) top left / 18px 2px, var(--c) top left / 2px 18px,
|
|
568
|
+
var(--c) top right / 18px 2px, var(--c) top right / 2px 18px,
|
|
569
|
+
var(--c) bottom left / 18px 2px, var(--c) bottom left / 2px 18px,
|
|
570
|
+
var(--c) bottom right / 18px 2px, var(--c) bottom right / 2px 18px;
|
|
571
|
+
background-repeat: no-repeat;
|
|
572
|
+
}
|
|
573
|
+
.cam-flash { position: absolute; inset: 0; z-index: 6; background: #fff; opacity: 0; pointer-events: none; }
|
|
574
|
+
.cam-flash[data-go="true"] { animation: flash 120ms ease-out; }
|
|
575
|
+
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
|
|
576
|
+
.drop-hint { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgb(0 0 0 / .72); font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 160ms; }
|
|
577
|
+
.cam-stage[data-drop="true"] .drop-hint { opacity: 1; }
|
|
578
|
+
.cam-stage .cap { position: absolute; left: 24px; right: 24px; bottom: 112px; z-index: 4; text-align: center; font-size: 17px; font-weight: 600; text-shadow: 0 1px 14px rgb(0 0 0 / .7); }
|
|
579
|
+
.cam-stage .cap:empty { display: none; }
|
|
580
|
+
|
|
581
|
+
.cam-noSrc { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 32px; background: var(--s1); text-align: center; }
|
|
582
|
+
.cam-noSrc .obj { display: block; width: 120px; height: 120px; margin: 0 auto 18px; }
|
|
583
|
+
.cam-noSrc h3 { margin-bottom: 8px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
|
|
584
|
+
.cam-noSrc p { max-width: 30ch; margin: 0 auto 20px; color: var(--t2); }
|
|
585
|
+
.cam-noSrc details { margin-top: 18px; font-size: 13px; color: var(--t3); }
|
|
586
|
+
.cam-noSrc details summary { cursor: pointer; }
|
|
587
|
+
.cam-noSrc details pre { max-width: 100%; overflow: auto; white-space: pre-wrap; text-align: left; font-size: 12px; color: var(--t3); }
|
|
588
|
+
.cam-noSrc .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
|
|
589
|
+
|
|
590
|
+
.cam-bar {
|
|
591
|
+
position: absolute; inset: auto 0 0 0; z-index: 4; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
|
|
592
|
+
padding: 64px 24px 24px; background: linear-gradient(to top, rgb(0 0 0 / .72), transparent); pointer-events: none;
|
|
593
|
+
}
|
|
594
|
+
.cam-bar > * { pointer-events: auto; }
|
|
595
|
+
.cam-side { justify-self: start; }
|
|
596
|
+
.cam-actions { display: none; }
|
|
597
|
+
.cam-stage[data-blocked="true"][data-review="false"] .cam-bar { display: none; }
|
|
598
|
+
.cam-bar .btn.ghost { background: rgb(0 0 0 / .5); border-color: rgb(255 255 255 / .2); color: #fff; }
|
|
599
|
+
.cam-bar .btn.ghost:hover { background: rgb(0 0 0 / .7); }
|
|
600
|
+
.cam-stage .btn.primary:disabled { background: rgb(0 0 0 / .5); color: rgb(255 255 255 / .55); }
|
|
601
|
+
.shutter {
|
|
602
|
+
width: 78px; height: 78px; padding: 6px; border: 4px solid #fff; border-radius: 50%;
|
|
603
|
+
background: var(--grad); background-clip: content-box;
|
|
604
|
+
transition: transform 120ms var(--spring); box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 8px 30px -6px rgb(47 107 255 / .55);
|
|
605
|
+
}
|
|
606
|
+
.shutter:hover { transform: scale(1.05); }
|
|
607
|
+
.shutter:active { transform: scale(.88); }
|
|
608
|
+
.cam-stage[data-review="true"] .cam-side, .cam-stage[data-review="true"] .shutter { display: none; }
|
|
609
|
+
.cam-stage[data-review="true"] .cam-actions { display: flex; grid-column: 1 / -1; justify-content: space-between; align-items: center; gap: 10px; }
|
|
610
|
+
.cam-send-group { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
|
|
611
|
+
.cam-story-btn { min-width: 132px; height: 44px; padding: 0 20px; font-size: 15px; font-weight: 700; }
|
|
612
|
+
|
|
613
|
+
/* snapchat-style text overlays and edit rail */
|
|
614
|
+
.snap-text-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
|
|
615
|
+
.snap-text-layer > * { pointer-events: auto; }
|
|
616
|
+
.snap-text, .story-text {
|
|
617
|
+
position: absolute; max-width: 86%; padding: 2px 4px; border-radius: 6px;
|
|
618
|
+
color: var(--tx-color, #fff); font-family: var(--font-display); font-weight: 800; line-height: 1.12; letter-spacing: -.015em;
|
|
619
|
+
text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; text-shadow: 0 2px 10px rgb(0 0 0 / .88), 0 0 2px rgb(0 0 0 / .8);
|
|
620
|
+
transform: translate(-50%, -50%); touch-action: none; user-select: none;
|
|
621
|
+
}
|
|
622
|
+
.snap-text { z-index: 3; cursor: grab; }
|
|
623
|
+
.story-text { z-index: 2; pointer-events: none; }
|
|
624
|
+
.snap-text:active { cursor: grabbing; }
|
|
625
|
+
.snap-text[data-bar="true"], .story-text[data-bar="true"] {
|
|
626
|
+
padding: .22em .38em; border-radius: 3px; background: rgb(0 0 0 / .74); text-shadow: none;
|
|
627
|
+
box-shadow: 0 1px 8px rgb(0 0 0 / .22);
|
|
628
|
+
}
|
|
629
|
+
.snap-text[data-active="true"] { outline: 1.5px solid rgb(60 200 255 / .72); outline-offset: 5px; }
|
|
630
|
+
.snap-text-remove {
|
|
631
|
+
position: absolute; right: -14px; top: -14px; display: none; place-items: center; width: 24px; height: 24px;
|
|
632
|
+
border-radius: 50%; background: rgb(0 0 0 / .72); color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .24);
|
|
633
|
+
font-size: 15px; line-height: 1;
|
|
634
|
+
}
|
|
635
|
+
.snap-text[data-active="true"] .snap-text-remove { display: grid; }
|
|
636
|
+
.snap-text-input {
|
|
637
|
+
position: absolute; z-index: 8; width: min(84%, 340px); min-height: 44px; padding: 6px 10px; border: 0; outline: 1.5px solid var(--sky); outline-offset: 4px;
|
|
638
|
+
border-radius: 6px; background: rgb(0 0 0 / .28); color: var(--tx-color, #fff); resize: none; text-align: center;
|
|
639
|
+
font-family: var(--font-display); font-weight: 800; line-height: 1.12; letter-spacing: -.015em; caret-color: var(--sky);
|
|
640
|
+
text-shadow: 0 2px 10px rgb(0 0 0 / .88), 0 0 2px rgb(0 0 0 / .8); transform: translate(-50%, -50%);
|
|
641
|
+
}
|
|
642
|
+
.snap-text-input[data-bar="true"] { background: rgb(0 0 0 / .78); text-shadow: none; }
|
|
643
|
+
.cam-edit-rail {
|
|
644
|
+
position: absolute; right: 12px; top: 70px; z-index: 7; display: none; flex-direction: column; align-items: center; gap: 8px;
|
|
645
|
+
}
|
|
646
|
+
.cam-stage[data-review="true"] .cam-edit-rail { display: flex; }
|
|
647
|
+
.cam-tool {
|
|
648
|
+
display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
|
|
649
|
+
background: rgb(0 0 0 / .48); color: #fff; font-size: 22px; font-weight: 800; font-family: var(--font-display);
|
|
650
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), inset 0 0 0 1px rgb(255 255 255 / .1), 0 4px 14px rgb(0 0 0 / .28);
|
|
651
|
+
-webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: transform 120ms var(--spring), background-color 140ms;
|
|
652
|
+
}
|
|
653
|
+
.cam-tool:hover { background: rgb(47 107 255 / .58); transform: translateY(-1px); }
|
|
654
|
+
.cam-tool:active { transform: scale(.9); }
|
|
655
|
+
.cam-tool.small-tool { width: 36px; height: 36px; font-size: 13px; font-weight: 800; }
|
|
656
|
+
.cam-text-colors { display: grid; gap: 6px; padding: 7px; border-radius: var(--r-pill); background: rgb(0 0 0 / .42); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .1); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
|
|
657
|
+
.cam-color { width: 20px; height: 20px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .35); transition: transform 120ms var(--spring); }
|
|
658
|
+
.cam-color[data-on="true"] { outline: 2px solid var(--sky); outline-offset: 2px; }
|
|
659
|
+
.cam-color:active { transform: scale(.86); }
|
|
660
|
+
|
|
661
|
+
/* GIF/meme picker */
|
|
662
|
+
.memeGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
|
|
663
|
+
.memeGrid.two { grid-template-columns: 1fr 1fr; }
|
|
664
|
+
.giftile { position: relative; overflow: hidden; aspect-ratio: 1; border-radius: 14px; background: var(--s2); box-shadow: inset 0 0 0 1px var(--line); transition: transform 140ms var(--spring), box-shadow 140ms; }
|
|
665
|
+
.giftile:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 2px rgb(60 200 255 / .6); }
|
|
666
|
+
.giftile:active { transform: scale(.95); }
|
|
667
|
+
.giftile img { width: 100%; height: 100%; object-fit: cover; }
|
|
668
|
+
.gif-skel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
|
|
669
|
+
.gif-skel i { aspect-ratio: 1; border-radius: 14px; background: linear-gradient(100deg, var(--s2) 38%, var(--s3) 50%, var(--s2) 62%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
|
|
670
|
+
.klipy-credit {
|
|
671
|
+
position: sticky; bottom: 0; margin-top: 8px; padding: 10px 2px 2px;
|
|
672
|
+
text-align: right; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--t3);
|
|
673
|
+
background: linear-gradient(transparent, rgb(22 22 24 / .96) 42%);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/* custom context menu */
|
|
677
|
+
.ctxmenu {
|
|
678
|
+
position: fixed; z-index: 90; width: 238px; padding: 7px; border: 0; border-radius: 18px; color: var(--t1);
|
|
679
|
+
background: var(--glass-bg); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
|
|
680
|
+
box-shadow: var(--glass-shadow); transform-origin: top left;
|
|
681
|
+
}
|
|
682
|
+
.ctxmenu::before {
|
|
683
|
+
content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
|
|
684
|
+
background: linear-gradient(135deg, rgb(255 255 255 / .16), rgb(255 255 255 / .03) 40%, rgb(255 255 255 / .03) 60%, rgb(255 255 255 / .09));
|
|
685
|
+
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
|
|
686
|
+
}
|
|
687
|
+
.ctxmenu:not(.hidden) { animation: ctx-in 150ms var(--spring); }
|
|
688
|
+
@keyframes ctx-in { from { opacity: 0; transform: scale(.94); } }
|
|
689
|
+
.ctxmenu-item {
|
|
690
|
+
display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border-radius: 12px;
|
|
691
|
+
color: var(--t2); font-size: 14px; font-weight: 600; text-align: left; transition: background-color 110ms, color 110ms;
|
|
692
|
+
}
|
|
693
|
+
.ctxmenu-item .ico { width: 17px; height: 17px; }
|
|
694
|
+
.ctxmenu-item:hover, .ctxmenu-item:focus-visible { background: rgb(47 107 255 / .32); color: #fff; outline: 0; }
|
|
695
|
+
.ctxmenu-sep { height: 1px; margin: 6px 8px; background: var(--line); }
|
|
696
|
+
|
|
697
|
+
.cam-cap-row { margin-top: 12px; }
|
|
698
|
+
.filters-strip {
|
|
699
|
+
display: none; gap: 8px; margin-top: 12px; padding: 2px 0; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
|
|
700
|
+
-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
|
|
701
|
+
}
|
|
702
|
+
.cam-route:has(.cam-stage[data-live="true"]) .filters-strip { display: flex; }
|
|
703
|
+
.filters-strip::-webkit-scrollbar { display: none; }
|
|
704
|
+
.fchip { display: inline-flex; align-items: center; gap: 8px; flex: none; height: 38px; padding: 0 14px; border-radius: var(--r-pill); scroll-snap-align: start; font-size: 14px; font-weight: 500; color: var(--t2); transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--spring); }
|
|
705
|
+
.fchip:hover { background: var(--s2); color: var(--t1); }
|
|
706
|
+
.fchip[data-on="true"] { background: var(--grad); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -1px 0 rgb(0 0 0 / .16); animation: pop-in 260ms var(--spring); }
|
|
707
|
+
.fswatch { width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--grad); border: 1px solid rgb(255 255 255 / .25); }
|
|
708
|
+
|
|
709
|
+
/* --------------------------------------------------------------- profile */
|
|
710
|
+
.banner { position: relative; height: 220px; overflow: hidden; border-radius: var(--r-card); background: var(--s2); }
|
|
711
|
+
.banner-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
|
712
|
+
.prof-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 0 4px; }
|
|
713
|
+
.prof-head > #prof-avatar { grid-column: 1; grid-row: 1; justify-self: start; margin-top: -56px; margin-left: 16px; box-shadow: 0 0 0 4px var(--bg); }
|
|
714
|
+
.prof-head > #prof-avatar[data-frame="ring"], .prof-head > #prof-avatar[data-frame="verified"] { outline-offset: 8px; }
|
|
715
|
+
.prof-head > #prof-edit { grid-column: 2; grid-row: 1; align-self: end; margin-bottom: 8px; }
|
|
716
|
+
.prof-ident { position: relative; grid-column: 1 / -1; grid-row: 2; margin-top: 16px; }
|
|
717
|
+
.prof-ident[data-plate="true"] {
|
|
718
|
+
min-height: 118px; display: flex; flex-direction: column; justify-content: center;
|
|
719
|
+
overflow: hidden; padding: 16px 20px; border-radius: 22px;
|
|
720
|
+
}
|
|
721
|
+
.prof-ident > *:not(.plate-layer) { position: relative; z-index: 1; }
|
|
722
|
+
.plate-layer { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: var(--s2); }
|
|
723
|
+
.plate-layer video { width: 100%; height: 100%; object-fit: cover; }
|
|
724
|
+
.plate-layer::after {
|
|
725
|
+
content: ""; position: absolute; inset: 0;
|
|
726
|
+
background: linear-gradient(90deg, rgb(0 0 0 / .68), rgb(0 0 0 / .34) 52%, rgb(0 0 0 / .58));
|
|
727
|
+
}
|
|
728
|
+
.prof-name { font-size: 34px; font-weight: 800; line-height: 1.05; text-shadow: 0 1px 12px rgb(0 0 0 / .35); }
|
|
729
|
+
.prof-handle-row { display: flex; gap: 6px; margin-top: 6px; font-size: 15px; color: var(--t3); }
|
|
730
|
+
#prof-joined { display: inline; height: auto; padding: 0; border: 0; font-size: inherit; color: inherit; }
|
|
731
|
+
#prof-joined::before { content: "· "; }
|
|
732
|
+
.prof-bio { margin-top: 16px; font-size: 16px; color: var(--t2); }
|
|
733
|
+
.prof-bio[data-empty="true"] {
|
|
734
|
+
display: inline-flex; padding: 8px 16px; border: 1.5px dashed var(--line-2); border-radius: var(--r-pill);
|
|
735
|
+
color: var(--t3); font-size: 14px; font-weight: 600; cursor: pointer; transition: color 160ms, border-color 160ms, transform 120ms var(--spring);
|
|
736
|
+
}
|
|
737
|
+
.prof-bio[data-empty="true"]:hover { color: var(--sky); border-color: var(--sky); }
|
|
738
|
+
.prof-bio[data-empty="true"]:active { transform: scale(.96); }
|
|
739
|
+
.prof-badges { display: flex; gap: 6px; margin-top: 12px; }
|
|
740
|
+
.prof-badges:empty { display: none; }
|
|
741
|
+
.prof-stats { display: flex; gap: 10px; margin-top: 16px; }
|
|
742
|
+
.stat {
|
|
743
|
+
display: flex; align-items: baseline; gap: 6px; padding: 8px 14px;
|
|
744
|
+
border: 0; border-radius: var(--r-pill); font-size: 13px; color: var(--t2);
|
|
745
|
+
}
|
|
746
|
+
.stat .num { font-size: 17px; font-weight: 800; color: var(--t1); font-variant-numeric: tabular-nums; }
|
|
747
|
+
.prof-section { margin-top: 32px; }
|
|
748
|
+
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
|
|
749
|
+
.section-head h3 { font-size: 20px; }
|
|
750
|
+
|
|
751
|
+
.drawer {
|
|
752
|
+
position: fixed; inset: 0 0 0 auto; z-index: 40; display: flex; flex-direction: column; width: 430px; max-width: 100%;
|
|
753
|
+
border-left: 1px solid rgb(255 255 255 / .1);
|
|
754
|
+
transform: translateX(100%); visibility: hidden; transition: transform 280ms var(--ease), visibility 0s 280ms;
|
|
755
|
+
}
|
|
756
|
+
.drawer[data-open="true"] { transform: none; visibility: visible; transition-delay: 0s; }
|
|
757
|
+
.drawer-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
|
|
758
|
+
.drawer-head h3 { font-size: 20px; }
|
|
759
|
+
.drawer-body { flex: 1; display: grid; align-content: start; gap: 24px; padding: 24px; overflow: auto; }
|
|
760
|
+
.drawer-foot { flex: none; display: flex; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
|
|
761
|
+
.drawer-foot #pf-save { flex: 1; }
|
|
762
|
+
.drawer-scrim { position: fixed; inset: 0; z-index: 39; background: rgb(0 0 0 / .55); opacity: 0; pointer-events: none; transition: opacity 240ms var(--ease); }
|
|
763
|
+
.drawer-scrim[data-open="true"] { opacity: 1; pointer-events: auto; }
|
|
764
|
+
|
|
765
|
+
.bannersel { display: flex; gap: 10px; flex-wrap: wrap; }
|
|
766
|
+
.bannersel button { position: relative; width: 72px; height: 48px; border-radius: 14px; border: 1px solid rgb(255 255 255 / .16); box-shadow: inset 0 1px 0 rgb(255 255 255 / .18); transition: transform 160ms var(--spring); }
|
|
767
|
+
.bannersel button:hover { transform: translateY(-2px); }
|
|
768
|
+
.bannersel button:active { transform: scale(.93); }
|
|
769
|
+
.bannersel button[aria-pressed="true"] { outline: 2px solid var(--sky); outline-offset: 2px; }
|
|
770
|
+
.bannersel button[aria-pressed="true"]::after {
|
|
771
|
+
content: ""; position: absolute; inset: 0;
|
|
772
|
+
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 18px no-repeat;
|
|
773
|
+
animation: pop-in 240ms var(--spring);
|
|
774
|
+
}
|
|
775
|
+
.swatch-midnight { background: linear-gradient(150deg, #070b12, #16295c); }
|
|
776
|
+
.swatch-aurora { background: linear-gradient(150deg, #041a2e, #0e5f9e); }
|
|
777
|
+
.swatch-sunset { background: linear-gradient(150deg, #0b1030, #2440a8); }
|
|
778
|
+
.swatch-royal { background: linear-gradient(150deg, #16224d, #2f6bff); }
|
|
779
|
+
.swatch-carbon { background: linear-gradient(150deg, #0c1017, #2a3140); }
|
|
780
|
+
|
|
781
|
+
.prof-preview { overflow: hidden; border: 0; border-radius: var(--r-card); }
|
|
782
|
+
.pv-banner { height: 120px; }
|
|
783
|
+
.pv-body { padding: 0 16px 16px; }
|
|
784
|
+
.pv-av { margin-top: -28px; box-shadow: 0 0 0 4px var(--s2); }
|
|
785
|
+
.pv-name { margin-top: 10px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
|
|
786
|
+
.pv-handle { font-size: 14px; color: var(--t3); }
|
|
787
|
+
.pv-body p { font-size: 14px !important; color: var(--t2) !important; }
|
|
788
|
+
|
|
789
|
+
/* profile cosmetics pickers + uploads */
|
|
790
|
+
.cosmetic-grid {
|
|
791
|
+
display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
|
|
792
|
+
max-height: 286px; overflow: auto; padding: 3px; scrollbar-width: thin;
|
|
793
|
+
}
|
|
794
|
+
.cosmetic-grid.plates { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 300px; }
|
|
795
|
+
.cosmetic-tile {
|
|
796
|
+
position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 1;
|
|
797
|
+
border: 1px solid var(--line); border-radius: 16px; background: rgb(255 255 255 / .045);
|
|
798
|
+
color: var(--t2); transition: transform 140ms var(--spring), border-color 140ms, box-shadow 140ms;
|
|
799
|
+
}
|
|
800
|
+
.cosmetic-grid.plates .cosmetic-tile { aspect-ratio: 16 / 3; }
|
|
801
|
+
.cosmetic-tile:hover { transform: translateY(-1px); border-color: var(--line-2); }
|
|
802
|
+
.cosmetic-tile:active { transform: scale(.96); }
|
|
803
|
+
.cosmetic-tile img, .cosmetic-tile video { width: 100%; height: 100%; object-fit: cover; }
|
|
804
|
+
.cosmetic-tile.decor img { width: 82%; height: 82%; object-fit: contain; }
|
|
805
|
+
.cosmetic-tile[data-on="true"] {
|
|
806
|
+
border-color: var(--sky); box-shadow: 0 0 0 2px rgb(60 200 255 / .72), 0 0 22px rgb(47 107 255 / .34);
|
|
807
|
+
}
|
|
808
|
+
.cosmetic-tile .cosmetic-name {
|
|
809
|
+
position: absolute; left: 5px; right: 5px; bottom: 5px; padding: 2px 6px; border-radius: 8px;
|
|
810
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgb(0 0 0 / .58);
|
|
811
|
+
color: #fff; font-size: 11px; font-weight: 700; line-height: 1.5; pointer-events: none;
|
|
812
|
+
}
|
|
813
|
+
.cosmetic-tile.none { font-size: 13px; font-weight: 700; }
|
|
814
|
+
.uploadrow {
|
|
815
|
+
display: flex; align-items: center; gap: 12px; padding: 12px;
|
|
816
|
+
border: 1px solid var(--line); border-radius: 18px; background: rgb(255 255 255 / .035);
|
|
817
|
+
}
|
|
818
|
+
.uploadrow .avatar { width: 48px; height: 48px; font-size: 16px; }
|
|
819
|
+
.uploadcopy { flex: 1; min-width: 0; }
|
|
820
|
+
.uploadcopy .row { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
821
|
+
.uploadcopy .hint { margin-top: 7px; }
|
|
822
|
+
.pv-banner { position: relative; overflow: hidden; }
|
|
823
|
+
.pv-idblock { position: relative; margin-top: 10px; }
|
|
824
|
+
.pv-idblock[data-plate="true"] { overflow: hidden; padding: 10px 12px; border-radius: 14px; }
|
|
825
|
+
.pv-idblock > *:not(.plate-layer) { position: relative; z-index: 1; }
|
|
826
|
+
.pv-idblock .pv-name { margin-top: 0; }
|
|
827
|
+
.pv-idblock[data-plate="false"] .pv-name { margin-top: 0; }
|
|
828
|
+
|
|
829
|
+
/* ----------------------------------------------------------------- admin */
|
|
830
|
+
.page-title { margin: 8px 0 20px; font-size: 34px; font-weight: 800; line-height: 1.1; }
|
|
831
|
+
.admin-tabs { display: flex; gap: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
|
|
832
|
+
.admin-tabs button { position: relative; padding: 12px 0; font-size: 14px; font-weight: 500; color: var(--t2); white-space: nowrap; transition: color 160ms var(--ease); }
|
|
833
|
+
.admin-tabs button:hover { color: var(--t1); }
|
|
834
|
+
.admin-tabs button.on { color: var(--t1); }
|
|
835
|
+
.admin-tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px; background: var(--grad); }
|
|
836
|
+
#admin-back { display: none; }
|
|
837
|
+
.grid2 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 40px; border-block: 1px solid var(--line); }
|
|
838
|
+
.grid2 .tile { padding: 20px 16px; border-left: 1px solid var(--line); }
|
|
839
|
+
.grid2 .tile:first-child { padding-left: 0; border-left: 0; }
|
|
840
|
+
.grid2 .k { font-size: 44px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
|
|
841
|
+
.grid2 .l { margin-top: 4px; font-size: 13px; color: var(--t3); }
|
|
842
|
+
#admin-body .section-head { margin-bottom: 4px; }
|
|
843
|
+
.listitem { padding: 16px 0; border-bottom: 1px solid var(--line); }
|
|
844
|
+
#admin-body > p.small, #admin-body > .skeleton { color: var(--t3); }
|
|
845
|
+
#admin-body .field { margin-bottom: 4px; }
|
|
846
|
+
|
|
847
|
+
/* -------------------------------------------------------------- overlays */
|
|
848
|
+
.userpop {
|
|
849
|
+
position: fixed; inset: auto; margin: 0; width: 240px; padding: 8px; color: var(--t1);
|
|
850
|
+
border: 0; border-radius: 20px;
|
|
851
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 16px 48px -12px rgb(0 0 0 / .6);
|
|
852
|
+
opacity: 0; transform: scale(.94); transform-origin: top right;
|
|
853
|
+
transition: opacity 140ms var(--ease), transform 200ms var(--spring), display 140ms allow-discrete, overlay 140ms allow-discrete;
|
|
854
|
+
}
|
|
855
|
+
.userpop:popover-open { opacity: 1; transform: none; }
|
|
856
|
+
@starting-style { .userpop:popover-open { opacity: 0; transform: scale(.94); } }
|
|
857
|
+
.userpop-head { position: relative; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; padding: 8px 8px 12px; overflow: hidden; border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; }
|
|
858
|
+
.userpop-head[data-plate="true"] { min-height: 74px; }
|
|
859
|
+
.userpop-head > *:not(.plate-layer) { position: relative; z-index: 1; }
|
|
860
|
+
.userpop-head .name { font-size: 15px; font-weight: 700; line-height: 1.3; }
|
|
861
|
+
.userpop-head .handle { font-size: 13px; color: var(--t3); line-height: 1.3; }
|
|
862
|
+
.userpop-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 10px; border-radius: 14px; font-size: 14px; color: var(--t2); transition: background-color 120ms, color 120ms; }
|
|
863
|
+
.userpop-item .ico { width: 18px; height: 18px; }
|
|
864
|
+
.userpop-item:hover { background: var(--s3); color: var(--t1); }
|
|
865
|
+
.userpop-item[data-rose="true"]:hover { color: var(--tx-1); }
|
|
866
|
+
|
|
867
|
+
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgb(0 0 0 / .6); opacity: 0; visibility: hidden; transition: opacity 200ms var(--ease), visibility 0s 200ms; }
|
|
868
|
+
.overlay.on { opacity: 1; visibility: visible; transition-delay: 0s; }
|
|
869
|
+
.sheet { width: min(440px, 100%); max-height: calc(100dvh - 48px); overflow: auto; padding: 24px; border: 0; border-radius: var(--r-card); transform: translateY(8px) scale(.96); transition: transform 260ms var(--spring); }
|
|
870
|
+
.overlay.on .sheet { transform: none; }
|
|
871
|
+
.sheet h3 { font-size: 20px; }
|
|
872
|
+
.sheet-actions { display: grid; gap: 8px; margin-top: 16px; }
|
|
873
|
+
.sheet-actions .btn { justify-content: flex-start; height: 44px; }
|
|
874
|
+
.sheet .hint { margin-top: 12px; font-size: 13px; color: var(--t3); }
|
|
875
|
+
|
|
876
|
+
#storyview { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; background: rgb(0 0 0 / .94); --svh: min(calc(100dvh - 140px), 760px); }
|
|
877
|
+
#storyview.on { display: flex; }
|
|
878
|
+
#storyview.on > .wrap { animation: story-in 260ms var(--spring); }
|
|
879
|
+
@keyframes story-in { from { opacity: .5; transform: scale(.92); } }
|
|
880
|
+
#storyview > div:first-child { width: calc(var(--svh) * .75); max-width: 100%; }
|
|
881
|
+
#storyview .bars { display: flex; gap: 4px; margin-bottom: 12px; }
|
|
882
|
+
#storyview .bars i { flex: 1; height: 3px; border-radius: 2px; overflow: hidden; background: rgb(255 255 255 / .25); }
|
|
883
|
+
#storyview .bars i b { display: block; height: 100%; width: 0; border-radius: 2px; background: #fff; }
|
|
884
|
+
#storyview .bars i.done b { width: 100%; }
|
|
885
|
+
#storyview .bars i.live b { animation: story-fill 6000ms linear forwards; }
|
|
886
|
+
@keyframes story-fill { from { width: 0; } to { width: 100%; } }
|
|
887
|
+
#storyview .head { display: flex; align-items: center; gap: 10px; }
|
|
888
|
+
#storyview .head .name { font-size: 15px; font-weight: 700; }
|
|
889
|
+
#storyview .head .mono { font-size: 13px; }
|
|
890
|
+
#storyview .wrap { position: relative; width: calc(var(--svh) * .75); max-width: 100%; height: var(--svh); overflow: hidden; border-radius: var(--r-card); background: #000; }
|
|
891
|
+
#storyview .wrap img { width: 100%; height: 100%; object-fit: cover; }
|
|
892
|
+
#storyview .nav { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; }
|
|
893
|
+
#storyview .nav > div { cursor: pointer; }
|
|
894
|
+
#storyview .cap { position: absolute; left: 20px; right: 20px; bottom: 24px; text-align: center; font-size: 19px; text-shadow: 0 1px 14px rgb(0 0 0 / .8); pointer-events: none; }
|
|
895
|
+
|
|
896
|
+
.lightbox { width: 100vw; max-width: none; height: 100vh; max-height: none; padding: 0; border: 0; background: transparent; }
|
|
897
|
+
.lightbox[open] { display: grid; place-items: center; }
|
|
898
|
+
.lightbox::backdrop { background: rgb(0 0 0 / .85); }
|
|
899
|
+
.lightbox-body { max-width: 92vw; max-height: 88vh; }
|
|
900
|
+
.lightbox-body img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: var(--r-card); }
|
|
901
|
+
.lightbox-close, .lightbox-nav { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgb(0 0 0 / .55); color: #fff; transition: background-color 160ms; }
|
|
902
|
+
.lightbox-close:hover, .lightbox-nav:hover { background: rgb(255 255 255 / .16); }
|
|
903
|
+
.lightbox-close { top: 24px; right: 24px; }
|
|
904
|
+
.lightbox-nav[data-dir="prev"] { left: 24px; top: 50%; margin-top: -22px; }
|
|
905
|
+
.lightbox-nav[data-dir="next"] { right: 24px; top: 50%; margin-top: -22px; }
|
|
906
|
+
|
|
907
|
+
#toasts { position: fixed; left: 50%; bottom: 24px; z-index: 70; display: grid; gap: 8px; justify-items: center; transform: translateX(-50%); pointer-events: none; }
|
|
908
|
+
.toast {
|
|
909
|
+
position: relative; display: flex; align-items: center; gap: 8px; overflow: hidden; padding: 11px 18px;
|
|
910
|
+
border: 0; border-radius: var(--r-pill); font-size: 14px; font-weight: 600;
|
|
911
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 12px 36px -10px rgb(0 0 0 / .6);
|
|
912
|
+
pointer-events: auto; animation: toast-in 240ms var(--spring);
|
|
913
|
+
}
|
|
914
|
+
.toast .ico { width: 16px; height: 16px; }
|
|
915
|
+
.toast[data-tone="ok"] .ico { color: var(--yap-hi); }
|
|
916
|
+
.toast[data-tone="err"] .ico { color: var(--tx-1); }
|
|
917
|
+
.toast .count { color: var(--t3); }
|
|
918
|
+
.toast .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad); transform-origin: left; animation: toast-bar 3500ms linear forwards; }
|
|
919
|
+
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.92); } }
|
|
920
|
+
@keyframes toast-bar { to { transform: scaleX(0); } }
|
|
921
|
+
|
|
922
|
+
/* ------------------------------------------------------------------ auth */
|
|
923
|
+
#auth {
|
|
924
|
+
width: min(1120px, calc(100% - 48px)); min-height: 100dvh; margin: 0 auto; padding: 24px 0 40px;
|
|
925
|
+
display: grid; grid-template-columns: minmax(0, 1fr) 430px; grid-template-rows: auto minmax(0, 1fr); column-gap: 80px;
|
|
926
|
+
}
|
|
927
|
+
.auth-hero { display: contents; }
|
|
928
|
+
.auth-brand { grid-column: 1 / -1; align-self: start; padding: 8px 0; }
|
|
929
|
+
.auth-hero-mid { grid-column: 1; grid-row: 2; align-self: center; min-width: 0; }
|
|
930
|
+
.auth-side { grid-column: 2; grid-row: 2; align-self: center; }
|
|
931
|
+
.auth-h1 { font-size: clamp(48px, 7vw, 96px); font-weight: 800; line-height: 1.0; letter-spacing: -.035em; white-space: nowrap; }
|
|
932
|
+
.auth-sub { max-width: 34ch; text-wrap: balance; margin-top: 24px; font-size: 18px; color: var(--t2); }
|
|
933
|
+
|
|
934
|
+
/* one restrained brand mark: glossy blue orb with a soft breathing glow */
|
|
935
|
+
.auth-orb {
|
|
936
|
+
display: grid; place-items: center; width: 96px; height: 96px; margin-top: 56px;
|
|
937
|
+
border-radius: 28px; background: var(--grad); color: #fff;
|
|
938
|
+
box-shadow: inset 0 2px 0 rgb(255 255 255 / .5), inset 0 -4px 0 rgb(0 0 0 / .16), 0 18px 48px -8px rgb(47 107 255 / .55);
|
|
939
|
+
animation: orb-in 700ms 200ms var(--spring) both, orb-breathe 5s 1.2s ease-in-out infinite;
|
|
940
|
+
}
|
|
941
|
+
.auth-orb .ico { width: 44px; height: 44px; stroke-width: 1.5; }
|
|
942
|
+
@keyframes orb-in { from { opacity: 0; transform: translateY(18px) scale(.86); } }
|
|
943
|
+
@keyframes orb-breathe { 0%, 100% { box-shadow: inset 0 2px 0 rgb(255 255 255 / .5), inset 0 -4px 0 rgb(0 0 0 / .16), 0 18px 48px -8px rgb(47 107 255 / .55); } 50% { box-shadow: inset 0 2px 0 rgb(255 255 255 / .5), inset 0 -4px 0 rgb(0 0 0 / .16), 0 18px 60px -6px rgb(47 107 255 / .8); } }
|
|
944
|
+
@media (prefers-reduced-motion: reduce) { .auth-orb { animation: none; } }
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
.auth-card { padding: 32px; border: 0; border-radius: var(--r-card); }
|
|
949
|
+
.auth-title { margin: 24px 0 20px; font-size: 20px; }
|
|
950
|
+
.auth-form { display: flex; flex-direction: column; }
|
|
951
|
+
.auth-form > div:not(.auth-foot) { margin-bottom: 16px; }
|
|
952
|
+
#auth .field { height: 48px; }
|
|
953
|
+
#auth-name-wrap { display: grid; grid-template-rows: 1fr; margin-bottom: 0 !important; transition: grid-template-rows 240ms var(--ease), opacity 160ms var(--ease); }
|
|
954
|
+
.collapse-inner { min-height: 0; overflow: hidden; padding: 2px 4px 16px; margin: -2px -4px; }
|
|
955
|
+
#auth[data-mode="login"] #auth-name-wrap { grid-template-rows: 0fr; opacity: 0; }
|
|
956
|
+
#auth[data-mode="login"] .collapse-inner { padding-bottom: 0; visibility: hidden; transition: visibility 0s 240ms; }
|
|
957
|
+
.pw-wrap { position: relative; }
|
|
958
|
+
.pw-wrap .field { padding-right: 52px; }
|
|
959
|
+
.pw-toggle { position: absolute; right: 6px; top: 6px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-pill); color: var(--t3); transition: color 160ms, background-color 160ms; }
|
|
960
|
+
.pw-toggle:hover { color: var(--t1); background: var(--s3); }
|
|
961
|
+
.pw-toggle .ico { width: 18px; height: 18px; }
|
|
962
|
+
.hint { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--t3); }
|
|
963
|
+
.hint .ico { width: 14px; height: 14px; color: var(--yap-hi); stroke-width: 2.2; }
|
|
964
|
+
.hint[data-ok="true"] { color: var(--t1); }
|
|
965
|
+
.auth-err { display: flex; align-items: center; gap: 7px; margin: -4px 0 16px; font-size: 14px; font-weight: 600; color: var(--t1); animation: shake 160ms; }
|
|
966
|
+
.auth-err::before { content: ""; flex: none; width: 15px; height: 15px; background: currentColor;
|
|
967
|
+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5'/%3E%3Ccircle cx='12' cy='16.5' r='.9' fill='white'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
968
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5'/%3E%3Ccircle cx='12' cy='16.5' r='.9' fill='white'/%3E%3C/svg%3E") center / contain no-repeat; }
|
|
969
|
+
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
|
|
970
|
+
.auth-form #auth-submit { width: 100%; }
|
|
971
|
+
.auth-foot { margin: 16px 0 0; font-size: 13px; color: var(--t3); }
|
|
972
|
+
#auth[data-mode="login"] #pw-hint, #auth[data-mode="login"] .auth-foot { display: none; }
|
|
973
|
+
|
|
974
|
+
/* ------------------------------------------------------- medium (icons) */
|
|
975
|
+
@media (min-width: 820px) and (max-width: 1199px) {
|
|
976
|
+
.shell, body[data-ctx="off"] .shell { grid-template-columns: 76px minmax(0, var(--center-w)); column-gap: 24px; }
|
|
977
|
+
.context { display: none; }
|
|
978
|
+
.rail { align-items: center; padding: 14px 8px; }
|
|
979
|
+
.rail-word, .rail-nav button span:not(.rail-badge), .rail-new span, .rail-user .who, .rail-user > .ico { display: none; }
|
|
980
|
+
.rail-nav button { justify-content: center; width: 56px; height: 52px; padding: 0; gap: 0; }
|
|
981
|
+
.rail-badge { position: absolute; top: 4px; right: 4px; margin: 0; }
|
|
982
|
+
.rail-new { width: 56px; height: 56px; padding: 0; margin-top: 18px; border-radius: 50%; }
|
|
983
|
+
.rail-new .ico { width: 24px; height: 24px; }
|
|
984
|
+
.rail-user { justify-content: center; padding: 6px; }
|
|
985
|
+
#chats-split { grid-template-columns: 290px minmax(0, 1fr); }
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
.tabbar { display: none; } /* desktop/tablet: rail nav instead; the mobile media query flips this to a grid */
|
|
989
|
+
|
|
990
|
+
/* ----------------------------------------------------------------- mobile */
|
|
991
|
+
@media (max-width: 819px) {
|
|
992
|
+
.shell, body[data-ctx="off"] .shell { display: block; padding: 0; }
|
|
993
|
+
.rail { display: none; }
|
|
994
|
+
.context { display: none; }
|
|
995
|
+
.route-logo { display: grid; width: 30px; height: 30px; }
|
|
996
|
+
.route-logo .ico { width: 17px; height: 17px; }
|
|
997
|
+
.mob-avatar { display: grid; place-items: center; }
|
|
998
|
+
.routebar {
|
|
999
|
+
min-height: 0; padding: calc(8px + env(safe-area-inset-top)) 16px 10px; margin: 0;
|
|
1000
|
+
}
|
|
1001
|
+
.route-title { font-size: 20px; }
|
|
1002
|
+
.route-sub { display: none; }
|
|
1003
|
+
.route-actions { display: none; }
|
|
1004
|
+
.feed-wrap, .cam-route, .profile-wrap, .admin-wrap { padding: 0 16px; }
|
|
1005
|
+
#main { padding: 12px 0 calc(108px + env(safe-area-inset-bottom)); }
|
|
1006
|
+
body[data-view="camera"] #main, body[data-view="chats"] #main, body[data-view="thread"] #main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
|
|
1007
|
+
.tabbar:not(.hidden) {
|
|
1008
|
+
position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
|
|
1009
|
+
display: grid !important; grid-template-columns: repeat(5, 1fr); height: 62px; padding: 4px; align-items: stretch;
|
|
1010
|
+
border: 1px solid var(--line-2); border-radius: var(--r-pill);
|
|
1011
|
+
background: rgb(10 10 12 / .72);
|
|
1012
|
+
-webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
|
|
1013
|
+
}
|
|
1014
|
+
.tabbar button { position: relative; display: grid; place-items: center; align-content: center; gap: 2px; min-width: 0; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; color: var(--t3); }
|
|
1015
|
+
.tabbar button .ico { width: 20px; height: 20px; }
|
|
1016
|
+
.tabbar button[aria-current="page"] { color: var(--t1); }
|
|
1017
|
+
.tabbar button[aria-current="page"] .ico { animation: nav-pop 300ms var(--spring); }
|
|
1018
|
+
.tabbar .tab-cam {
|
|
1019
|
+
display: grid; place-items: center; align-self: center; justify-self: center;
|
|
1020
|
+
width: 62px; height: 62px; border-radius: 50%;
|
|
1021
|
+
transform: translateY(-16px); background: var(--grad); color: #fff;
|
|
1022
|
+
border: 4px solid var(--bg); box-shadow: inset 0 1px 0 rgb(255 255 255 / .5), inset 0 -2px 0 rgb(0 0 0 / .18), 0 10px 30px -6px rgb(47 107 255 / .55);
|
|
1023
|
+
transition: transform 130ms var(--spring);
|
|
1024
|
+
}
|
|
1025
|
+
.tabbar .tab-cam:active { transform: translateY(-16px) scale(.88); }
|
|
1026
|
+
.tabbar .tab-cam .ico { width: 26px; height: 26px; }
|
|
1027
|
+
.tab-badge { position: absolute; top: 6px; right: 14px; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; box-shadow: inset 0 1px 0 rgb(255 255 255 / .45); }
|
|
1028
|
+
.tab-badge.hidden { display: none; }
|
|
1029
|
+
#toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }
|
|
1030
|
+
.post-more { opacity: .35; }
|
|
1031
|
+
.post-media { max-width: 100%; }
|
|
1032
|
+
#chats-split { grid-template-columns: 1fr; gap: 0; height: calc(100dvh - 150px - env(safe-area-inset-bottom)); }
|
|
1033
|
+
.list-pane, .thread-pane { border: 0; border-radius: 0; background: transparent; }
|
|
1034
|
+
body[data-view="chats"] #v-thread, body[data-view="thread"] #v-chats { display: none; }
|
|
1035
|
+
#thread-back { display: inline-grid; }
|
|
1036
|
+
.thread-head { padding: 8px 12px; min-height: 60px; }
|
|
1037
|
+
#thread-list { padding: 14px 14px 20px; }
|
|
1038
|
+
.cam-route { --sh: min(calc(100dvh - 320px), 600px); }
|
|
1039
|
+
.cam-bar { padding: 56px 12px 18px; }
|
|
1040
|
+
.cam-send-group { gap: 6px; }
|
|
1041
|
+
.cam-story-btn { min-width: 0; height: 40px; padding: 0 14px; font-size: 14px; }
|
|
1042
|
+
.cam-edit-rail { right: 8px; top: 58px; gap: 6px; }
|
|
1043
|
+
.cam-tool { width: 38px; height: 38px; }
|
|
1044
|
+
.cam-tool.small-tool { width: 33px; height: 33px; font-size: 12px; }
|
|
1045
|
+
.banner { height: 140px; }
|
|
1046
|
+
.prof-head > #prof-avatar { width: 88px; height: 88px; font-size: 26px; margin-top: -44px; }
|
|
1047
|
+
.prof-name { font-size: 30px; }
|
|
1048
|
+
.grid2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1049
|
+
.grid2 .tile:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
|
|
1050
|
+
.grid2 .tile:nth-child(n + 4) { border-top: 1px solid var(--line); }
|
|
1051
|
+
.grid2 .k { font-size: 34px; }
|
|
1052
|
+
.drawer { width: 100%; }
|
|
1053
|
+
#auth { grid-template-columns: 1fr; grid-template-rows: auto auto auto; row-gap: 28px; padding: 16px 0 40px; width: min(430px, calc(100% - 32px)); }
|
|
1054
|
+
.auth-hero-mid, .auth-side { grid-column: 1; grid-row: auto; }
|
|
1055
|
+
.auth-h1 { font-size: 52px; white-space: normal; }
|
|
1056
|
+
.auth-card { padding: 24px; }
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
@media (max-width: 900px) and (min-width: 820px) {
|
|
1060
|
+
.grid2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1061
|
+
.grid2 .tile:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
|
|
1062
|
+
.grid2 .tile:nth-child(n + 4) { border-top: 1px solid var(--line); }
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1066
|
+
*, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
|
|
1067
|
+
}
|
|
1068
|
+
</style>
|
|
1069
|
+
</head>
|
|
1070
|
+
<body>
|
|
1071
|
+
|
|
1072
|
+
<svg width="0" height="0" style="position:absolute" aria-hidden="true" focusable="false"><defs>
|
|
1073
|
+
<symbol id="i-feed" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M4 6h16M4 12h16M4 18h10"/></symbol>
|
|
1074
|
+
<symbol id="i-cam" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M4 8h3l1.6-2.2h6.8L17 8h3v10.2a.8.8 0 0 1-.8.8H4.8a.8.8 0 0 1-.8-.8z"/><circle cx="12" cy="13" r="3.2"/></symbol>
|
|
1075
|
+
<symbol id="i-chat" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M4 5.8h16v9.6a1 1 0 0 1-1 1h-7.6L6.6 20v-3.6H5a1 1 0 0 1-1-1z"/></symbol>
|
|
1076
|
+
<symbol id="i-me" viewBox="0 0 24 24" fill="none" stroke="currentColor"><circle cx="12" cy="8.6" r="3.4"/><path d="M5.2 20a6.8 6.8 0 0 1 13.6 0" stroke-linecap="round"/></symbol>
|
|
1077
|
+
<symbol id="i-plus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></symbol>
|
|
1078
|
+
<symbol id="i-more" viewBox="0 0 24 24" fill="currentColor"><circle cx="5" cy="12" r="1.9"/><circle cx="12" cy="12" r="1.9"/><circle cx="19" cy="12" r="1.9"/></symbol>
|
|
1079
|
+
<symbol id="i-heart" viewBox="0 0 24 24" stroke="currentColor" stroke-linejoin="round"><path d="M12 20.2S4.3 15.6 4.3 10.6A4.3 4.3 0 0 1 12 8a4.3 4.3 0 0 1 7.7 2.6c0 5-7.7 9.6-7.7 9.6z"/></symbol>
|
|
1080
|
+
<symbol id="i-reply" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M4.5 6h15v9.5a1 1 0 0 1-1 1h-6.2L8 20v-3.5H5.5a1 1 0 0 1-1-1z"/></symbol>
|
|
1081
|
+
<symbol id="i-image" viewBox="0 0 24 24" fill="none" stroke="currentColor"><rect x="3.2" y="5" width="17.6" height="14" rx="3"/><circle cx="8.6" cy="10.2" r="1.5" fill="currentColor" stroke="none"/><path d="m5.4 17.4 4.6-4.6 3 3L16 12.4l3.4 3.4" stroke-linecap="round"/></symbol>
|
|
1082
|
+
<symbol id="i-gif" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><rect x="3.2" y="5" width="17.6" height="14" rx="3"/><path d="M8.2 10.2H6.8v3.6h1.4m6.2-3.6v3.6m0-3.6h2.6m-2.6 1.8h2"/></symbol>
|
|
1083
|
+
<symbol id="i-send" viewBox="0 0 24 24" fill="currentColor"><path d="M3.6 11.2 20.4 3.6l-7 16.8-2.2-7z"/></symbol>
|
|
1084
|
+
<symbol id="i-upload" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5"/><path d="M4.5 16v2.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V16"/></symbol>
|
|
1085
|
+
<symbol id="i-refresh" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M20 12a8 8 0 1 1-2.3-5.6"/><path d="M20 4v5h-5"/></symbol>
|
|
1086
|
+
<symbol id="i-help" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><circle cx="12" cy="12" r="8.6"/><path d="M9.6 9.4a2.5 2.5 0 1 1 3.3 2.4c-.6.3-.9.8-.9 1.4v.3"/><circle cx="12" cy="16.6" r=".9" fill="currentColor" stroke="none"/></symbol>
|
|
1087
|
+
<symbol id="i-logout" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M14 8V5.5a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V16"/><path d="M10 12h10m0 0-3.2-3.2M20 12l-3.2 3.2"/></symbol>
|
|
1088
|
+
<symbol id="i-search" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><circle cx="11" cy="11" r="6.4"/><path d="m16 16 4 4"/></symbol>
|
|
1089
|
+
<symbol id="i-x" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"/></symbol>
|
|
1090
|
+
<symbol id="i-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="m4.5 12.5 5 5 10-11"/></symbol>
|
|
1091
|
+
<symbol id="i-left" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="m14.5 5-7 7 7 7"/></symbol>
|
|
1092
|
+
<symbol id="i-right" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="m9.5 5 7 7-7 7"/></symbol>
|
|
1093
|
+
<symbol id="i-bolt" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linejoin="round"><path d="M13 3 5.5 13.5H11L10 21l7.5-10.5H12z"/></symbol>
|
|
1094
|
+
<symbol id="i-flame" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.5c3.2 3.4 6 6.2 6 10a6 6 0 0 1-12 0c0-2 .8-3.6 2-5 .2 1.4.9 2.4 2 2.8.7-2.6.9-5.4 2-7.8z"/></symbol>
|
|
1095
|
+
<symbol id="i-eye" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M2.8 12S6.3 5.8 12 5.8 21.2 12 21.2 12 17.7 18.2 12 18.2 2.8 12 2.8 12z"/><circle cx="12" cy="12" r="2.8"/></symbol>
|
|
1096
|
+
<symbol id="i-eye-off" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M9.9 6.1A9.6 9.6 0 0 1 12 5.8c5.7 0 9.2 6.2 9.2 6.2a15.6 15.6 0 0 1-2.6 3.3M6.4 7.6A15.7 15.7 0 0 0 2.8 12s3.5 6.2 9.2 6.2c1.4 0 2.7-.4 3.8-.9"/><path d="M9.9 9.9a2.8 2.8 0 0 0 4.2 3.7M3.5 3.5l17 17"/></symbol>
|
|
1097
|
+
<symbol id="i-key" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round"><circle cx="8" cy="8" r="3.6"/><path d="m10.6 10.6 8 8m-3-3 2-2m-4-2 2-2"/></symbol>
|
|
1098
|
+
<symbol id="i-copy" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linejoin="round"><rect x="8" y="8" width="11" height="12" rx="2"/><path d="M5.5 15.5v-9a2 2 0 0 1 2-2h9" stroke-linecap="round"/></symbol>
|
|
1099
|
+
</defs></svg>
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
<section id="auth" class="hidden" data-mode="signup">
|
|
1103
|
+
<div class="auth-hero">
|
|
1104
|
+
<a class="auth-brand" href="#" id="auth-brand">
|
|
1105
|
+
<span class="logo-mark"><svg class="ico"><use href="#i-chat"/></svg></span>yap
|
|
1106
|
+
</a>
|
|
1107
|
+
<div class="auth-hero-mid">
|
|
1108
|
+
<h1 class="auth-h1">say it in a<br>snap.</h1>
|
|
1109
|
+
<p class="auth-sub">Post to everyone. Snap your friends. It all clears in 24 hours.</p>
|
|
1110
|
+
<div class="auth-orb" aria-hidden="true"><svg class="ico"><use href="#i-chat"/></svg></div>
|
|
1111
|
+
</div>
|
|
1112
|
+
</div>
|
|
1113
|
+
|
|
1114
|
+
<div class="auth-side">
|
|
1115
|
+
<div class="auth-card">
|
|
1116
|
+
<div class="seg" id="auth-tabs">
|
|
1117
|
+
<button data-auth="signup" class="on">Sign up</button>
|
|
1118
|
+
<button data-auth="login">Log in</button>
|
|
1119
|
+
</div>
|
|
1120
|
+
<h2 class="auth-title" id="auth-title">make an account</h2>
|
|
1121
|
+
<div class="auth-form">
|
|
1122
|
+
<div>
|
|
1123
|
+
<label class="lbl" for="auth-user">Username</label>
|
|
1124
|
+
<input id="auth-user" class="field" autocapitalize="off" autocomplete="username" placeholder="yourname" maxlength="20" autofocus />
|
|
1125
|
+
</div>
|
|
1126
|
+
<div id="auth-name-wrap">
|
|
1127
|
+
<div class="collapse-inner">
|
|
1128
|
+
<label class="lbl" for="auth-name">Display name</label>
|
|
1129
|
+
<input id="auth-name" class="field" autocomplete="name" placeholder="what friends see" maxlength="40" />
|
|
1130
|
+
</div>
|
|
1131
|
+
</div>
|
|
1132
|
+
<div>
|
|
1133
|
+
<label class="lbl" for="auth-pass">Password</label>
|
|
1134
|
+
<div class="pw-wrap">
|
|
1135
|
+
<input id="auth-pass" class="field" type="password" autocomplete="new-password" />
|
|
1136
|
+
<button class="pw-toggle" id="pw-toggle" type="button" aria-label="Show password" aria-pressed="false">
|
|
1137
|
+
<svg class="ico" id="pw-eye"><use href="#i-eye"/></svg>
|
|
1138
|
+
</button>
|
|
1139
|
+
</div>
|
|
1140
|
+
<div class="hint" id="pw-hint" data-ok="false"><span>at least 6 characters</span></div>
|
|
1141
|
+
</div>
|
|
1142
|
+
<p id="auth-err" class="auth-err hidden"></p>
|
|
1143
|
+
<button id="auth-submit" class="btn primary lg" style="width:100%">Create my account</button>
|
|
1144
|
+
<p class="auth-foot">Be nice. Everything is filtered and reports go to a human.</p>
|
|
1145
|
+
</div>
|
|
1146
|
+
</div>
|
|
1147
|
+
</div>
|
|
1148
|
+
</section>
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
<div id="shell" class="shell hidden">
|
|
1152
|
+
<header class="rail">
|
|
1153
|
+
<a class="rail-logo" href="#" id="rail-logo">
|
|
1154
|
+
<span class="logo-mark"><svg class="ico"><use href="#i-chat"/></svg></span><span class="rail-word">yap</span>
|
|
1155
|
+
</a>
|
|
1156
|
+
<nav class="rail-nav" id="rail-nav" aria-label="Sections">
|
|
1157
|
+
<div class="rail-pill" id="rail-pill" aria-hidden="true"></div>
|
|
1158
|
+
<button data-tab="feed" aria-current="page" aria-label="Feed" title="Feed"><svg class="ico"><use href="#i-feed"/></svg><span>Feed</span></button>
|
|
1159
|
+
<button data-tab="camera" aria-label="Camera" title="Camera"><svg class="ico"><use href="#i-cam"/></svg><span>Camera</span></button>
|
|
1160
|
+
<button data-tab="chats" aria-label="Chats" title="Chats"><svg class="ico"><use href="#i-chat"/></svg><span>Chats</span><span class="rail-badge hidden" id="rail-badge"></span></button>
|
|
1161
|
+
<button data-tab="profile" aria-label="Profile" title="You"><svg class="ico"><use href="#i-me"/></svg><span>You</span></button>
|
|
1162
|
+
</nav>
|
|
1163
|
+
<button class="rail-new" id="rail-new" data-ready="false">
|
|
1164
|
+
<svg class="ico"><use href="#i-plus"/></svg><span>Yap</span>
|
|
1165
|
+
</button>
|
|
1166
|
+
<button class="rail-user" id="rail-user" popovertarget="userpop">
|
|
1167
|
+
<div id="rail-avatar" class="avatar sm"></div>
|
|
1168
|
+
<div class="who">
|
|
1169
|
+
<div class="name" id="rail-name">you</div>
|
|
1170
|
+
<div class="handle" id="rail-handle">@you</div>
|
|
1171
|
+
</div>
|
|
1172
|
+
<svg class="ico"><use href="#i-more"/></svg>
|
|
1173
|
+
</button>
|
|
1174
|
+
</header>
|
|
1175
|
+
|
|
1176
|
+
<div class="route">
|
|
1177
|
+
<header class="routebar" id="topbar">
|
|
1178
|
+
<span class="logo-mark route-logo"><svg class="ico"><use href="#i-chat"/></svg></span>
|
|
1179
|
+
<div class="route-text">
|
|
1180
|
+
<h1 class="route-title" id="topbar-title">Feed</h1>
|
|
1181
|
+
<div class="route-sub" id="topbar-sub"></div>
|
|
1182
|
+
</div>
|
|
1183
|
+
<div class="route-actions" id="route-actions"></div>
|
|
1184
|
+
<button class="mob-avatar" id="mob-avatar" popovertarget="userpop" aria-label="Account"><div class="avatar sm" id="mob-av"></div></button>
|
|
1185
|
+
</header>
|
|
1186
|
+
|
|
1187
|
+
<main id="main">
|
|
1188
|
+
<section class="view on" id="v-feed">
|
|
1189
|
+
<div class="feed-wrap">
|
|
1190
|
+
<div class="stories" id="story-rail"></div>
|
|
1191
|
+
<div class="composer" id="composer">
|
|
1192
|
+
<div class="composer-top">
|
|
1193
|
+
<div id="composer-avatar"></div>
|
|
1194
|
+
<textarea id="composer-text" placeholder="what's yapping?" maxlength="1000" rows="1" aria-label="Write a yap"></textarea>
|
|
1195
|
+
</div>
|
|
1196
|
+
<div class="composer-tools">
|
|
1197
|
+
<button class="iconbtn" id="composer-img" title="Add a photo" aria-label="Add a photo" data-tip="Add a photo"><svg class="ico"><use href="#i-image"/></svg></button>
|
|
1198
|
+
<button class="iconbtn" id="composer-gif" title="Memes and GIFs" aria-label="Memes and GIFs" data-tip="Memes and GIFs"><svg class="ico"><use href="#i-gif"/></svg></button>
|
|
1199
|
+
<span class="grow"></span>
|
|
1200
|
+
<svg class="count-ring" id="count-ring" viewBox="0 0 26 26" aria-hidden="true">
|
|
1201
|
+
<circle class="track" cx="13" cy="13" r="11"/>
|
|
1202
|
+
<circle class="val" cx="13" cy="13" r="11" stroke-dasharray="69.1" stroke-dashoffset="69.1"/>
|
|
1203
|
+
</svg>
|
|
1204
|
+
<button class="btn primary sm" id="composer-send" disabled>Yap it</button>
|
|
1205
|
+
</div>
|
|
1206
|
+
<div id="composer-attach" class="attach-note hidden"></div>
|
|
1207
|
+
</div>
|
|
1208
|
+
<div id="feed-list"></div>
|
|
1209
|
+
</div>
|
|
1210
|
+
</section>
|
|
1211
|
+
|
|
1212
|
+
<section class="view" id="v-camera">
|
|
1213
|
+
<div class="cam-route">
|
|
1214
|
+
<div class="cam-stage" id="cam-box" data-review="false">
|
|
1215
|
+
<video id="cam-video" autoplay playsinline muted></video>
|
|
1216
|
+
<img id="cam-shot" class="shot hidden" alt="" />
|
|
1217
|
+
<div class="snap-text-layer" id="cam-text-layer" aria-live="polite"></div>
|
|
1218
|
+
<div class="cam-edit-rail" id="cam-edit-rail" aria-label="Photo edit tools">
|
|
1219
|
+
<button class="cam-tool" id="cam-text-add" type="button" aria-label="Add text" data-tip="T">T</button>
|
|
1220
|
+
<button class="cam-tool small-tool" id="cam-text-style" type="button" aria-label="Toggle text style" data-tip="Style">Aa</button>
|
|
1221
|
+
<div class="cam-text-colors" id="cam-text-colors" aria-label="Text color"></div>
|
|
1222
|
+
<button class="cam-tool small-tool" id="cam-text-plus" type="button" aria-label="Make text bigger">A+</button>
|
|
1223
|
+
<button class="cam-tool small-tool" id="cam-text-minus" type="button" aria-label="Make text smaller">A−</button>
|
|
1224
|
+
</div>
|
|
1225
|
+
<div class="cap" id="cam-cap"></div>
|
|
1226
|
+
<div class="cam-flash" id="cam-flash"></div>
|
|
1227
|
+
<div class="drop-hint" id="drop-hint">drop it in</div>
|
|
1228
|
+
<div class="cam-noSrc hidden" id="cam-empty">
|
|
1229
|
+
<div>
|
|
1230
|
+
<div class="obj">
|
|
1231
|
+
<svg viewBox="0 0 120 120" fill="none">
|
|
1232
|
+
<defs><linearGradient id="camg" x1="20" y1="24" x2="100" y2="104" gradientUnits="userSpaceOnUse">
|
|
1233
|
+
<stop stop-color="#7fa4ff"/><stop offset=".5" stop-color="#2f6bff"/><stop offset="1" stop-color="#173da8"/>
|
|
1234
|
+
</linearGradient></defs>
|
|
1235
|
+
<ellipse cx="60" cy="110" rx="34" ry="6" fill="#2f6bff" opacity=".22"/>
|
|
1236
|
+
<rect x="16" y="32" width="88" height="62" rx="16" fill="url(#camg)"/>
|
|
1237
|
+
<path d="M44 32l5-8h22l5 8" fill="url(#camg)"/>
|
|
1238
|
+
<circle cx="60" cy="63" r="19" fill="#05070d" opacity=".55"/>
|
|
1239
|
+
<circle cx="60" cy="63" r="13" fill="#a8c2ff" opacity=".38"/>
|
|
1240
|
+
<ellipse cx="38" cy="44" rx="14" ry="8" fill="#fff" opacity=".3"/>
|
|
1241
|
+
</svg>
|
|
1242
|
+
</div>
|
|
1243
|
+
<h3 id="cam-empty-title">camera's blocked</h3>
|
|
1244
|
+
<p id="cam-empty-copy">Your browser is holding the lens back. Allow camera access in the address bar, or drop a photo in instead.</p>
|
|
1245
|
+
<div class="row" style="display:flex;gap:8px;justify-content:center;flex-wrap:wrap">
|
|
1246
|
+
<button class="btn primary" id="cam-empty-upload">Upload a photo</button>
|
|
1247
|
+
<button class="btn ghost" id="cam-empty-retry">Try camera again</button>
|
|
1248
|
+
</div>
|
|
1249
|
+
<details>
|
|
1250
|
+
<summary>details</summary>
|
|
1251
|
+
<pre id="cam-empty-detail">NotAllowedError</pre>
|
|
1252
|
+
</details>
|
|
1253
|
+
</div>
|
|
1254
|
+
</div>
|
|
1255
|
+
<div class="cam-bar">
|
|
1256
|
+
<div class="cam-side">
|
|
1257
|
+
<button class="btn ghost sm" id="cam-file">Upload</button>
|
|
1258
|
+
</div>
|
|
1259
|
+
<button class="shutter" id="shutter" aria-label="Take a photo" data-tip="space"></button>
|
|
1260
|
+
<div class="cam-actions">
|
|
1261
|
+
<button class="btn ghost sm" id="cam-retake">Retake</button>
|
|
1262
|
+
<div class="cam-send-group">
|
|
1263
|
+
<button class="btn ghost sm" id="cam-send" disabled>Send to…</button>
|
|
1264
|
+
<button class="btn primary cam-story-btn" id="cam-story" disabled>Add to story</button>
|
|
1265
|
+
</div>
|
|
1266
|
+
</div>
|
|
1267
|
+
</div>
|
|
1268
|
+
</div>
|
|
1269
|
+
<input id="cam-fileinput" type="file" accept="image/*" class="hidden" />
|
|
1270
|
+
<input id="cap-input" class="field cam-cap-row hidden" placeholder="add a caption" maxlength="120" aria-label="Caption" />
|
|
1271
|
+
<div class="filters-strip" id="filter-row"></div>
|
|
1272
|
+
</div>
|
|
1273
|
+
</section>
|
|
1274
|
+
|
|
1275
|
+
<div id="chats-split">
|
|
1276
|
+
<section class="view" id="v-chats">
|
|
1277
|
+
<div class="list-pane">
|
|
1278
|
+
<div class="chat-search">
|
|
1279
|
+
<input id="people-search" class="field" placeholder="Find someone on yap" aria-label="Search people" />
|
|
1280
|
+
</div>
|
|
1281
|
+
<div id="people-results"></div>
|
|
1282
|
+
<div class="chat-scroll" id="inbox-list"></div>
|
|
1283
|
+
</div>
|
|
1284
|
+
</section>
|
|
1285
|
+
|
|
1286
|
+
<section class="view" id="v-thread">
|
|
1287
|
+
<div class="thread-pane">
|
|
1288
|
+
<div class="thread-head">
|
|
1289
|
+
<button class="iconbtn" id="thread-back" aria-label="Back" data-tip="Back">
|
|
1290
|
+
<svg class="ico"><use href="#i-left"/></svg>
|
|
1291
|
+
</button>
|
|
1292
|
+
<div id="thread-head" class="who row" style="display:flex;align-items:center;gap:10px"></div>
|
|
1293
|
+
<div id="thread-streak" class="streak"></div>
|
|
1294
|
+
</div>
|
|
1295
|
+
<div id="thread-list"></div>
|
|
1296
|
+
<div class="threadbar" id="threadbar">
|
|
1297
|
+
<button class="iconbtn photo-btn" id="thread-cam" title="Photo yap" aria-label="Photo yap" data-tip="Photo yap">
|
|
1298
|
+
<svg class="ico"><use href="#i-cam"/></svg>
|
|
1299
|
+
</button>
|
|
1300
|
+
<textarea id="thread-input" class="field" placeholder="Send a yap…" maxlength="500" rows="1" aria-label="Message"></textarea>
|
|
1301
|
+
<button class="send" id="thread-send" aria-label="Send" data-empty="true">
|
|
1302
|
+
<svg class="ico"><use href="#i-send"/></svg>
|
|
1303
|
+
</button>
|
|
1304
|
+
</div>
|
|
1305
|
+
</div>
|
|
1306
|
+
</section>
|
|
1307
|
+
</div>
|
|
1308
|
+
|
|
1309
|
+
<section class="view" id="v-profile">
|
|
1310
|
+
<div class="profile-wrap">
|
|
1311
|
+
<div id="prof-banner" class="banner"></div>
|
|
1312
|
+
<div class="prof-head">
|
|
1313
|
+
<div id="prof-avatar" class="avatar lg" data-frame="none">?</div>
|
|
1314
|
+
<div class="prof-ident" id="prof-ident" data-plate="false">
|
|
1315
|
+
<div class="plate-layer" id="prof-plate" hidden></div>
|
|
1316
|
+
<h2 class="prof-name" id="prof-name"></h2>
|
|
1317
|
+
<div class="prof-handle-row">
|
|
1318
|
+
<span class="prof-handle" id="prof-handle"></span>
|
|
1319
|
+
<span class="pill" id="prof-joined"></span>
|
|
1320
|
+
</div>
|
|
1321
|
+
</div>
|
|
1322
|
+
<button class="btn ghost" id="prof-edit">Edit profile</button>
|
|
1323
|
+
</div>
|
|
1324
|
+
<p class="prof-bio" id="prof-bio"></p>
|
|
1325
|
+
<div class="prof-badges" id="prof-badges"></div>
|
|
1326
|
+
<div class="prof-stats">
|
|
1327
|
+
<div class="stat"><span class="num" id="prof-posts">0</span><span class="cap">posts</span></div>
|
|
1328
|
+
<div class="stat"><span class="num" id="prof-stories">0</span><span class="cap">live stories</span></div>
|
|
1329
|
+
</div>
|
|
1330
|
+
<div class="prof-section">
|
|
1331
|
+
<div class="section-head"><h3>Your yaps</h3></div>
|
|
1332
|
+
<div id="prof-post-list"></div>
|
|
1333
|
+
</div>
|
|
1334
|
+
<div class="prof-section">
|
|
1335
|
+
<button class="btn quiet sm" id="prof-logout">Log out</button>
|
|
1336
|
+
</div>
|
|
1337
|
+
</div>
|
|
1338
|
+
</section>
|
|
1339
|
+
|
|
1340
|
+
<section class="view" id="v-admin">
|
|
1341
|
+
<div class="admin-wrap">
|
|
1342
|
+
<h2 class="page-title">Admin</h2>
|
|
1343
|
+
<div class="admin-tabs" id="admin-tabs">
|
|
1344
|
+
<button data-atab="overview" class="on">Overview</button>
|
|
1345
|
+
<button data-atab="reports">Reports</button>
|
|
1346
|
+
<button data-atab="users">Users</button>
|
|
1347
|
+
<button data-atab="posts">Posts</button>
|
|
1348
|
+
<button data-atab="filter">Filter</button>
|
|
1349
|
+
<button data-atab="support">Support</button>
|
|
1350
|
+
</div>
|
|
1351
|
+
<div id="admin-body"></div>
|
|
1352
|
+
<div style="margin-top:24px"><button class="btn ghost sm" id="admin-back">Back to profile</button></div>
|
|
1353
|
+
</div>
|
|
1354
|
+
</section>
|
|
1355
|
+
</main>
|
|
1356
|
+
</div>
|
|
1357
|
+
|
|
1358
|
+
<aside class="context" id="context">
|
|
1359
|
+
<div id="ctx-chats"></div>
|
|
1360
|
+
<div id="ctx-stories"></div>
|
|
1361
|
+
</aside>
|
|
1362
|
+
</div>
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
<nav class="tabbar hidden" id="tabbar" aria-label="Sections">
|
|
1366
|
+
<button data-tab="feed" aria-current="page" aria-label="Feed"><svg class="ico"><use href="#i-feed"/></svg><span>Feed</span></button>
|
|
1367
|
+
<button data-tab="chats" aria-label="Chats"><svg class="ico"><use href="#i-chat"/></svg><span>Chats</span><span class="tab-badge hidden" id="tab-badge"></span></button>
|
|
1368
|
+
<button class="tab-cam" data-tab="camera" aria-label="Camera"><svg class="ico"><use href="#i-cam"/></svg></button>
|
|
1369
|
+
<button class="tab-new" id="tab-new" aria-label="New yap"><svg class="ico"><use href="#i-plus"/></svg><span>New</span></button>
|
|
1370
|
+
<button data-tab="profile" aria-label="Profile"><svg class="ico"><use href="#i-me"/></svg><span>You</span></button>
|
|
1371
|
+
</nav>
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
<div id="userpop" popover class="userpop">
|
|
1375
|
+
<div class="userpop-head" id="userpop-head" data-plate="false">
|
|
1376
|
+
<div class="plate-layer" id="pop-plate" hidden></div>
|
|
1377
|
+
<div id="pop-avatar" class="avatar"></div>
|
|
1378
|
+
<div>
|
|
1379
|
+
<div class="name" id="pop-name">you</div>
|
|
1380
|
+
<div class="handle" id="pop-handle">@you</div>
|
|
1381
|
+
</div>
|
|
1382
|
+
</div>
|
|
1383
|
+
<button class="userpop-item hidden" id="pop-admin"><svg class="ico"><use href="#i-bolt"/></svg>Admin</button>
|
|
1384
|
+
<button class="userpop-item" id="top-support"><svg class="ico"><use href="#i-help"/></svg>Help</button>
|
|
1385
|
+
<button class="userpop-item" id="top-refresh"><svg class="ico"><use href="#i-refresh"/></svg>Refresh</button>
|
|
1386
|
+
<button class="userpop-item" data-rose="true" id="pop-logout"><svg class="ico"><use href="#i-logout"/></svg>Log out</button>
|
|
1387
|
+
</div>
|
|
1388
|
+
|
|
1389
|
+
<div class="drawer-scrim" id="drawer-scrim"></div>
|
|
1390
|
+
<aside class="drawer" id="edit-drawer" data-open="false" aria-label="Edit profile">
|
|
1391
|
+
<div class="drawer-head">
|
|
1392
|
+
<h3>Edit profile</h3>
|
|
1393
|
+
<button class="iconbtn" id="drawer-close" aria-label="Close"><svg class="ico"><use href="#i-x"/></svg></button>
|
|
1394
|
+
</div>
|
|
1395
|
+
<div class="drawer-body">
|
|
1396
|
+
<div>
|
|
1397
|
+
<label class="lbl" for="pf-name">Display name</label>
|
|
1398
|
+
<input id="pf-name" class="field" maxlength="40" />
|
|
1399
|
+
</div>
|
|
1400
|
+
<div>
|
|
1401
|
+
<label class="lbl" for="pf-bio">Bio</label>
|
|
1402
|
+
<textarea id="pf-bio" class="field" maxlength="160" style="min-height:88px"></textarea>
|
|
1403
|
+
</div>
|
|
1404
|
+
<div>
|
|
1405
|
+
<span class="lbl">Profile picture</span>
|
|
1406
|
+
<div class="uploadrow">
|
|
1407
|
+
<div class="avatar" id="pf-avatar-thumb"></div>
|
|
1408
|
+
<div class="uploadcopy">
|
|
1409
|
+
<div class="row">
|
|
1410
|
+
<button class="btn ghost sm" id="pf-avatar-btn" type="button">Choose image</button>
|
|
1411
|
+
<button class="btn quiet sm hidden" id="pf-avatar-clear" type="button">Clear selection</button>
|
|
1412
|
+
</div>
|
|
1413
|
+
<p class="hint">JPEG, PNG, WebP or GIF · animated welcome · up to 5MB</p>
|
|
1414
|
+
</div>
|
|
1415
|
+
</div>
|
|
1416
|
+
<input id="pf-avatar-input" type="file" accept="image/jpeg,image/png,image/webp,image/gif" class="hidden" />
|
|
1417
|
+
</div>
|
|
1418
|
+
<div>
|
|
1419
|
+
<span class="lbl">Banner image</span>
|
|
1420
|
+
<div class="uploadrow">
|
|
1421
|
+
<div class="uploadcopy">
|
|
1422
|
+
<div class="row">
|
|
1423
|
+
<button class="btn ghost sm" id="pf-banner-img-btn" type="button">Choose image</button>
|
|
1424
|
+
<button class="btn quiet sm hidden" id="pf-banner-img-clear" type="button">Remove image</button>
|
|
1425
|
+
</div>
|
|
1426
|
+
<p class="hint" id="pf-banner-img-note">Overrides the banner color · JPEG, PNG, WebP or GIF · up to 5MB</p>
|
|
1427
|
+
</div>
|
|
1428
|
+
</div>
|
|
1429
|
+
<input id="pf-banner-img-input" type="file" accept="image/jpeg,image/png,image/webp,image/gif" class="hidden" />
|
|
1430
|
+
</div>
|
|
1431
|
+
<div>
|
|
1432
|
+
<span class="lbl">Banner</span>
|
|
1433
|
+
<div class="bannersel" id="pf-banner-pick">
|
|
1434
|
+
<button data-banner="midnight" class="swatch-midnight" aria-label="Midnight" aria-pressed="false"></button>
|
|
1435
|
+
<button data-banner="aurora" class="swatch-aurora" aria-label="Aurora" aria-pressed="false"></button>
|
|
1436
|
+
<button data-banner="sunset" class="swatch-sunset" aria-label="Sunset" aria-pressed="false"></button>
|
|
1437
|
+
<button data-banner="royal" class="swatch-royal" aria-label="Royal" aria-pressed="false"></button>
|
|
1438
|
+
<button data-banner="carbon" class="swatch-carbon" aria-label="Carbon" aria-pressed="false"></button>
|
|
1439
|
+
</div>
|
|
1440
|
+
</div>
|
|
1441
|
+
<div>
|
|
1442
|
+
<span class="lbl">Avatar frame</span>
|
|
1443
|
+
<div class="seg" id="pf-frame-pick" style="max-width:320px">
|
|
1444
|
+
<button data-frame="none" class="on">None</button>
|
|
1445
|
+
<button data-frame="ring">Ring</button>
|
|
1446
|
+
<button data-frame="verified">Ice</button>
|
|
1447
|
+
</div>
|
|
1448
|
+
</div>
|
|
1449
|
+
<div>
|
|
1450
|
+
<span class="lbl">Avatar decoration</span>
|
|
1451
|
+
<div class="cosmetic-grid" id="pf-decor-pick"></div>
|
|
1452
|
+
</div>
|
|
1453
|
+
<div>
|
|
1454
|
+
<span class="lbl">Nameplate</span>
|
|
1455
|
+
<div class="cosmetic-grid plates" id="pf-plate-pick"></div>
|
|
1456
|
+
</div>
|
|
1457
|
+
<div>
|
|
1458
|
+
<span class="lbl">Live preview</span>
|
|
1459
|
+
<div class="prof-preview" id="pf-preview"></div>
|
|
1460
|
+
</div>
|
|
1461
|
+
</div>
|
|
1462
|
+
<div class="drawer-foot">
|
|
1463
|
+
<button class="btn ghost" id="pf-discard" hidden>Discard</button>
|
|
1464
|
+
<button class="btn primary" id="pf-save" disabled>Save profile</button>
|
|
1465
|
+
</div>
|
|
1466
|
+
</aside>
|
|
1467
|
+
<div class="overlay" id="sheet"><div class="sheet" id="sheet-body"></div></div>
|
|
1468
|
+
<div class="storyview" id="storyview"></div>
|
|
1469
|
+
<div id="ctxmenu" class="ctxmenu hidden" role="menu" aria-label="Context menu"></div>
|
|
1470
|
+
<div id="toasts" role="status" aria-live="polite"></div>
|
|
1471
|
+
|
|
1472
|
+
<dialog id="lightbox" class="lightbox" aria-label="Photo">
|
|
1473
|
+
<div class="lightbox-body">
|
|
1474
|
+
|
|
1475
|
+
<img id="lightbox-img" alt="" />
|
|
1476
|
+
</div>
|
|
1477
|
+
<button class="lightbox-close" id="lightbox-close" aria-label="Close"><svg class="ico"><use href="#i-x"/></svg></button>
|
|
1478
|
+
<button class="lightbox-nav" data-dir="prev" id="lightbox-prev" aria-label="Previous"><svg class="ico"><use href="#i-left"/></svg></button>
|
|
1479
|
+
<button class="lightbox-nav" data-dir="next" id="lightbox-next" aria-label="Next"><svg class="ico"><use href="#i-right"/></svg></button>
|
|
1480
|
+
</dialog>
|
|
1481
|
+
|
|
1482
|
+
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
|
|
1483
|
+
<script>
|
|
1484
|
+
|
|
1485
|
+
/* =======================================================================
|
|
1486
|
+
CORE — config, helpers, state, toast, routing
|
|
1487
|
+
======================================================================= */
|
|
1488
|
+
const CONFIG = JSON.parse(atob("eyJzdXBhYmFzZVVybCI6Imh0dHBzOi8vdnphb2ViYXVpZmFmbmZmYmZpeG8uc3VwYWJhc2UuY28iLCJzdXBhYmFzZUFub25LZXkiOiJleUpoYkdjaU9pSklVekkxTmlJc0luUjVjQ0k2SWtwWFZDSjkuZXlKcGMzTWlPaUp6ZFhCaFltRnpaU0lzSW5KbFppSTZJblo2WVc5bFltRjFhV1poWm01bVptSm1hWGh2SWl3aWNtOXNaU0k2SW1GdWIyNGlMQ0pwWVhRaU9qRTNPVEkzT1Rjd05EY3NJbVY0Y0NJNk1qRXdPRE0zTXpBME4zMC45UFlFZjVPQ3lEckR2LVhSTzJ2OGM4SThwVDN0UDEydFVDQlZ3a3NoU0dZIiwibWVkaWFCdWNrZXQiOiJ5YXAtbWVkaWEiLCJrbGlweUtleSI6Ik9rY1ZxQnVaaVVIdTZqQU9XSUtXWkNMVXRzZkFQb3FsekRIdXpQQkVCV3ZSTHI3TnNLUVd4bm9mZEpOYmF4bjEifQ=="));
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
const SHOP = {"decorations":[{"id":"astronaut_helmet","name":"Astronaut Helmet","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/astronaut_helmet.webp","animated":true},{"id":"ufo","name":"Ufo","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/ufo.webp","animated":true},{"id":"pink_gyroscope","name":"Pink Gyroscope","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/pink_gyroscope.webp","animated":true},{"id":"radiating_energy","name":"Radiating Energy","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/radiating_energy.webp","animated":true},{"id":"arcane_sigil","name":"Arcane Sigil","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/arcane_sigil.webp","animated":true},{"id":"wizard_hat_blue","name":"Wizard Hat Blue","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/wizard_hat_blue.webp","animated":true},{"id":"midnight_sorceress","name":"Midnight Sorceress","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/midnight_sorceress.webp","animated":true},{"id":"dancing_fairies","name":"Dancing Fairies","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/dancing_fairies.webp","animated":true},{"id":"crystal_elk","name":"Crystal Elk","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/crystal_elk.webp","animated":true},{"id":"unicorn","name":"Unicorn","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/unicorn.webp","animated":true},{"id":"phoenix","name":"Phoenix","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/phoenix.webp","animated":true},{"id":"treat_ghost","name":"Treat Ghost","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/treat_ghost.webp","animated":true},{"id":"malefic_crown","name":"Malefic Crown","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/malefic_crown.webp","animated":true},{"id":"devil","name":"Devil","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/devil.webp","animated":true},{"id":"cyber_katana","name":"Cyber Katana","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/cyber_katana.webp","animated":true},{"id":"spooky_cat_ears","name":"Spooky Cat Ears","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/spooky_cat_ears.webp","animated":true},{"id":"neon_spike_choker","name":"Neon Spike Choker","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/neon_spike_choker.webp","animated":true},{"id":"bonsai","name":"Bonsai","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/bonsai.webp","animated":true},{"id":"butterflies","name":"Butterflies","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/butterflies.webp","animated":true},{"id":"happy_harvest","name":"Happy Harvest","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/happy_harvest.webp","animated":true},{"id":"touch_grass","name":"Touch Grass","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/touch_grass.webp","animated":true},{"id":"luminescent_lotus","name":"Luminescent Lotus","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/luminescent_lotus.webp","animated":true},{"id":"sakura_scholar","name":"Sakura Scholar","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/sakura_scholar.webp","animated":true},{"id":"beach_hat","name":"Beach Hat","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/beach_hat.webp","animated":true},{"id":"baker_bear","name":"Baker Bear","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/baker_bear.webp","animated":true},{"id":"bread_doggy","name":"Bread Doggy","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/bread_doggy.webp","animated":true},{"id":"berry_bunny","name":"Berry Bunny","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/berry_bunny.webp","animated":true},{"id":"owlbear_cub","name":"Owlbear Cub","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/owlbear_cub.webp","animated":true},{"id":"frog_derpy","name":"Frog Derpy","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/frog_derpy.webp","animated":true},{"id":"morning_coffee","name":"Morning Coffee","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/morning_coffee.webp","animated":true},{"id":"lovestruck","name":"Lovestruck","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/lovestruck.webp","animated":true},{"id":"snowglobe","name":"Snowglobe","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/snowglobe.webp","animated":true},{"id":"gold_laurel_wreath","name":"Gold Laurel Wreath","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/gold_laurel_wreath.webp","animated":true},{"id":"cozy_headphones","name":"Cozy Headphones","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/cozy_headphones.webp","animated":true},{"id":"gone_fishin","name":"Gone Fishin","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/gone_fishin.webp","animated":true},{"id":"glop","name":"Glop","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/decorations/glop.webp","animated":true}],"nameplates":[{"id":"angels","name":"Angels","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/angels.webm"},{"id":"aurora","name":"Aurora","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/aurora.webm"},{"id":"autumn_breeze","name":"Autumn Breeze","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/autumn_breeze.webm"},{"id":"bonsai","name":"Bonsai","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/bonsai.webm"},{"id":"busy_bee","name":"Busy Bee","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/busy_bee.webm"},{"id":"cat_beans","name":"Cat Beans","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/cat_beans.webm"},{"id":"cherry_blossoms","name":"Cherry Blossoms","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/cherry_blossoms.webm"},{"id":"cityscape","name":"Cityscape","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/cityscape.webm"},{"id":"cosmic_guardian","name":"Cosmic Guardian","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/cosmic_guardian.webm"},{"id":"d20_roll","name":"D20 Roll","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/d20_roll.webm"},{"id":"dark_roses","name":"Dark Roses","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/dark_roses.webm"},{"id":"elysian_tides","name":"Elysian Tides","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/elysian_tides.webm"},{"id":"fairies","name":"Fairies","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/fairies.webm"},{"id":"firefly_meadow","name":"Firefly Meadow","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/firefly_meadow.webm"},{"id":"glitch","name":"Glitch","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/glitch.webm"},{"id":"gothic_arches","name":"Gothic Arches","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/gothic_arches.webm"},{"id":"hyperspace","name":"Hyperspace","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/hyperspace.webm"},{"id":"koi_pond","name":"Koi Pond","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/koi_pond.webm"},{"id":"luna_moth","name":"Luna Moth","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/luna_moth.webm"},{"id":"magic_mists","name":"Magic Mists","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/magic_mists.webm"},{"id":"pixi_dust","name":"Pixi Dust","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/pixi_dust.webm"},{"id":"red_dragon","name":"Red Dragon","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/red_dragon.webm"},{"id":"starlight_whales","name":"Starlight Whales","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/starlight_whales.webm"},{"id":"under_the_sea","name":"Under The Sea","url":"https://vzaoebauifafnffbfixo.supabase.co/storage/v1/object/public/yap-media/shop/nameplates/under_the_sea.webm"}]};
|
|
1492
|
+
|
|
1493
|
+
const $ = (sel, root = document) => root.querySelector(sel);
|
|
1494
|
+
const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));
|
|
1495
|
+
const esc = (v) => String(v ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
|
1496
|
+
const TOKEN_KEY = "yap_token";
|
|
1497
|
+
const sb = window.supabase.createClient(CONFIG.supabaseUrl, CONFIG.supabaseAnonKey);
|
|
1498
|
+
const REDUCED = () => matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1499
|
+
const EASE = "cubic-bezier(.22,1,.36,1)";
|
|
1500
|
+
|
|
1501
|
+
async function api(fn, args = {}) {
|
|
1502
|
+
const { data, error } = await sb.rpc(fn, args);
|
|
1503
|
+
if (error) throw new Error(error.message || "Request failed");
|
|
1504
|
+
return data;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
const state = {
|
|
1508
|
+
me: null, token: null, view: "feed", feed: [], inbox: [], stories: [],
|
|
1509
|
+
peer: null, thread: null, admin: null, atab: "overview",
|
|
1510
|
+
filter: "none", shot: null, shotBlob: null, attach: null, gifUrl: null,
|
|
1511
|
+
storyList: [], storyIdx: 0, storyTimer: 0, camStream: null, camError: null,
|
|
1512
|
+
camReview: false, dirty: false, pickedBanner: null, pickedFrame: null,
|
|
1513
|
+
pickedDecor: undefined, pickedPlate: undefined,
|
|
1514
|
+
avatarFile: null, avatarPreview: null, bannerFile: null, bannerPreview: null, bannerImgCleared: false,
|
|
1515
|
+
lightbox: { list: [], idx: 0 }, hasShotOnce: false,
|
|
1516
|
+
camTexts: [], activeTextId: null,
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
/* ---------------------------------------------------------------- toast */
|
|
1520
|
+
const TOAST_MS = 3500;
|
|
1521
|
+
const toastLive = new Map();
|
|
1522
|
+
const toastOrder = [];
|
|
1523
|
+
|
|
1524
|
+
function toast(msg, tone = "") {
|
|
1525
|
+
const key = tone + "|" + msg;
|
|
1526
|
+
const region = $("#toasts");
|
|
1527
|
+
const seen = toastLive.get(key);
|
|
1528
|
+
if (seen) {
|
|
1529
|
+
seen.n += 1;
|
|
1530
|
+
seen.el.querySelector(".count").textContent = "×" + seen.n;
|
|
1531
|
+
seen.el.querySelector(".count").hidden = false;
|
|
1532
|
+
restartToast(seen);
|
|
1533
|
+
return seen.el;
|
|
1534
|
+
}
|
|
1535
|
+
const el = document.createElement("div");
|
|
1536
|
+
el.className = "toast";
|
|
1537
|
+
el.dataset.key = key;
|
|
1538
|
+
if (tone) el.dataset.tone = tone;
|
|
1539
|
+
el.innerHTML =
|
|
1540
|
+
(tone === "ok" ? '<svg class="ico"><use href="#i-check"/></svg>'
|
|
1541
|
+
: tone === "err" ? '<svg class="ico"><use href="#i-x"/></svg>' : "") +
|
|
1542
|
+
`<span class="msg"></span><span class="count" hidden></span><span class="bar"></span>`;
|
|
1543
|
+
el.querySelector(".msg").textContent = msg;
|
|
1544
|
+
region.appendChild(el);
|
|
1545
|
+
const entry = { el, n: 1, left: TOAST_MS, started: performance.now(), timer: 0, paused: false };
|
|
1546
|
+
toastLive.set(key, entry);
|
|
1547
|
+
toastOrder.push(key);
|
|
1548
|
+
while (toastOrder.length > 3) {
|
|
1549
|
+
const oldest = toastOrder.shift();
|
|
1550
|
+
const dead = toastLive.get(oldest);
|
|
1551
|
+
if (dead) { dead.el.remove(); toastLive.delete(oldest); }
|
|
1552
|
+
}
|
|
1553
|
+
el.addEventListener("mouseenter", () => {
|
|
1554
|
+
entry.paused = true;
|
|
1555
|
+
entry.left -= performance.now() - entry.started;
|
|
1556
|
+
clearTimeout(entry.timer);
|
|
1557
|
+
el.querySelector(".bar").style.animationPlayState = "paused";
|
|
1558
|
+
});
|
|
1559
|
+
el.addEventListener("mouseleave", () => {
|
|
1560
|
+
entry.paused = false;
|
|
1561
|
+
el.querySelector(".bar").style.animationPlayState = "running";
|
|
1562
|
+
restartToast(entry);
|
|
1563
|
+
});
|
|
1564
|
+
restartToast(entry);
|
|
1565
|
+
return el;
|
|
1566
|
+
}
|
|
1567
|
+
function restartToast(entry) {
|
|
1568
|
+
clearTimeout(entry.timer);
|
|
1569
|
+
entry.started = performance.now();
|
|
1570
|
+
entry.el.querySelector(".bar").style.animation = "none";
|
|
1571
|
+
void entry.el.offsetWidth;
|
|
1572
|
+
entry.el.querySelector(".bar").style.animation = "";
|
|
1573
|
+
entry.timer = setTimeout(() => {
|
|
1574
|
+
entry.el.style.transition = "opacity .2s, transform .2s";
|
|
1575
|
+
entry.el.style.opacity = "0";
|
|
1576
|
+
entry.el.style.transform = "translateY(8px)";
|
|
1577
|
+
setTimeout(() => {
|
|
1578
|
+
entry.el.remove();
|
|
1579
|
+
const k = entry.el.dataset.key;
|
|
1580
|
+
if (toastLive.get(k) === entry) toastLive.delete(k);
|
|
1581
|
+
const i = toastOrder.indexOf(k);
|
|
1582
|
+
if (i >= 0) toastOrder.splice(i, 1);
|
|
1583
|
+
}, 220);
|
|
1584
|
+
}, Math.max(400, entry.left));
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
/* -------------------------------------------------------------- helpers */
|
|
1588
|
+
const fmtTime = (iso) => {
|
|
1589
|
+
const d = new Date(iso), diff = (Date.now() - d.getTime()) / 1000;
|
|
1590
|
+
if (diff < 60) return "now";
|
|
1591
|
+
if (diff < 3600) return Math.floor(diff / 60) + "m";
|
|
1592
|
+
if (diff < 86400) return Math.floor(diff / 3600) + "h";
|
|
1593
|
+
if (diff < 604800) return Math.floor(diff / 86400) + "d";
|
|
1594
|
+
return d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
|
1595
|
+
};
|
|
1596
|
+
const dayKey = (iso) => new Date(iso).toDateString();
|
|
1597
|
+
const dayLabel = (iso) => {
|
|
1598
|
+
const d = new Date(iso), now = new Date();
|
|
1599
|
+
if (d.toDateString() === now.toDateString()) return "today";
|
|
1600
|
+
const y = new Date(now); y.setDate(now.getDate() - 1);
|
|
1601
|
+
if (d.toDateString() === y.toDateString()) return "yesterday";
|
|
1602
|
+
return d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
|
1603
|
+
};
|
|
1604
|
+
const initials = (name) => (name || "?").trim().replace(/^@/, "").slice(0, 2).toUpperCase();
|
|
1605
|
+
const TONES = [
|
|
1606
|
+
{ bg: "#173DA8", fg: "#ffffff" },
|
|
1607
|
+
{ bg: "#1D4FD7", fg: "#ffffff" },
|
|
1608
|
+
{ bg: "#2F6BFF", fg: "#ffffff" },
|
|
1609
|
+
{ bg: "#4E86FF", fg: "#041231" },
|
|
1610
|
+
{ bg: "#3CC8FF", fg: "#06213A" },
|
|
1611
|
+
{ bg: "#5C8DFF", fg: "#041231" },
|
|
1612
|
+
{ bg: "#9DB9FF", fg: "#061A3A" },
|
|
1613
|
+
];
|
|
1614
|
+
const toneIdx = (seed) => {
|
|
1615
|
+
let h = 0;
|
|
1616
|
+
for (const ch of String(seed || "?")) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
|
|
1617
|
+
return h % TONES.length;
|
|
1618
|
+
};
|
|
1619
|
+
const toneFor = (seed) => TONES[toneIdx(seed)].bg;
|
|
1620
|
+
const toneFg = (seed) => TONES[toneIdx(seed)].fg;
|
|
1621
|
+
const decorItem = (id) => SHOP.decorations.find((d) => d.id === id) || null;
|
|
1622
|
+
const plateItem = (id) => SHOP.nameplates.find((p) => p.id === id) || null;
|
|
1623
|
+
function decorImg(decoration, force = false) {
|
|
1624
|
+
const item = decorItem(decoration?.decor);
|
|
1625
|
+
/* Reduced-motion compromise: decoration images are omitted outside the
|
|
1626
|
+
profile page rather than attempting to freeze animated WebP frames. */
|
|
1627
|
+
if (!item || (REDUCED() && !force)) return "";
|
|
1628
|
+
return `<img class="avdecor" src="${esc(item.url)}" alt="" aria-hidden="true" loading="lazy" onerror="this.remove()" />`;
|
|
1629
|
+
}
|
|
1630
|
+
function plateVideoHtml(id) {
|
|
1631
|
+
const item = plateItem(id);
|
|
1632
|
+
if (!item) return "";
|
|
1633
|
+
const auto = REDUCED() ? "" : " autoplay";
|
|
1634
|
+
return `<video src="${esc(item.url)}"${auto} loop muted playsinline preload="metadata" disablepictureinpicture aria-hidden="true"></video>`;
|
|
1635
|
+
}
|
|
1636
|
+
function setPlateLayer(layer, host, decoration) {
|
|
1637
|
+
if (!layer) return;
|
|
1638
|
+
const html = plateVideoHtml(decoration?.plate);
|
|
1639
|
+
layer.innerHTML = html;
|
|
1640
|
+
layer.hidden = !html;
|
|
1641
|
+
if (host) host.dataset.plate = String(!!html);
|
|
1642
|
+
}
|
|
1643
|
+
const avatarHtml = (who, cls = "", forceDecor = false) => {
|
|
1644
|
+
who = who || { username: "?" };
|
|
1645
|
+
const frame = (who.decoration && who.decoration.frame) || "none";
|
|
1646
|
+
const inner = (who.avatar_url
|
|
1647
|
+
? `<img src="${esc(who.avatar_url)}" alt="" loading="lazy" onerror="this.remove()" />`
|
|
1648
|
+
: esc(initials(who.display_name || who.username))) + decorImg(who.decoration, forceDecor);
|
|
1649
|
+
return `<div class="avatar ${cls}${who.is_support ? " support" : ""}" data-frame="${esc(frame)}" style="--av:${toneFor(who.username)};--av-fg:${toneFg(who.username)}">${inner}</div>`;
|
|
1650
|
+
};
|
|
1651
|
+
const countUp = (el, to) => {
|
|
1652
|
+
const from = Number(el.textContent) || 0;
|
|
1653
|
+
if (from === to || REDUCED()) { el.textContent = to; return; }
|
|
1654
|
+
const t0 = performance.now();
|
|
1655
|
+
const step = (t) => {
|
|
1656
|
+
const p = Math.min(1, (t - t0) / 520);
|
|
1657
|
+
el.textContent = Math.round(from + (to - from) * (1 - Math.pow(1 - p, 3)));
|
|
1658
|
+
if (p < 1) requestAnimationFrame(step);
|
|
1659
|
+
};
|
|
1660
|
+
requestAnimationFrame(step);
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
/* ------------------------------------------------------------- routing */
|
|
1664
|
+
const ROUTES = {
|
|
1665
|
+
feed: { title: "Feed", ctx: true },
|
|
1666
|
+
camera: { title: "Camera", ctx: false },
|
|
1667
|
+
chats: { title: "Chats", ctx: false },
|
|
1668
|
+
thread: { title: "Chats", ctx: false },
|
|
1669
|
+
profile: { title: "You", ctx: true },
|
|
1670
|
+
admin: { title: "Admin", ctx: false },
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
function moveRailPill() {
|
|
1674
|
+
const pill = $("#rail-pill");
|
|
1675
|
+
const nav = $("#rail-nav");
|
|
1676
|
+
if (!pill || !nav) return;
|
|
1677
|
+
const active = nav.querySelector('button[aria-current="page"]');
|
|
1678
|
+
if (!active) { pill.style.opacity = "0"; return; }
|
|
1679
|
+
pill.style.opacity = "1";
|
|
1680
|
+
pill.style.width = active.offsetWidth + "px";
|
|
1681
|
+
pill.style.height = active.offsetHeight + "px";
|
|
1682
|
+
pill.style.transform = `translateY(${active.offsetTop}px)`;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
function updateRouteChrome() {
|
|
1686
|
+
const r = ROUTES[state.view] || ROUTES.feed;
|
|
1687
|
+
$("#topbar-title").textContent = r.title;
|
|
1688
|
+
const sub = $("#topbar-sub");
|
|
1689
|
+
sub.textContent = routeSub();
|
|
1690
|
+
document.body.dataset.ctx = r.ctx ? "on" : "off";
|
|
1691
|
+
const acts = $("#route-actions");
|
|
1692
|
+
acts.innerHTML = "";
|
|
1693
|
+
if (state.view === "camera") {
|
|
1694
|
+
acts.innerHTML = `<button class="btn ghost sm" id="act-upload"><svg class="ico" style="width:16px;height:16px"><use href="#i-upload"/></svg>Upload</button>`;
|
|
1695
|
+
$("#act-upload").addEventListener("click", () => $("#cam-fileinput").click());
|
|
1696
|
+
}
|
|
1697
|
+
renderContext();
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
function routeSub() {
|
|
1701
|
+
if (state.view === "feed") return state.feed.length ? `${state.feed.length} yaps from the last 24 hours` : "quiet in here";
|
|
1702
|
+
if (state.view === "chats") return state.inbox.length ? `${state.inbox.length} conversations` : "no conversations yet";
|
|
1703
|
+
if (state.view === "camera") return "one shot, gone in 24";
|
|
1704
|
+
if (state.view === "profile" && state.me) return "@" + state.me.username;
|
|
1705
|
+
if (state.view === "admin") return "moderation and filters";
|
|
1706
|
+
return "";
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
function go(view) {
|
|
1710
|
+
state.view = view;
|
|
1711
|
+
document.body.dataset.view = view;
|
|
1712
|
+
$$(".view").forEach((v) => v.classList.toggle("on", v.id === "v-" + view));
|
|
1713
|
+
const tabFor = view === "thread" ? "chats" : view === "admin" ? null : view;
|
|
1714
|
+
$$("[data-tab]").forEach((b) => {
|
|
1715
|
+
if (b.dataset.tab === tabFor) b.setAttribute("aria-current", "page");
|
|
1716
|
+
else b.removeAttribute("aria-current");
|
|
1717
|
+
});
|
|
1718
|
+
moveRailPill();
|
|
1719
|
+
updateRouteChrome();
|
|
1720
|
+
if (view !== "thread") window.scrollTo(0, 0);
|
|
1721
|
+
if (view === "camera") startCamera(); else stopCamera();
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
const showApp = (on) => {
|
|
1725
|
+
$("#auth").classList.toggle("hidden", on);
|
|
1726
|
+
$("#shell").classList.toggle("hidden", !on);
|
|
1727
|
+
$("#tabbar").classList.toggle("hidden", !on);
|
|
1728
|
+
document.body.dataset.view = on ? state.view : "auth";
|
|
1729
|
+
document.body.dataset.ctx = on ? (ROUTES[state.view]?.ctx ? "on" : "off") : "off";
|
|
1730
|
+
if (on) requestAnimationFrame(moveRailPill);
|
|
1731
|
+
};
|
|
1732
|
+
|
|
1733
|
+
/* ---------------------------------------------------------------- auth */
|
|
1734
|
+
let authMode = "signup";
|
|
1735
|
+
function setAuthMode(mode) {
|
|
1736
|
+
authMode = mode;
|
|
1737
|
+
$$("#auth-tabs button").forEach((x) => x.classList.toggle("on", x.dataset.auth === mode));
|
|
1738
|
+
$("#auth").dataset.mode = mode;
|
|
1739
|
+
const wrap = $("#auth-name-wrap");
|
|
1740
|
+
wrap.inert = mode === "login";
|
|
1741
|
+
$("#auth-title").textContent = mode === "signup" ? "make an account" : "welcome back";
|
|
1742
|
+
$("#auth-submit").textContent = mode === "signup" ? "Create my account" : "Log in";
|
|
1743
|
+
$("#auth-pass").setAttribute("autocomplete", mode === "signup" ? "new-password" : "current-password");
|
|
1744
|
+
$("#auth-err").classList.add("hidden");
|
|
1745
|
+
positionSegPill($("#auth-tabs"));
|
|
1746
|
+
$("#auth-user").focus();
|
|
1747
|
+
}
|
|
1748
|
+
$$("#auth-tabs button").forEach((b) => b.addEventListener("click", () => setAuthMode(b.dataset.auth)));
|
|
1749
|
+
|
|
1750
|
+
function positionSegPill(seg) {
|
|
1751
|
+
if (!seg) return;
|
|
1752
|
+
let pill = seg.querySelector(".seg-pill");
|
|
1753
|
+
const active = seg.querySelector("button.on");
|
|
1754
|
+
if (!active) return;
|
|
1755
|
+
if (!pill) { pill = document.createElement("div"); pill.className = "seg-pill"; seg.appendChild(pill); }
|
|
1756
|
+
pill.style.width = active.offsetWidth + "px";
|
|
1757
|
+
pill.style.transform = `translateX(${active.offsetLeft - 3}px)`;
|
|
1758
|
+
}
|
|
1759
|
+
$$(".seg").forEach((s) => {
|
|
1760
|
+
positionSegPill(s);
|
|
1761
|
+
$$("button", s).forEach((b) => b.addEventListener("click", () => {
|
|
1762
|
+
$$("button", s).forEach((x) => x.classList.toggle("on", x === b));
|
|
1763
|
+
positionSegPill(s);
|
|
1764
|
+
}));
|
|
1765
|
+
});
|
|
1766
|
+
window.addEventListener("resize", () => $$(".seg").forEach(positionSegPill));
|
|
1767
|
+
|
|
1768
|
+
function authError(msg) {
|
|
1769
|
+
const el = $("#auth-err");
|
|
1770
|
+
el.textContent = msg;
|
|
1771
|
+
el.classList.remove("hidden");
|
|
1772
|
+
el.style.animation = "none";
|
|
1773
|
+
void el.offsetWidth;
|
|
1774
|
+
el.style.animation = "";
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
$("#pw-toggle").addEventListener("click", () => {
|
|
1778
|
+
const input = $("#auth-pass");
|
|
1779
|
+
const show = input.type === "password";
|
|
1780
|
+
input.type = show ? "text" : "password";
|
|
1781
|
+
$("#pw-toggle").setAttribute("aria-pressed", String(show));
|
|
1782
|
+
$("#pw-toggle").setAttribute("aria-label", show ? "Hide password" : "Show password");
|
|
1783
|
+
$("#pw-eye").innerHTML = `<use href="#i-${show ? "eye-off" : "eye"}"/>`;
|
|
1784
|
+
});
|
|
1785
|
+
$("#auth-pass").addEventListener("input", (e) => {
|
|
1786
|
+
const ok = e.target.value.length >= 6;
|
|
1787
|
+
const hint = $("#pw-hint");
|
|
1788
|
+
hint.dataset.ok = String(ok);
|
|
1789
|
+
hint.innerHTML = ok
|
|
1790
|
+
? '<svg class="ico"><use href="#i-check"/></svg><span>at least 6 characters</span>'
|
|
1791
|
+
: '<span>at least 6 characters</span>';
|
|
1792
|
+
});
|
|
1793
|
+
|
|
1794
|
+
["auth-user", "auth-pass", "auth-name"].forEach((id) => $("#" + id).addEventListener("input", () => $("#auth-err").classList.add("hidden")));
|
|
1795
|
+
|
|
1796
|
+
async function submitAuth() {
|
|
1797
|
+
const username = $("#auth-user").value.trim();
|
|
1798
|
+
const password = $("#auth-pass").value;
|
|
1799
|
+
const display = $("#auth-name").value.trim();
|
|
1800
|
+
const btn = $("#auth-submit");
|
|
1801
|
+
$("#auth-err").classList.add("hidden");
|
|
1802
|
+
if (!username || !password) return authError("Pick a username and password.");
|
|
1803
|
+
if (authMode === "signup" && password.length < 6) return authError("that password's too short — six characters or more.");
|
|
1804
|
+
btn.disabled = true;
|
|
1805
|
+
const label = btn.textContent;
|
|
1806
|
+
btn.innerHTML = '<span class="spinner"></span>';
|
|
1807
|
+
const w = btn.offsetWidth;
|
|
1808
|
+
btn.style.width = w + "px";
|
|
1809
|
+
try {
|
|
1810
|
+
const res = authMode === "signup"
|
|
1811
|
+
? await api("yap_signup", { p_username: username, p_password: password, p_display_name: display || username })
|
|
1812
|
+
: await api("yap_login", { p_username: username, p_password: password });
|
|
1813
|
+
state.token = res.token;
|
|
1814
|
+
localStorage.setItem(TOKEN_KEY, res.token);
|
|
1815
|
+
await loadMe();
|
|
1816
|
+
const enter = () => { showApp(true); renderProfile(); go("feed"); };
|
|
1817
|
+
if (document.startViewTransition && !REDUCED()) document.startViewTransition(enter);
|
|
1818
|
+
else enter();
|
|
1819
|
+
await Promise.all([loadFeed(), loadStories(), loadInbox()]);
|
|
1820
|
+
toast(authMode === "signup" ? "You're in" : "Welcome back", "ok");
|
|
1821
|
+
} catch (err) {
|
|
1822
|
+
authError(friendlyAuthError(err.message));
|
|
1823
|
+
btn.disabled = false;
|
|
1824
|
+
btn.textContent = label;
|
|
1825
|
+
btn.style.width = "";
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
function friendlyAuthError(msg) {
|
|
1829
|
+
const m = String(msg || "").toLowerCase();
|
|
1830
|
+
if (m.includes("invalid login")) return "that username and password don't match.";
|
|
1831
|
+
if (m.includes("taken")) return "that username's taken — try another.";
|
|
1832
|
+
if (m.includes("usernames are")) return "usernames are 3–20 characters: letters, numbers, dots or underscores.";
|
|
1833
|
+
if (m.includes("password must")) return "pick a password with six characters or more.";
|
|
1834
|
+
return msg;
|
|
1835
|
+
}
|
|
1836
|
+
$("#auth-submit").addEventListener("click", submitAuth);
|
|
1837
|
+
["auth-user", "auth-pass", "auth-name"].forEach((id) => $("#" + id).addEventListener("keydown", (e) => { if (e.key === "Enter") submitAuth(); }));
|
|
1838
|
+
|
|
1839
|
+
async function loadMe() {
|
|
1840
|
+
state.me = await api("yap_me", { p_token: state.token });
|
|
1841
|
+
return state.me;
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
async function enterApp() {
|
|
1845
|
+
showApp(true);
|
|
1846
|
+
renderProfile();
|
|
1847
|
+
go("feed");
|
|
1848
|
+
await Promise.all([loadFeed(), loadStories(), loadInbox()]);
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
async function logout() {
|
|
1852
|
+
try { await api("yap_logout", { p_token: state.token }); } catch { /* ignore */ }
|
|
1853
|
+
state.token = null;
|
|
1854
|
+
state.me = null;
|
|
1855
|
+
localStorage.removeItem(TOKEN_KEY);
|
|
1856
|
+
showApp(false);
|
|
1857
|
+
$("#auth-pass").value = "";
|
|
1858
|
+
$("#auth-user").value = "";
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/* --------------------------------------------------------------- sheets */
|
|
1862
|
+
function openSheet(html) {
|
|
1863
|
+
$("#sheet-body").innerHTML = html;
|
|
1864
|
+
$("#sheet").classList.add("on");
|
|
1865
|
+
return $("#sheet-body");
|
|
1866
|
+
}
|
|
1867
|
+
function closeSheet() {
|
|
1868
|
+
$("#sheet").classList.remove("on");
|
|
1869
|
+
$("#sheet-body").innerHTML = "";
|
|
1870
|
+
}
|
|
1871
|
+
$("#sheet").addEventListener("click", (e) => { if (e.target.id === "sheet") closeSheet(); });
|
|
1872
|
+
document.addEventListener("keydown", (e) => {
|
|
1873
|
+
if (e.key === "Escape") {
|
|
1874
|
+
if (!$("#ctxmenu")?.classList.contains("hidden")) return;
|
|
1875
|
+
closeSheet();
|
|
1876
|
+
closeStory();
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
|
|
1880
|
+
</script>
|
|
1881
|
+
<script>
|
|
1882
|
+
|
|
1883
|
+
/* =======================================================================
|
|
1884
|
+
FEED, COMPOSER, POSTS, LIGHTBOX
|
|
1885
|
+
======================================================================= */
|
|
1886
|
+
const OBJ = {
|
|
1887
|
+
bubble: `<svg viewBox="0 0 120 120" fill="none" class="obj"><defs><linearGradient id="g-b" x1="24" y1="20" x2="104" y2="104" gradientUnits="userSpaceOnUse"><stop stop-color="#7fa4ff"/><stop offset=".5" stop-color="#2f6bff"/><stop offset="1" stop-color="#173da8"/></linearGradient></defs><ellipse cx="60" cy="108" rx="32" ry="6" fill="#2f6bff" opacity=".2"/><path d="M18 26h84v48a14 14 0 0 1-14 14H52l-20 16V88h-4a10 10 0 0 1-10-10z" fill="url(#g-b)"/><ellipse cx="38" cy="40" rx="20" ry="13" fill="#fff" opacity=".28"/><circle cx="46" cy="58" r="3.4" fill="#fff" opacity=".9"/><circle cx="60" cy="58" r="3.4" fill="#fff" opacity=".72"/><circle cx="74" cy="58" r="3.4" fill="#fff" opacity=".55"/></svg>`,
|
|
1888
|
+
chat: `<svg viewBox="0 0 120 120" fill="none" class="obj"><defs><linearGradient id="g-c" x1="20" y1="24" x2="100" y2="100" gradientUnits="userSpaceOnUse"><stop stop-color="#7fa4ff"/><stop offset=".55" stop-color="#2f6bff"/><stop offset="1" stop-color="#1b3fb3"/></linearGradient></defs><ellipse cx="60" cy="106" rx="30" ry="6" fill="#2f6bff" opacity=".18"/><rect x="18" y="28" width="84" height="54" rx="18" fill="url(#g-c)"/><path d="M34 76l-8 14 20-10z" fill="#1b3fb3"/><ellipse cx="42" cy="42" rx="18" ry="10" fill="#fff" opacity=".24"/></svg>`,
|
|
1889
|
+
plane: `<svg viewBox="0 0 120 120" fill="none" class="obj"><defs><linearGradient id="g-p" x1="18" y1="20" x2="104" y2="100" gradientUnits="userSpaceOnUse"><stop stop-color="#9db9ff"/><stop offset=".5" stop-color="#2f6bff"/><stop offset="1" stop-color="#1b3fb3"/></linearGradient></defs><ellipse cx="60" cy="104" rx="30" ry="6" fill="#2f6bff" opacity=".18"/><path d="M16 58 104 20 66 104 54 68z" fill="url(#g-p)"/><path d="M54 68 104 20 66 104z" fill="#173da8" opacity=".55"/><ellipse cx="44" cy="48" rx="14" ry="7" fill="#fff" opacity=".25" transform="rotate(-20 44 48)"/></svg>`,
|
|
1890
|
+
};
|
|
1891
|
+
const emptyState = (obj, title, copy, ctaLabel, ctaId) => `
|
|
1892
|
+
<div class="empty">
|
|
1893
|
+
${OBJ[obj] || ""}
|
|
1894
|
+
<h3>${esc(title)}</h3>
|
|
1895
|
+
<p style="max-width:36ch">${esc(copy)}</p>
|
|
1896
|
+
${ctaLabel ? `<button class="btn primary" id="${ctaId}">${esc(ctaLabel)}</button>` : ""}
|
|
1897
|
+
</div>`;
|
|
1898
|
+
|
|
1899
|
+
/* ------------------------------------------------------------- lightbox */
|
|
1900
|
+
function openLightbox(list, idx) {
|
|
1901
|
+
state.lightbox = { list, idx };
|
|
1902
|
+
const dlg = $("#lightbox");
|
|
1903
|
+
const img = $("#lightbox-img");
|
|
1904
|
+
img.src = list[idx];
|
|
1905
|
+
const many = list.length > 1;
|
|
1906
|
+
$("#lightbox-prev").style.display = many ? "grid" : "none";
|
|
1907
|
+
$("#lightbox-next").style.display = many ? "grid" : "none";
|
|
1908
|
+
if (typeof dlg.showModal === "function") dlg.showModal(); else dlg.setAttribute("open", "");
|
|
1909
|
+
}
|
|
1910
|
+
function shiftLightbox(dir) {
|
|
1911
|
+
const { list } = state.lightbox;
|
|
1912
|
+
if (list.length < 2) return;
|
|
1913
|
+
state.lightbox.idx = (state.lightbox.idx + dir + list.length) % list.length;
|
|
1914
|
+
$("#lightbox-img").src = list[state.lightbox.idx];
|
|
1915
|
+
}
|
|
1916
|
+
$("#lightbox-close").addEventListener("click", () => $("#lightbox").close());
|
|
1917
|
+
$("#lightbox-prev").addEventListener("click", () => shiftLightbox(-1));
|
|
1918
|
+
$("#lightbox-next").addEventListener("click", () => shiftLightbox(1));
|
|
1919
|
+
$("#lightbox").addEventListener("click", (e) => { if (e.target.id === "lightbox") $("#lightbox").close(); });
|
|
1920
|
+
$("#lightbox").addEventListener("keydown", (e) => {
|
|
1921
|
+
if (e.key === "ArrowLeft") shiftLightbox(-1);
|
|
1922
|
+
if (e.key === "ArrowRight") shiftLightbox(1);
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
/* ------------------------------------------------------------------ feed */
|
|
1926
|
+
let feedSnapshot = new Map();
|
|
1927
|
+
|
|
1928
|
+
async function loadFeed(opts = {}) {
|
|
1929
|
+
const list = $("#feed-list");
|
|
1930
|
+
if (!opts.silent && !state.feed.length) {
|
|
1931
|
+
list.innerHTML = `<div class="skeleton">${'<i></i>'.repeat(3)}<i style="width:60%"></i></div>`;
|
|
1932
|
+
}
|
|
1933
|
+
try {
|
|
1934
|
+
const rows = await api("yap_feed", { p_token: state.token, p_limit: 40 });
|
|
1935
|
+
const prevIds = new Set(state.feed.map((p) => p.id));
|
|
1936
|
+
const fresh = rows.filter((p) => !prevIds.has(p.id)).length;
|
|
1937
|
+
feedSnapshot = new Map($$(".post", list).map((el) => [el.dataset.post, el.getBoundingClientRect()]));
|
|
1938
|
+
state.feed = rows;
|
|
1939
|
+
renderFeed();
|
|
1940
|
+
updateRouteChrome();
|
|
1941
|
+
if (opts.silent && fresh && window.scrollY > 240) showNewPill(fresh);
|
|
1942
|
+
} catch (err) {
|
|
1943
|
+
list.innerHTML = emptyState("bubble", "couldn't load yaps", err.message);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function showNewPill(n) {
|
|
1947
|
+
const old = $("#new-pill");
|
|
1948
|
+
if (old) old.remove();
|
|
1949
|
+
const pill = document.createElement("button");
|
|
1950
|
+
pill.className = "new-pill";
|
|
1951
|
+
pill.id = "new-pill";
|
|
1952
|
+
pill.textContent = `${n} new ${n === 1 ? "yap" : "yaps"}`;
|
|
1953
|
+
pill.addEventListener("click", () => {
|
|
1954
|
+
window.scrollTo({ top: 0, behavior: REDUCED() ? "auto" : "smooth" });
|
|
1955
|
+
pill.remove();
|
|
1956
|
+
});
|
|
1957
|
+
$("#feed-list").before(pill);
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
function mediaHtml(p) {
|
|
1961
|
+
const src = p.image_url || p.gif_url;
|
|
1962
|
+
if (!src) return "";
|
|
1963
|
+
return `<div class="post-media" data-zoom="${esc(src)}"><img src="${esc(src)}" alt="" loading="lazy" onerror="this.parentNode.remove()" width="800" height="600" /></div>`;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
function postHtml(p) {
|
|
1967
|
+
const badges = [
|
|
1968
|
+
p.author.is_support ? '<span class="badge support">support</span>' : "",
|
|
1969
|
+
p.author.is_verified && !p.author.is_support ? '<span class="badge verified"><svg class="ico"><use href="#i-check"/></svg>verified</span>' : "",
|
|
1970
|
+
].join("");
|
|
1971
|
+
const burst = Array.from({ length: 6 }, (_, i) => `<i style="--a:${i * 60}deg"></i>`).join("");
|
|
1972
|
+
return `<article class="post spot" data-post="${esc(p.id)}">
|
|
1973
|
+
<div class="post-head">
|
|
1974
|
+
${avatarHtml(p.author)}
|
|
1975
|
+
<div class="post-who">
|
|
1976
|
+
<div class="post-name-row">
|
|
1977
|
+
<span class="post-name">${esc(p.author.display_name || p.author.username)}</span>${badges}
|
|
1978
|
+
</div>
|
|
1979
|
+
<div class="post-meta">${p.mine ? '<span class="you">you</span><i class="dot"></i>' : ""}<span>@${esc(p.author.username)}</span><i class="dot"></i><time datetime="${esc(p.created_at)}">${esc(fmtTime(p.created_at))}</time></div>
|
|
1980
|
+
</div>
|
|
1981
|
+
<button class="iconbtn post-more" data-menu="${esc(p.id)}" aria-label="Post options" data-tip="Options">
|
|
1982
|
+
<svg class="ico"><use href="#i-more"/></svg>
|
|
1983
|
+
</button>
|
|
1984
|
+
</div>
|
|
1985
|
+
${p.body ? `<p class="post-body">${esc(p.body)}</p>` : ""}
|
|
1986
|
+
${mediaHtml(p)}
|
|
1987
|
+
<div class="post-acts">
|
|
1988
|
+
<button class="act" data-like="${esc(p.id)}" data-on="${p.liked ? "true" : "false"}" aria-pressed="${p.liked ? "true" : "false"}" aria-label="Like">
|
|
1989
|
+
<span class="burst">${burst}</span>
|
|
1990
|
+
<svg class="ico"><use href="#i-heart"/></svg>
|
|
1991
|
+
<span class="count"><span>${p.likes}</span></span>
|
|
1992
|
+
</button>
|
|
1993
|
+
<button class="act" data-reply="${esc(p.id)}" aria-label="Replies">
|
|
1994
|
+
<svg class="ico"><use href="#i-reply"/></svg>
|
|
1995
|
+
<span class="count"><span>${p.replies ?? 0}</span></span>
|
|
1996
|
+
</button>
|
|
1997
|
+
</div>
|
|
1998
|
+
<div class="replies" id="replies-${esc(p.id)}"></div>
|
|
1999
|
+
</article>`;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
function renderFeed() {
|
|
2003
|
+
const list = $("#feed-list");
|
|
2004
|
+
if (!state.feed.length) {
|
|
2005
|
+
list.innerHTML = emptyState("bubble", "no yaps yet", "The feed's empty. Say something and it lands here for the next 24 hours.", "Write the first yap", "feed-cta");
|
|
2006
|
+
$("#feed-cta").addEventListener("click", () => $("#composer-text").focus());
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
list.innerHTML = state.feed.map(postHtml).join("");
|
|
2010
|
+
flipIn(list);
|
|
2011
|
+
|
|
2012
|
+
$$("[data-like]", list).forEach((b) => b.addEventListener("click", () => likePost(b)));
|
|
2013
|
+
$$("[data-reply]", list).forEach((b) => b.addEventListener("click", () => toggleReplies(b.dataset.reply)));
|
|
2014
|
+
$$("[data-menu]", list).forEach((b) => b.addEventListener("click", () => openPostMenu(b.dataset.menu)));
|
|
2015
|
+
$$("[data-zoom]", list).forEach((el) => el.addEventListener("click", () => openLightbox([el.dataset.zoom], 0)));
|
|
2016
|
+
wireSpotlights(list);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
function flipIn(list) {
|
|
2020
|
+
if (REDUCED()) return;
|
|
2021
|
+
$$(".post", list).forEach((el) => {
|
|
2022
|
+
const prev = feedSnapshot.get(el.dataset.post);
|
|
2023
|
+
const now = el.getBoundingClientRect();
|
|
2024
|
+
if (!prev) {
|
|
2025
|
+
el.animate(
|
|
2026
|
+
[{ opacity: 0, transform: "translateY(-12px) scale(0.995)" }, { opacity: 1, transform: "none" }],
|
|
2027
|
+
{ duration: 420, easing: EASE }
|
|
2028
|
+
);
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
const dy = prev.top - now.top;
|
|
2032
|
+
if (Math.abs(dy) > 1) el.animate([{ transform: `translateY(${dy}px)` }, { transform: "none" }], { duration: 420, easing: EASE });
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
function wireSpotlights(root) {
|
|
2037
|
+
$$(".spot", root).forEach((el) => {
|
|
2038
|
+
if (el.dataset.spot) return;
|
|
2039
|
+
el.dataset.spot = "1";
|
|
2040
|
+
el.addEventListener("pointermove", (e) => {
|
|
2041
|
+
const r = el.getBoundingClientRect();
|
|
2042
|
+
el.style.setProperty("--mx", `${e.clientX - r.left}px`);
|
|
2043
|
+
el.style.setProperty("--my", `${e.clientY - r.top}px`);
|
|
2044
|
+
});
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
async function likePost(btn) {
|
|
2049
|
+
const id = btn.dataset.like;
|
|
2050
|
+
const post = state.feed.find((p) => p.id === id);
|
|
2051
|
+
if (!post) return;
|
|
2052
|
+
const on = !post.liked;
|
|
2053
|
+
post.liked = on;
|
|
2054
|
+
post.likes += on ? 1 : -1;
|
|
2055
|
+
paintLike(btn, post.likes, on);
|
|
2056
|
+
if (on) {
|
|
2057
|
+
const burst = btn.querySelector(".burst");
|
|
2058
|
+
burst.dataset.go = "false";
|
|
2059
|
+
void burst.offsetWidth;
|
|
2060
|
+
burst.dataset.go = "true";
|
|
2061
|
+
if (!REDUCED()) btn.animate([{ transform: "scale(0.9)" }, { transform: "scale(1)" }], { duration: 320, easing: "cubic-bezier(.34,1.56,.64,1)" });
|
|
2062
|
+
}
|
|
2063
|
+
try { await api("yap_like", { p_token: state.token, p_post_id: id, p_on: on }); }
|
|
2064
|
+
catch (err) {
|
|
2065
|
+
toast(err.message, "err");
|
|
2066
|
+
post.liked = !on;
|
|
2067
|
+
post.likes += on ? -1 : 1;
|
|
2068
|
+
paintLike(btn, post.likes, post.liked);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
function paintLike(btn, likes, on) {
|
|
2072
|
+
btn.dataset.on = String(on);
|
|
2073
|
+
btn.setAttribute("aria-pressed", String(on));
|
|
2074
|
+
const box = btn.querySelector(".count");
|
|
2075
|
+
const prev = box.querySelector("span");
|
|
2076
|
+
const next = document.createElement("span");
|
|
2077
|
+
next.textContent = likes;
|
|
2078
|
+
box.innerHTML = "";
|
|
2079
|
+
box.appendChild(next);
|
|
2080
|
+
btn.classList.add("roll");
|
|
2081
|
+
setTimeout(() => btn.classList.remove("roll"), 340);
|
|
2082
|
+
void prev;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
async function toggleReplies(postId) {
|
|
2086
|
+
const box = $("#replies-" + postId);
|
|
2087
|
+
if (!box) return;
|
|
2088
|
+
if (box.classList.contains("on")) { box.classList.remove("on"); return; }
|
|
2089
|
+
box.classList.add("on");
|
|
2090
|
+
box.innerHTML = `<div class="skeleton"><i style="width:40%"></i><i style="width:70%"></i></div>`;
|
|
2091
|
+
try {
|
|
2092
|
+
const rows = await api("yap_replies_for", { p_token: state.token, p_post_id: postId });
|
|
2093
|
+
box.innerHTML = (rows.length
|
|
2094
|
+
? rows.map((r) => `<div class="reply"><span class="who">@${esc(r.username)}</span><span style="flex:1;min-width:0">${esc(r.body)}</span><span class="when">${esc(fmtTime(r.created_at))}</span></div>`).join("")
|
|
2095
|
+
: `<p class="small" style="color:var(--tx-3)">No replies yet.</p>`) +
|
|
2096
|
+
`<div class="reply-form">
|
|
2097
|
+
<input class="field" id="rep-${esc(postId)}" placeholder="Reply…" maxlength="500" aria-label="Reply" />
|
|
2098
|
+
<button class="btn primary sm" data-sendreply="${esc(postId)}">Send</button>
|
|
2099
|
+
</div>`;
|
|
2100
|
+
box.querySelector("[data-sendreply]").addEventListener("click", async (e) => {
|
|
2101
|
+
const input = $("#rep-" + postId);
|
|
2102
|
+
const body = input.value.trim();
|
|
2103
|
+
if (!body) return;
|
|
2104
|
+
e.currentTarget.disabled = true;
|
|
2105
|
+
try {
|
|
2106
|
+
await api("yap_reply", { p_token: state.token, p_post_id: postId, p_body: body });
|
|
2107
|
+
const post = state.feed.find((p) => p.id === postId);
|
|
2108
|
+
if (post) post.replies += 1;
|
|
2109
|
+
const counter = $(`[data-reply="${postId}"] .count span`);
|
|
2110
|
+
if (counter && post) counter.textContent = post.replies;
|
|
2111
|
+
input.value = "";
|
|
2112
|
+
toast("Reply sent", "ok");
|
|
2113
|
+
box.classList.remove("on");
|
|
2114
|
+
toggleReplies(postId);
|
|
2115
|
+
} catch (err) { toast(err.message, "err"); e.currentTarget.disabled = false; }
|
|
2116
|
+
});
|
|
2117
|
+
box.querySelector("input")?.addEventListener("keydown", (e) => {
|
|
2118
|
+
if (e.key === "Enter") box.querySelector("[data-sendreply]").click();
|
|
2119
|
+
});
|
|
2120
|
+
} catch (err) {
|
|
2121
|
+
box.innerHTML = `<p class="small" style="color:var(--tx-1)">${esc(err.message)}</p>`;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
function canDeletePost(post) {
|
|
2126
|
+
return !!(post && (post.mine || state.me?.is_admin));
|
|
2127
|
+
}
|
|
2128
|
+
function reportPost(postId) {
|
|
2129
|
+
const post = state.feed.find((p) => p.id === postId);
|
|
2130
|
+
if (!post) return;
|
|
2131
|
+
closeSheet();
|
|
2132
|
+
openReport("post", post.id, post.author.username + ": " + (post.body || "").slice(0, 60));
|
|
2133
|
+
}
|
|
2134
|
+
async function deletePostById(postId) {
|
|
2135
|
+
const post = state.feed.find((p) => p.id === postId);
|
|
2136
|
+
if (!canDeletePost(post)) return;
|
|
2137
|
+
try {
|
|
2138
|
+
await api("yap_admin_remove_post", {
|
|
2139
|
+
p_token: state.token,
|
|
2140
|
+
p_post_id: postId,
|
|
2141
|
+
p_reason: post.mine ? "author deleted" : "moderation removal",
|
|
2142
|
+
});
|
|
2143
|
+
toast("Post deleted", "ok");
|
|
2144
|
+
closeSheet();
|
|
2145
|
+
await loadFeed();
|
|
2146
|
+
} catch (err) { toast(err.message, "err"); }
|
|
2147
|
+
}
|
|
2148
|
+
function openPostMenu(postId) {
|
|
2149
|
+
const post = state.feed.find((p) => p.id === postId);
|
|
2150
|
+
if (!post) return;
|
|
2151
|
+
const sheet = openSheet(`<h3>Post options</h3>
|
|
2152
|
+
<div class="sheet-actions">
|
|
2153
|
+
<button class="btn ghost" data-do="report"><svg class="ico"><use href="#i-help"/></svg>Report this post</button>
|
|
2154
|
+
${canDeletePost(post) ? `<button class="btn danger" data-do="delete"><svg class="ico"><use href="#i-x"/></svg>${post.mine ? "Delete my post" : "Remove post"}</button>` : ""}
|
|
2155
|
+
</div>`);
|
|
2156
|
+
sheet.querySelector('[data-do="report"]').addEventListener("click", () => reportPost(postId));
|
|
2157
|
+
const del = sheet.querySelector('[data-do="delete"]');
|
|
2158
|
+
if (del) del.addEventListener("click", async () => {
|
|
2159
|
+
del.disabled = true;
|
|
2160
|
+
await deletePostById(postId);
|
|
2161
|
+
del.disabled = false;
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
/* -------------------------------------------------------------- composer */
|
|
2166
|
+
function syncComposer() {
|
|
2167
|
+
const text = $("#composer-text").value;
|
|
2168
|
+
const has = text.trim().length > 0 || !!state.attach || !!state.gifUrl;
|
|
2169
|
+
$("#composer-send").disabled = !has || !!state.sending;
|
|
2170
|
+
$("#rail-new").dataset.ready = String(has);
|
|
2171
|
+
const ring = $("#count-ring");
|
|
2172
|
+
const pct = Math.min(1, text.length / 1000);
|
|
2173
|
+
ring.dataset.show = String(text.length > 800);
|
|
2174
|
+
ring.dataset.warn = String(text.length > 900);
|
|
2175
|
+
ring.dataset.over = String(text.length >= 1000);
|
|
2176
|
+
ring.querySelector(".val").style.strokeDashoffset = String(69.1 * (1 - pct));
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
async function sendPost() {
|
|
2180
|
+
const box = $("#composer-text");
|
|
2181
|
+
const body = box.value.trim();
|
|
2182
|
+
const btn = $("#composer-send");
|
|
2183
|
+
if (!body && !state.attach && !state.gifUrl) return toast("Write something first", "err");
|
|
2184
|
+
if (state.sending) return;
|
|
2185
|
+
state.sending = true;
|
|
2186
|
+
btn.disabled = true;
|
|
2187
|
+
btn.innerHTML = '<span class="spinner"></span>';
|
|
2188
|
+
try {
|
|
2189
|
+
let imageUrl = null;
|
|
2190
|
+
if (state.attach) {
|
|
2191
|
+
const path = `${state.me.username}/${crypto.randomUUID()}.${state.attach.ext}`;
|
|
2192
|
+
const { error } = await sb.storage.from(CONFIG.mediaBucket).upload(path, state.attach.blob, { contentType: state.attach.blob.type || "image/jpeg" });
|
|
2193
|
+
if (error) throw new Error(error.message);
|
|
2194
|
+
imageUrl = sb.storage.from(CONFIG.mediaBucket).getPublicUrl(path).data.publicUrl;
|
|
2195
|
+
}
|
|
2196
|
+
await api("yap_post", { p_token: state.token, p_body: body, p_image_url: imageUrl, p_gif_url: state.gifUrl || null });
|
|
2197
|
+
box.value = "";
|
|
2198
|
+
box.style.height = "auto";
|
|
2199
|
+
clearAttach();
|
|
2200
|
+
await loadFeed();
|
|
2201
|
+
loadMe().then(renderProfile).catch(() => {});
|
|
2202
|
+
toast("Yapped", "ok");
|
|
2203
|
+
window.scrollTo({ top: 0, behavior: REDUCED() ? "auto" : "smooth" });
|
|
2204
|
+
} catch (err) {
|
|
2205
|
+
toast(err.message, "err");
|
|
2206
|
+
} finally {
|
|
2207
|
+
state.sending = false;
|
|
2208
|
+
btn.textContent = "Yap it";
|
|
2209
|
+
syncComposer();
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
$("#composer-send").addEventListener("click", sendPost);
|
|
2213
|
+
$("#composer-text").addEventListener("input", (e) => {
|
|
2214
|
+
e.target.style.height = "auto";
|
|
2215
|
+
e.target.style.height = Math.min(e.target.scrollHeight, 220) + "px";
|
|
2216
|
+
syncComposer();
|
|
2217
|
+
});
|
|
2218
|
+
$("#composer-text").addEventListener("blur", (e) => { if (!e.target.value) e.target.style.height = ""; });
|
|
2219
|
+
$("#composer-text").addEventListener("keydown", (e) => {
|
|
2220
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") { e.preventDefault(); sendPost(); }
|
|
2221
|
+
});
|
|
2222
|
+
|
|
2223
|
+
function clearAttach() {
|
|
2224
|
+
state.attach = null;
|
|
2225
|
+
state.gifUrl = null;
|
|
2226
|
+
$("#composer-attach").classList.add("hidden");
|
|
2227
|
+
$("#composer-attach").innerHTML = "";
|
|
2228
|
+
syncComposer();
|
|
2229
|
+
}
|
|
2230
|
+
function noteAttach(icon, label) {
|
|
2231
|
+
const box = $("#composer-attach");
|
|
2232
|
+
box.classList.remove("hidden");
|
|
2233
|
+
box.innerHTML = `<svg class="ico" style="width:15px;height:15px;color:var(--blue-hi)"><use href="#i-${icon}"/></svg>
|
|
2234
|
+
<span>${esc(label)}</span>
|
|
2235
|
+
<button class="btn quiet sm" id="attach-clear" style="height:26px">Remove</button>`;
|
|
2236
|
+
$("#attach-clear").addEventListener("click", clearAttach);
|
|
2237
|
+
syncComposer();
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
const attachInput = document.createElement("input");
|
|
2241
|
+
attachInput.type = "file";
|
|
2242
|
+
attachInput.accept = "image/*";
|
|
2243
|
+
attachInput.className = "hidden";
|
|
2244
|
+
document.body.appendChild(attachInput);
|
|
2245
|
+
$("#composer-img").addEventListener("click", () => attachInput.click());
|
|
2246
|
+
attachInput.addEventListener("change", async (e) => {
|
|
2247
|
+
const file = e.target.files[0];
|
|
2248
|
+
e.target.value = "";
|
|
2249
|
+
if (!file) return;
|
|
2250
|
+
try {
|
|
2251
|
+
const bitmap = await createImageBitmap(file);
|
|
2252
|
+
const canvas = document.createElement("canvas");
|
|
2253
|
+
const scale = Math.min(1, 1200 / Math.max(bitmap.width, bitmap.height));
|
|
2254
|
+
canvas.width = Math.round(bitmap.width * scale);
|
|
2255
|
+
canvas.height = Math.round(bitmap.height * scale);
|
|
2256
|
+
canvas.getContext("2d").drawImage(bitmap, 0, 0, canvas.width, canvas.height);
|
|
2257
|
+
const blob = await new Promise((res) => canvas.toBlob(res, "image/jpeg", 0.78));
|
|
2258
|
+
state.attach = { blob, ext: "jpg" };
|
|
2259
|
+
state.gifUrl = null;
|
|
2260
|
+
noteAttach("image", "photo attached");
|
|
2261
|
+
} catch (err) { toast("Couldn't read that image", "err"); }
|
|
2262
|
+
});
|
|
2263
|
+
|
|
2264
|
+
/* ----------------------------------------------------------------- memes */
|
|
2265
|
+
const MEME_CARDS = [
|
|
2266
|
+
{ emoji: "💀", text: "i'm dead", bg: "#12203f" },
|
|
2267
|
+
{ emoji: "🔥", text: "this is fire", bg: "#101a3e" },
|
|
2268
|
+
{ emoji: "🫠", text: "melting rn", bg: "#0e1e3c" },
|
|
2269
|
+
{ emoji: "🗿", text: "bruh", bg: "#1a1a24" },
|
|
2270
|
+
{ emoji: "👀", text: "watching", bg: "#0c1c33" },
|
|
2271
|
+
{ emoji: "🎯", text: "called it", bg: "#14224d" },
|
|
2272
|
+
];
|
|
2273
|
+
const memeDataUrl = (m) => "data:image/svg+xml," + encodeURIComponent(
|
|
2274
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320"><rect width="320" height="320" fill="${m.bg}"/>` +
|
|
2275
|
+
`<text x="160" y="150" font-size="96" text-anchor="middle">${m.emoji}</text>` +
|
|
2276
|
+
`<text x="160" y="230" font-size="26" font-family="Geist,Arial" font-weight="700" fill="#e8eeff" text-anchor="middle">${m.text}</text></svg>`);
|
|
2277
|
+
|
|
2278
|
+
/* KLIPY responses have changed shape over time (and Tenor-compatible apps can
|
|
2279
|
+
wrap them differently), so pick media URLs defensively instead of trusting
|
|
2280
|
+
one exact nested path. */
|
|
2281
|
+
function collectUrls(node, path = "", out = [], depth = 0) {
|
|
2282
|
+
if (!node || depth > 7) return out;
|
|
2283
|
+
if (typeof node === "string") {
|
|
2284
|
+
if (/^(https?:)?\/\//i.test(node) || node.startsWith("data:image/")) out.push({ url: node.startsWith("//") ? "https:" + node : node, path });
|
|
2285
|
+
return out;
|
|
2286
|
+
}
|
|
2287
|
+
if (Array.isArray(node)) { node.forEach((v, i) => collectUrls(v, path + "." + i, out, depth + 1)); return out; }
|
|
2288
|
+
if (typeof node === "object") {
|
|
2289
|
+
for (const [k, v] of Object.entries(node)) {
|
|
2290
|
+
if (k === "url" && typeof v === "string") collectUrls(v, path + "." + k, out, depth + 1);
|
|
2291
|
+
else if (v && typeof v === "object") collectUrls(v, path + "." + k, out, depth + 1);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
return out;
|
|
2295
|
+
}
|
|
2296
|
+
function klipyMedia(item, small = false) {
|
|
2297
|
+
const urls = collectUrls(item).filter((u) => !/\.(mp4|webm)(\?|#|$)/i.test(u.url));
|
|
2298
|
+
if (!urls.length) return null;
|
|
2299
|
+
const score = (u) => {
|
|
2300
|
+
const s = (u.path + " " + u.url).toLowerCase();
|
|
2301
|
+
let n = 0;
|
|
2302
|
+
if (/\.gif(\?|#|$|\s)/i.test(u.url) || s.includes("gif")) n -= 24;
|
|
2303
|
+
else if (/\.webp(\?|#|$)/i.test(u.url)) n -= 18;
|
|
2304
|
+
else if (/\.(jpe?g|png)(\?|#|$)/i.test(u.url)) n -= 8;
|
|
2305
|
+
if (small) {
|
|
2306
|
+
if (/(^|[._])(sm|small|tiny|preview|thumb)([._]|$)/i.test(u.path)) n -= 28;
|
|
2307
|
+
if (/(^|[._])(hd|large|original)([._]|$)/i.test(u.path)) n += 18;
|
|
2308
|
+
} else {
|
|
2309
|
+
if (/(^|[._])(md|hd|large|original)([._]|$)/i.test(u.path)) n -= 28;
|
|
2310
|
+
if (/(^|[._])(sm|small|tiny|preview|thumb)([._]|$)/i.test(u.path)) n += 18;
|
|
2311
|
+
}
|
|
2312
|
+
return n;
|
|
2313
|
+
};
|
|
2314
|
+
return urls.sort((a, b) => score(a) - score(b))[0].url;
|
|
2315
|
+
}
|
|
2316
|
+
function klipyRows(payload) {
|
|
2317
|
+
const candidates = [payload?.data?.data, payload?.data?.results, payload?.data?.items, payload?.data, payload?.results, payload?.items, payload];
|
|
2318
|
+
const rows = candidates.find(Array.isArray) || [];
|
|
2319
|
+
return rows.map((item) => {
|
|
2320
|
+
const full = klipyMedia(item, false);
|
|
2321
|
+
const preview = klipyMedia(item, true) || full;
|
|
2322
|
+
return full ? { full, preview, title: item.title || item.slug || item.id || "GIF", slug: item.slug || item.id || "" } : null;
|
|
2323
|
+
}).filter(Boolean).slice(0, 20);
|
|
2324
|
+
}
|
|
2325
|
+
async function fetchKlipy(q) {
|
|
2326
|
+
const endpoint = q ? "search" : "trending";
|
|
2327
|
+
const params = new URLSearchParams({
|
|
2328
|
+
page: "1",
|
|
2329
|
+
per_page: "20",
|
|
2330
|
+
customer_id: state.me?.username || "anonymous",
|
|
2331
|
+
locale: ((navigator.language || "en-US").split("-")[1] || "us").toLowerCase(),
|
|
2332
|
+
content_filter: "high",
|
|
2333
|
+
format_filter: "gif,webp",
|
|
2334
|
+
});
|
|
2335
|
+
if (q) params.set("q", q);
|
|
2336
|
+
const url = `https://api.klipy.com/api/v1/${encodeURIComponent(CONFIG.klipyKey)}/gifs/${endpoint}?${params}`;
|
|
2337
|
+
const res = await fetch(url);
|
|
2338
|
+
if (!res.ok) throw new Error("KLIPY did not answer");
|
|
2339
|
+
return klipyRows(await res.json());
|
|
2340
|
+
}
|
|
2341
|
+
function registerKlipyShare(slug, q) {
|
|
2342
|
+
if (!CONFIG.klipyKey || !slug) return;
|
|
2343
|
+
const url = `https://api.klipy.com/api/v1/${encodeURIComponent(CONFIG.klipyKey)}/gifs/share/${encodeURIComponent(slug)}`;
|
|
2344
|
+
fetch(url, {
|
|
2345
|
+
method: "POST",
|
|
2346
|
+
headers: { "Content-Type": "application/json" },
|
|
2347
|
+
body: JSON.stringify({ customer_id: state.me?.username || "anonymous", q: q || "" }),
|
|
2348
|
+
}).catch(() => { /* share analytics must never block posting */ });
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
function openMemePicker() {
|
|
2352
|
+
const hasKey = !!CONFIG.klipyKey;
|
|
2353
|
+
const sheet = openSheet(`<h3>Memes & GIFs</h3>
|
|
2354
|
+
<div class="row" style="margin:12px 0 10px;display:flex;gap:8px">
|
|
2355
|
+
<input class="field" id="gif-q" placeholder="Search KLIPY GIFs" ${hasKey ? "" : "disabled"} />
|
|
2356
|
+
</div>
|
|
2357
|
+
<div id="gif-results" class="memeGrid" style="margin-bottom:14px"></div>
|
|
2358
|
+
<div class="section-head" style="margin:4px 0 10px;padding-bottom:8px"><h3 style="font-size:15px">Card memes</h3></div>
|
|
2359
|
+
<div class="memeGrid two" id="meme-grid"></div>
|
|
2360
|
+
<p class="hint" style="margin-top:14px">${hasKey ? "" : "Add a KLIPY key for live GIFs. "}Or paste an image link:</p>
|
|
2361
|
+
<div class="row" style="display:flex;gap:8px;margin-top:8px"><input class="field" id="gif-url" placeholder="https://…gif" /><button class="btn primary sm" id="gif-use">Use</button></div>
|
|
2362
|
+
<div class="klipy-credit">Powered by KLIPY</div>`);
|
|
2363
|
+
const grid = sheet.querySelector("#meme-grid");
|
|
2364
|
+
grid.innerHTML = MEME_CARDS.map((m, i) => `<button class="giftile" data-meme="${i}"><img src="${memeDataUrl(m)}" alt="${esc(m.text)}" /></button>`).join("");
|
|
2365
|
+
const useGif = (url, label, share = null) => {
|
|
2366
|
+
state.gifUrl = url;
|
|
2367
|
+
state.attach = null;
|
|
2368
|
+
noteAttach("gif", label);
|
|
2369
|
+
if (share?.slug) registerKlipyShare(share.slug, share.q);
|
|
2370
|
+
closeSheet();
|
|
2371
|
+
};
|
|
2372
|
+
grid.querySelectorAll("[data-meme]").forEach((b) => b.addEventListener("click", () => useGif(memeDataUrl(MEME_CARDS[Number(b.dataset.meme)]), "meme attached")));
|
|
2373
|
+
sheet.querySelector("#gif-use").addEventListener("click", () => {
|
|
2374
|
+
const url = sheet.querySelector("#gif-url").value.trim();
|
|
2375
|
+
if (!/^https?:\/\//i.test(url)) return toast("That is not a link", "err");
|
|
2376
|
+
useGif(url, "GIF attached");
|
|
2377
|
+
});
|
|
2378
|
+
|
|
2379
|
+
const results = sheet.querySelector("#gif-results");
|
|
2380
|
+
if (!hasKey) {
|
|
2381
|
+
results.innerHTML = "";
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
let timer = 0, seq = 0;
|
|
2385
|
+
const skeleton = () => { results.innerHTML = `<div class="gif-skel" style="grid-column:1/-1">${"<i></i>".repeat(6)}</div>`; };
|
|
2386
|
+
const search = async (q) => {
|
|
2387
|
+
const mine = ++seq;
|
|
2388
|
+
skeleton();
|
|
2389
|
+
try {
|
|
2390
|
+
const rows = await fetchKlipy(q);
|
|
2391
|
+
if (mine !== seq || !document.body.contains(results)) return;
|
|
2392
|
+
if (!rows.length) {
|
|
2393
|
+
results.innerHTML = `<p class="small" style="grid-column:1/-1;color:var(--tx-3);padding:8px 2px">${q ? "No GIFs matched that." : "No trending GIFs right now."}</p>`;
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
results.innerHTML = rows.map((g, i) => `<button class="giftile" data-gif="${esc(g.full)}" data-gifi="${i}" aria-label="${esc(g.title)}"><img src="${esc(g.preview)}" alt="" loading="lazy" /></button>`).join("");
|
|
2397
|
+
results.querySelectorAll("[data-gif]").forEach((b) => b.addEventListener("click", () => {
|
|
2398
|
+
const gif = rows[Number(b.dataset.gifi)] || {};
|
|
2399
|
+
useGif(b.dataset.gif, "GIF attached", { slug: gif.slug, q });
|
|
2400
|
+
}));
|
|
2401
|
+
} catch (err) {
|
|
2402
|
+
if (mine !== seq || !document.body.contains(results)) return;
|
|
2403
|
+
results.innerHTML = `<p class="small" style="grid-column:1/-1;color:var(--tx-3);padding:8px 2px">${esc(err.message)}</p>`;
|
|
2404
|
+
toast(err.message, "err");
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
search("");
|
|
2408
|
+
sheet.querySelector("#gif-q").addEventListener("input", (e) => {
|
|
2409
|
+
clearTimeout(timer);
|
|
2410
|
+
const q = e.target.value.trim();
|
|
2411
|
+
timer = setTimeout(() => search(q), 300);
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
$("#composer-gif").addEventListener("click", openMemePicker);
|
|
2415
|
+
|
|
2416
|
+
/* ---------------------------------------------------------------- report */
|
|
2417
|
+
function openReport(targetType, targetId, label) {
|
|
2418
|
+
const reasons = ["Harassment", "Hate speech", "Spam", "Nudity or sexual content", "Self harm", "Impersonation", "Something else"];
|
|
2419
|
+
const sheet = openSheet(`<h3>Report</h3>
|
|
2420
|
+
<p class="small" style="color:var(--tx-2);margin:6px 0 14px">Reports go straight to the moderation queue. A person reads every one.</p>
|
|
2421
|
+
<div class="sheet-actions">
|
|
2422
|
+
${reasons.map((r, i) => `<button class="btn ghost" data-reason="${i}">${esc(r)}</button>`).join("")}
|
|
2423
|
+
</div>
|
|
2424
|
+
<textarea class="field" id="report-detail" placeholder="Anything else we should know? (optional)" maxlength="500" style="min-height:80px;margin-top:12px"></textarea>`);
|
|
2425
|
+
sheet.querySelectorAll("[data-reason]").forEach((b) => b.addEventListener("click", async () => {
|
|
2426
|
+
b.disabled = true;
|
|
2427
|
+
try {
|
|
2428
|
+
await api("yap_report", {
|
|
2429
|
+
p_token: state.token, p_target_type: targetType, p_target_id: targetId,
|
|
2430
|
+
p_label: label, p_reason: reasons[Number(b.dataset.reason)],
|
|
2431
|
+
p_detail: sheet.querySelector("#report-detail").value.trim(),
|
|
2432
|
+
});
|
|
2433
|
+
closeSheet();
|
|
2434
|
+
toast("Report sent — thank you", "ok");
|
|
2435
|
+
} catch (err) { toast(err.message, "err"); b.disabled = false; }
|
|
2436
|
+
}));
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
</script>
|
|
2440
|
+
<script>
|
|
2441
|
+
|
|
2442
|
+
/* =======================================================================
|
|
2443
|
+
STORIES, CHATS, THREAD
|
|
2444
|
+
======================================================================= */
|
|
2445
|
+
async function loadStories() {
|
|
2446
|
+
try { state.stories = await api("yap_stories", { p_token: state.token }); }
|
|
2447
|
+
catch { state.stories = []; }
|
|
2448
|
+
renderStories();
|
|
2449
|
+
renderContext();
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
function renderStories() {
|
|
2453
|
+
const rail = $("#story-rail");
|
|
2454
|
+
if (!rail) return;
|
|
2455
|
+
const mine = state.stories.find((s) => s.is_me);
|
|
2456
|
+
const others = state.stories.filter((s) => !s.is_me);
|
|
2457
|
+
const hasLive = !!(mine && mine.items && mine.items.length);
|
|
2458
|
+
const meTile = `<button class="story" id="story-add" data-me="true" data-has="${hasLive ? "true" : "false"}" data-seen="${hasLive ? "false" : "true"}" aria-label="Your story">
|
|
2459
|
+
<div class="story-ring">
|
|
2460
|
+
${avatarHtml(state.me || { username: "me" })}
|
|
2461
|
+
<span class="story-plus"><svg class="ico"><use href="#i-plus"/></svg></span>
|
|
2462
|
+
</div>
|
|
2463
|
+
<div class="story-name">You</div>
|
|
2464
|
+
</button>`;
|
|
2465
|
+
const tiles = others.map((s) => `
|
|
2466
|
+
<button class="story" data-story="${esc(s.username)}" data-seen="${s.all_seen ? "true" : "false"}">
|
|
2467
|
+
<div class="story-ring">${avatarHtml(s)}</div>
|
|
2468
|
+
<div class="story-name">${esc(s.display_name || s.username)}</div>
|
|
2469
|
+
</button>`).join("");
|
|
2470
|
+
rail.innerHTML = meTile + tiles;
|
|
2471
|
+
rail.dataset.few = String(1 + others.length <= 6);
|
|
2472
|
+
$("#story-add").addEventListener("click", () => go("camera"));
|
|
2473
|
+
$$("[data-story]", rail).forEach((b) => b.addEventListener("click", () => openStory(b.dataset.story)));
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
function openStory(username) {
|
|
2477
|
+
const author = state.stories.find((s) => s.username === username);
|
|
2478
|
+
if (!author || !author.items?.length) return;
|
|
2479
|
+
state.storyList = author.items;
|
|
2480
|
+
state.storyIdx = 0;
|
|
2481
|
+
state.storyAuthor = author;
|
|
2482
|
+
$("#storyview").classList.add("on");
|
|
2483
|
+
renderStoryFrame();
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
const SNAP_TEXT_COLORS = ["#FFFFFF", "#000000", "#3CC8FF", "#2F6BFF", "#8FA8FF", "#A1A1A6"];
|
|
2487
|
+
const cleanTextColor = (c) => SNAP_TEXT_COLORS.includes(String(c || "").toUpperCase()) ? String(c).toUpperCase() : "#FFFFFF";
|
|
2488
|
+
const clamp01 = (n) => Math.max(0, Math.min(1, Number.isFinite(Number(n)) ? Number(n) : .5));
|
|
2489
|
+
const clampScale = (n) => Math.max(.55, Math.min(2.4, Number.isFinite(Number(n)) ? Number(n) : 1));
|
|
2490
|
+
function normalizeOverlayText(o) {
|
|
2491
|
+
return {
|
|
2492
|
+
t: String(o?.t ?? o?.text ?? "").slice(0, 160),
|
|
2493
|
+
x: clamp01(o?.x), y: clamp01(o?.y),
|
|
2494
|
+
scale: clampScale(o?.scale),
|
|
2495
|
+
color: cleanTextColor(o?.color),
|
|
2496
|
+
bar: !!o?.bar,
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
function overlayMarkup(o, cls, active = false) {
|
|
2500
|
+
const n = normalizeOverlayText(o);
|
|
2501
|
+
if (!n.t) return "";
|
|
2502
|
+
return `<div class="${cls}" data-bar="${n.bar}" data-active="${active}" data-scale="${n.scale}"
|
|
2503
|
+
style="left:${n.x * 100}%;top:${n.y * 100}%;--tx-color:${n.color};color:${n.color}"><span>${esc(n.t)}</span></div>`;
|
|
2504
|
+
}
|
|
2505
|
+
function sizeStoryTexts() {
|
|
2506
|
+
const wrap = $("#storyview .wrap");
|
|
2507
|
+
if (!wrap) return;
|
|
2508
|
+
const base = Math.max(22, Math.min(42, wrap.clientWidth * .075));
|
|
2509
|
+
$$("#storyview .story-text").forEach((el) => {
|
|
2510
|
+
el.style.fontSize = (base * clampScale(el.dataset.scale)) + "px";
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
function renderStoryFrame() {
|
|
2514
|
+
clearTimeout(storyTimer);
|
|
2515
|
+
const author = state.storyAuthor;
|
|
2516
|
+
const item = state.storyList[state.storyIdx];
|
|
2517
|
+
if (!item) return closeStory();
|
|
2518
|
+
let meta = item.meta;
|
|
2519
|
+
if (typeof meta === "string") { try { meta = JSON.parse(meta); } catch { meta = null; } }
|
|
2520
|
+
const texts = Array.isArray(meta?.texts) ? meta.texts : [];
|
|
2521
|
+
$("#storyview").innerHTML = `
|
|
2522
|
+
<div style="position:relative">
|
|
2523
|
+
<div class="bars">${state.storyList.map((_, i) => `<i class="${i < state.storyIdx ? "done" : i === state.storyIdx ? "live" : ""}"><b></b></i>`).join("")}</div>
|
|
2524
|
+
<div class="head">
|
|
2525
|
+
${avatarHtml(author, "sm")}
|
|
2526
|
+
<span class="name">${esc(author.display_name || author.username)}</span>
|
|
2527
|
+
<span class="mono" style="color:rgb(255 255 255 / .6)">${esc(fmtTime(item.created_at))}</span>
|
|
2528
|
+
<span style="flex:1"></span>
|
|
2529
|
+
<button class="iconbtn" id="story-close" aria-label="Close" style="color:#fff"><svg class="ico"><use href="#i-x"/></svg></button>
|
|
2530
|
+
</div>
|
|
2531
|
+
</div>
|
|
2532
|
+
<div class="wrap">
|
|
2533
|
+
<img src="${esc(item.image_url)}" alt="" />
|
|
2534
|
+
${texts.map((o) => overlayMarkup(o, "story-text")).join("")}
|
|
2535
|
+
<div class="nav"><div id="story-prev"></div><div id="story-next"></div></div>
|
|
2536
|
+
${item.caption ? `<div class="cap">${esc(item.caption)}</div>` : ""}
|
|
2537
|
+
</div>
|
|
2538
|
+
<div></div>`;
|
|
2539
|
+
sizeStoryTexts();
|
|
2540
|
+
$("#story-close").addEventListener("click", closeStory);
|
|
2541
|
+
$("#story-next").addEventListener("click", () => { if (!storyHeld) nextStoryFrame(); });
|
|
2542
|
+
$("#story-prev").addEventListener("click", () => {
|
|
2543
|
+
if (storyHeld) return;
|
|
2544
|
+
state.storyIdx = Math.max(0, state.storyIdx - 1);
|
|
2545
|
+
renderStoryFrame();
|
|
2546
|
+
});
|
|
2547
|
+
if (!item.seen) {
|
|
2548
|
+
api("yap_story_view", { p_token: state.token, p_story_id: item.id })
|
|
2549
|
+
.then(() => { item.seen = true; })
|
|
2550
|
+
.catch(() => {});
|
|
2551
|
+
}
|
|
2552
|
+
armStoryTimer();
|
|
2553
|
+
}
|
|
2554
|
+
function nextStoryFrame() {
|
|
2555
|
+
state.storyIdx += 1;
|
|
2556
|
+
if (state.storyIdx >= state.storyList.length) return closeStory();
|
|
2557
|
+
renderStoryFrame();
|
|
2558
|
+
}
|
|
2559
|
+
function closeStory() {
|
|
2560
|
+
clearTimeout(storyTimer);
|
|
2561
|
+
$("#storyview").classList.remove("on");
|
|
2562
|
+
$("#storyview").innerHTML = "";
|
|
2563
|
+
loadStories();
|
|
2564
|
+
}
|
|
2565
|
+
let storyTimer = 0, storyLeft = 6000, storyAt = 0, storyHeld = false;
|
|
2566
|
+
function armStoryTimer() {
|
|
2567
|
+
clearTimeout(storyTimer);
|
|
2568
|
+
storyLeft = 6000;
|
|
2569
|
+
storyAt = performance.now();
|
|
2570
|
+
storyTimer = setTimeout(nextStoryFrame, storyLeft);
|
|
2571
|
+
}
|
|
2572
|
+
function pauseStory() {
|
|
2573
|
+
if (!$("#storyview").classList.contains("on")) return;
|
|
2574
|
+
clearTimeout(storyTimer);
|
|
2575
|
+
storyLeft = Math.max(0, storyLeft - (performance.now() - storyAt));
|
|
2576
|
+
const b = $("#storyview .bars i.live b");
|
|
2577
|
+
if (b) b.style.animationPlayState = "paused";
|
|
2578
|
+
}
|
|
2579
|
+
function resumeStory() {
|
|
2580
|
+
if (!$("#storyview").classList.contains("on")) return;
|
|
2581
|
+
storyAt = performance.now();
|
|
2582
|
+
storyTimer = setTimeout(nextStoryFrame, Math.max(60, storyLeft));
|
|
2583
|
+
const b = $("#storyview .bars i.live b");
|
|
2584
|
+
if (b) b.style.animationPlayState = "running";
|
|
2585
|
+
}
|
|
2586
|
+
{
|
|
2587
|
+
const sv = $("#storyview");
|
|
2588
|
+
sv.addEventListener("pointerdown", (e) => {
|
|
2589
|
+
if (e.target.closest("button")) return;
|
|
2590
|
+
storyHeld = false;
|
|
2591
|
+
pauseStory();
|
|
2592
|
+
sv._heldAt = performance.now();
|
|
2593
|
+
});
|
|
2594
|
+
["pointerup", "pointercancel", "pointerleave"].forEach((ev) =>
|
|
2595
|
+
sv.addEventListener(ev, () => {
|
|
2596
|
+
if (sv._heldAt == null) return;
|
|
2597
|
+
storyHeld = performance.now() - sv._heldAt > 260;
|
|
2598
|
+
sv._heldAt = null;
|
|
2599
|
+
resumeStory();
|
|
2600
|
+
setTimeout(() => { storyHeld = false; }, 0);
|
|
2601
|
+
}));
|
|
2602
|
+
}
|
|
2603
|
+
$("#storyview").addEventListener("keydown", (e) => {
|
|
2604
|
+
if (e.key === "ArrowRight") nextStoryFrame();
|
|
2605
|
+
if (e.key === "ArrowLeft") { state.storyIdx = Math.max(0, state.storyIdx - 1); renderStoryFrame(); }
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2608
|
+
/* ------------------------------------------------------------------ inbox */
|
|
2609
|
+
// The inbox RPC can return the same peer twice: its synthetic support row is
|
|
2610
|
+
// de-duplicated by `union` on (peer_id, last_at), and that row carries NULL
|
|
2611
|
+
// for last_at, so it never collapses with the real support thread. Merge by
|
|
2612
|
+
// username here; nothing is deleted anywhere.
|
|
2613
|
+
function dedupeInbox(rows) {
|
|
2614
|
+
const byUser = new Map();
|
|
2615
|
+
for (const r of rows || []) {
|
|
2616
|
+
const cur = byUser.get(r.username);
|
|
2617
|
+
if (!cur) { byUser.set(r.username, { ...r }); continue; }
|
|
2618
|
+
const merged = { ...cur, ...r };
|
|
2619
|
+
merged.last = r.last || cur.last;
|
|
2620
|
+
merged.last_at = r.last_at || cur.last_at;
|
|
2621
|
+
merged.last_kind = r.last_kind || cur.last_kind;
|
|
2622
|
+
merged.last_from_me = r.last_from_me ?? cur.last_from_me;
|
|
2623
|
+
merged.unread = Math.max(cur.unread || 0, r.unread || 0);
|
|
2624
|
+
merged.streak = Math.max(cur.streak || 0, r.streak || 0);
|
|
2625
|
+
merged.pinned = !!(cur.pinned || r.pinned);
|
|
2626
|
+
byUser.set(r.username, merged);
|
|
2627
|
+
}
|
|
2628
|
+
return [...byUser.values()].sort((a, b) => {
|
|
2629
|
+
if (a.pinned !== b.pinned) return a.pinned ? -1 : 1;
|
|
2630
|
+
return new Date(b.last_at || 0) - new Date(a.last_at || 0);
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
async function loadInbox() {
|
|
2635
|
+
try {
|
|
2636
|
+
state.inbox = dedupeInbox(await api("yap_inbox", { p_token: state.token }));
|
|
2637
|
+
renderInbox();
|
|
2638
|
+
updateRouteChrome();
|
|
2639
|
+
} catch (err) {
|
|
2640
|
+
$("#inbox-list").innerHTML = emptyState("chat", "couldn't load chats", err.message);
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
function renderInbox() {
|
|
2645
|
+
const list = $("#inbox-list");
|
|
2646
|
+
if (!state.inbox.length) {
|
|
2647
|
+
list.innerHTML = emptyState("chat", "no conversations", "Find someone above and send the first yap. Streaks start with one.", "Find people", "inbox-cta");
|
|
2648
|
+
$("#inbox-cta").addEventListener("click", () => $("#people-search").focus());
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2651
|
+
list.innerHTML = state.inbox.map((c) => `
|
|
2652
|
+
<button class="chatrow spot" data-chat="${esc(c.username)}" data-active="${state.peer === c.username ? "true" : "false"}">
|
|
2653
|
+
${avatarHtml(c)}
|
|
2654
|
+
<div class="who">
|
|
2655
|
+
<div class="name-row">
|
|
2656
|
+
<span class="name">${esc(c.display_name || c.username)}</span>
|
|
2657
|
+
${c.is_support ? '<span class="badge support"><svg class="ico"><use href="#i-check"/></svg>support</span>' : ""}
|
|
2658
|
+
${!c.is_support && c.streak ? `<span class="streak" data-hot="${c.streak >= 3}"><svg class="ico"><use href="#i-flame"/></svg>${c.streak}</span>` : ""}
|
|
2659
|
+
</div>
|
|
2660
|
+
<div class="snippet">${c.last_from_me ? "You: " : ""}${esc(c.last || "say hi")}</div>
|
|
2661
|
+
</div>
|
|
2662
|
+
<div class="end">
|
|
2663
|
+
<span class="time">${c.last_at ? esc(fmtTime(c.last_at)) : ""}</span>
|
|
2664
|
+
${c.unread ? `<span class="unread">${c.unread > 9 ? "9+" : c.unread}</span>` : ""}
|
|
2665
|
+
</div>
|
|
2666
|
+
</button>`).join("");
|
|
2667
|
+
$$("[data-chat]", list).forEach((b) => b.addEventListener("click", () => openThread(b.dataset.chat)));
|
|
2668
|
+
wireSpotlights(list);
|
|
2669
|
+
const unread = state.inbox.reduce((n, c) => n + (c.unread || 0), 0);
|
|
2670
|
+
["#rail-badge", "#tab-badge"].forEach((sel) => {
|
|
2671
|
+
const b = $(sel);
|
|
2672
|
+
if (!b) return;
|
|
2673
|
+
b.textContent = unread > 9 ? "9+" : unread;
|
|
2674
|
+
b.classList.toggle("hidden", !unread);
|
|
2675
|
+
});
|
|
2676
|
+
renderContext();
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
let peopleTimer = 0;
|
|
2680
|
+
$("#people-search").addEventListener("input", (e) => {
|
|
2681
|
+
clearTimeout(peopleTimer);
|
|
2682
|
+
const q = e.target.value.trim();
|
|
2683
|
+
peopleTimer = setTimeout(async () => {
|
|
2684
|
+
const box = $("#people-results");
|
|
2685
|
+
if (!q) { box.innerHTML = ""; return; }
|
|
2686
|
+
try {
|
|
2687
|
+
const rows = await api("yap_search_users", { p_token: state.token, p_q: q });
|
|
2688
|
+
box.innerHTML = rows.length ? rows.map((p) => `
|
|
2689
|
+
<button class="chatrow spot" data-found="${esc(p.username)}">
|
|
2690
|
+
${avatarHtml(p)}
|
|
2691
|
+
<div class="who">
|
|
2692
|
+
<div class="name">${esc(p.display_name || p.username)}</div>
|
|
2693
|
+
<div class="snippet">@${esc(p.username)}${p.is_support ? " · support" : ""}</div>
|
|
2694
|
+
</div>
|
|
2695
|
+
<span class="btn sm ghost">Yap</span>
|
|
2696
|
+
</button>`).join("") : `<p class="small" style="color:var(--tx-3);padding:12px">No one by that name.</p>`;
|
|
2697
|
+
$$("[data-found]", box).forEach((b) => b.addEventListener("click", () => {
|
|
2698
|
+
$("#people-search").value = "";
|
|
2699
|
+
box.innerHTML = "";
|
|
2700
|
+
openThread(b.dataset.found);
|
|
2701
|
+
}));
|
|
2702
|
+
wireSpotlights(box);
|
|
2703
|
+
} catch (err) { toast(err.message, "err"); }
|
|
2704
|
+
}, 260);
|
|
2705
|
+
});
|
|
2706
|
+
|
|
2707
|
+
/* ----------------------------------------------------------------- thread */
|
|
2708
|
+
async function openThread(username) {
|
|
2709
|
+
state.peer = username;
|
|
2710
|
+
go("thread");
|
|
2711
|
+
$$("[data-chat]").forEach((b) => b.dataset.active = String(b.dataset.chat === username));
|
|
2712
|
+
$("#thread-list").innerHTML = `<div class="thread-scroll-inner"><div class="skeleton"><i style="width:50%"></i><i style="width:70%"></i><i style="width:40%"></i></div></div>`;
|
|
2713
|
+
$("#thread-input").value = "";
|
|
2714
|
+
syncThreadBar();
|
|
2715
|
+
try {
|
|
2716
|
+
const t = await api("yap_thread", { p_token: state.token, p_peer: username });
|
|
2717
|
+
state.thread = t;
|
|
2718
|
+
renderThread();
|
|
2719
|
+
loadInbox();
|
|
2720
|
+
} catch (err) {
|
|
2721
|
+
$("#thread-list").innerHTML = emptyState("chat", "couldn't open that", err.message);
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
function renderThread() {
|
|
2726
|
+
const t = state.thread;
|
|
2727
|
+
const peer = t.peer || { username: state.peer, display_name: state.peer };
|
|
2728
|
+
$("#thread-head").innerHTML = `${avatarHtml(peer, "sm")}
|
|
2729
|
+
<div style="min-width:0">
|
|
2730
|
+
<div class="name">${esc(peer.display_name || peer.username)}
|
|
2731
|
+
${peer.is_verified ? '<span class="badge verified"><svg class="ico"><use href="#i-check"/></svg>verified</span>' : ""}
|
|
2732
|
+
${peer.is_support ? '<span class="badge support">support</span>' : ""}
|
|
2733
|
+
</div>
|
|
2734
|
+
<div class="handle">@${esc(peer.username)}</div>
|
|
2735
|
+
</div>`;
|
|
2736
|
+
$("#thread-streak").innerHTML = t.streak
|
|
2737
|
+
? `<svg class="ico"><use href="#i-flame"/></svg>${t.streak} day${t.streak === 1 ? "" : "s"}`
|
|
2738
|
+
: "";
|
|
2739
|
+
|
|
2740
|
+
const rows = t.messages || [];
|
|
2741
|
+
if (!rows.length) {
|
|
2742
|
+
$("#thread-list").innerHTML = emptyState("plane", "no yaps yet", `Say something to @${peer.username}. Yaps clear after 24 hours.`);
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2745
|
+
const out = [];
|
|
2746
|
+
let lastDay = "";
|
|
2747
|
+
rows.forEach((m, i) => {
|
|
2748
|
+
const day = dayKey(m.created_at);
|
|
2749
|
+
if (day !== lastDay) { out.push(`<div class="day-sep">${esc(dayLabel(m.created_at))}</div>`); lastDay = day; }
|
|
2750
|
+
const prev = rows[i - 1], next = rows[i + 1];
|
|
2751
|
+
const samePrev = prev && prev.from_me === m.from_me && dayKey(prev.created_at) === day;
|
|
2752
|
+
const sameNext = next && next.from_me === m.from_me && dayKey(next.created_at) === day;
|
|
2753
|
+
const group = !samePrev && !sameNext ? "solo" : samePrev && sameNext ? "mid" : samePrev ? "last" : "first";
|
|
2754
|
+
out.push(bubbleHtml(m, group, i === rows.length - 1));
|
|
2755
|
+
});
|
|
2756
|
+
$("#thread-list").innerHTML = `<div class="thread-scroll-inner">${out.join("")}</div>`;
|
|
2757
|
+
$$("#thread-list [data-open-dm]").forEach((b) => b.addEventListener("click", () => viewDm(b.dataset.openDm)));
|
|
2758
|
+
const scroller = $("#thread-list");
|
|
2759
|
+
scroller.scrollTop = scroller.scrollHeight;
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
function bubbleHtml(m, group, isLast) {
|
|
2763
|
+
const when = `<span class="when">${esc(fmtTime(m.created_at))}</span>`;
|
|
2764
|
+
if (m.kind === "photo") {
|
|
2765
|
+
if (m.from_me) return `<div class="bubble me photo" data-group="${group}"><svg class="ico" style="width:16px;height:16px"><use href="#i-cam"/></svg>Photo yap${when}</div>`;
|
|
2766
|
+
if (m.locked) return `<button class="bubble locked" data-open-dm="${esc(m.id)}" data-group="${group}">
|
|
2767
|
+
<span class="locked-row"><svg class="ico"><use href="#i-cam"/></svg>Tap to view photo</span>
|
|
2768
|
+
<span class="locked-sub">disappears once opened</span>${when}</button>`;
|
|
2769
|
+
return `<div class="bubble photo" data-group="${group}"><svg class="ico" style="width:16px;height:16px"><use href="#i-cam"/></svg>Photo yap${when}</div>`;
|
|
2770
|
+
}
|
|
2771
|
+
const body = `<span>${esc(m.body || "")}</span>${when}`;
|
|
2772
|
+
if (!m.from_me) return `<div class="bubble" data-group="${group}">${body}</div>`;
|
|
2773
|
+
const stateLine = isLast
|
|
2774
|
+
? `<div class="thread-state">${m.viewed ? "opened" : "sent"}<svg class="ico" style="width:12px;height:12px"><use href="#i-${m.viewed ? "check" : "send"}"/></svg></div>`
|
|
2775
|
+
: "";
|
|
2776
|
+
return `<div class="bubble me" data-group="${group}">${body}</div>${stateLine}`;
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
async function viewDm(id) {
|
|
2780
|
+
try {
|
|
2781
|
+
const src = await api("yap_view_dm", { p_token: state.token, p_dm_id: id });
|
|
2782
|
+
const sheet = openSheet(`<h3>Photo yap</h3>
|
|
2783
|
+
<div><img src="${esc(src)}" alt="" style="border-radius:var(--r-3);width:100%" /></div>
|
|
2784
|
+
<p class="hint" style="justify-content:center;margin-top:10px">Opened — it's gone now.</p>`);
|
|
2785
|
+
void sheet;
|
|
2786
|
+
await openThread(state.peer);
|
|
2787
|
+
} catch (err) { toast(err.message, "err"); }
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
function syncThreadBar() {
|
|
2791
|
+
const input = $("#thread-input");
|
|
2792
|
+
const typing = input.value.trim().length > 0;
|
|
2793
|
+
$("#threadbar").dataset.typing = String(typing);
|
|
2794
|
+
const send = $("#thread-send");
|
|
2795
|
+
send.dataset.empty = String(!typing);
|
|
2796
|
+
send.disabled = !typing;
|
|
2797
|
+
input.style.height = "auto";
|
|
2798
|
+
input.style.height = Math.min(input.scrollHeight, 160) + "px";
|
|
2799
|
+
}
|
|
2800
|
+
$("#thread-input").addEventListener("input", syncThreadBar);
|
|
2801
|
+
$("#thread-input").addEventListener("keydown", (e) => {
|
|
2802
|
+
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); sendThread(); }
|
|
2803
|
+
});
|
|
2804
|
+
|
|
2805
|
+
async function sendThread() {
|
|
2806
|
+
const input = $("#thread-input");
|
|
2807
|
+
const body = input.value.trim();
|
|
2808
|
+
if (!body) return;
|
|
2809
|
+
input.value = "";
|
|
2810
|
+
syncThreadBar();
|
|
2811
|
+
const inner = $("#thread-list .thread-scroll-inner");
|
|
2812
|
+
if (inner) {
|
|
2813
|
+
const el = document.createElement("div");
|
|
2814
|
+
el.className = "bubble me";
|
|
2815
|
+
el.dataset.group = "solo";
|
|
2816
|
+
el.style.opacity = "0.6";
|
|
2817
|
+
el.innerHTML = `<span>${esc(body)}</span>`;
|
|
2818
|
+
inner.appendChild(el);
|
|
2819
|
+
if (!REDUCED()) {
|
|
2820
|
+
el.animate([{ opacity: 0, transform: "translateY(10px) scale(.8)" }, { opacity: 0.6, transform: "none" }], { duration: 320, easing: "cubic-bezier(.34,1.56,.64,1)" });
|
|
2821
|
+
const send = $("#thread-send svg");
|
|
2822
|
+
if (send) send.animate([{ transform: "none" }, { transform: "translate(3px,-3px) rotate(12deg)" }, { transform: "none" }], { duration: 300, easing: EASE });
|
|
2823
|
+
}
|
|
2824
|
+
const scroller = $("#thread-list");
|
|
2825
|
+
scroller.scrollTop = scroller.scrollHeight;
|
|
2826
|
+
}
|
|
2827
|
+
try {
|
|
2828
|
+
await api("yap_send_yap", { p_token: state.token, p_to: state.peer, p_kind: "text", p_body: body });
|
|
2829
|
+
await openThread(state.peer);
|
|
2830
|
+
} catch (err) {
|
|
2831
|
+
toast(err.message, "err");
|
|
2832
|
+
input.value = body;
|
|
2833
|
+
syncThreadBar();
|
|
2834
|
+
await openThread(state.peer);
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
$("#thread-send").addEventListener("click", sendThread);
|
|
2838
|
+
$("#thread-back").addEventListener("click", () => { go("chats"); loadInbox(); });
|
|
2839
|
+
|
|
2840
|
+
const threadPhoto = document.createElement("input");
|
|
2841
|
+
threadPhoto.type = "file";
|
|
2842
|
+
threadPhoto.accept = "image/*";
|
|
2843
|
+
threadPhoto.hidden = true;
|
|
2844
|
+
threadPhoto.className = "hidden";
|
|
2845
|
+
document.body.appendChild(threadPhoto);
|
|
2846
|
+
$("#thread-cam").addEventListener("click", () => threadPhoto.click());
|
|
2847
|
+
threadPhoto.addEventListener("change", async (e) => {
|
|
2848
|
+
const file = e.target.files[0];
|
|
2849
|
+
e.target.value = "";
|
|
2850
|
+
if (!file) return;
|
|
2851
|
+
try {
|
|
2852
|
+
const bitmap = await createImageBitmap(file);
|
|
2853
|
+
const canvas = document.createElement("canvas");
|
|
2854
|
+
canvas.width = 960; canvas.height = 1280;
|
|
2855
|
+
const ctx = canvas.getContext("2d");
|
|
2856
|
+
const scale = Math.max(960 / bitmap.width, 1280 / bitmap.height);
|
|
2857
|
+
const w = bitmap.width * scale, h = bitmap.height * scale;
|
|
2858
|
+
ctx.drawImage(bitmap, (960 - w) / 2, (1280 - h) / 2, w, h);
|
|
2859
|
+
await api("yap_send_yap", {
|
|
2860
|
+
p_token: state.token, p_to: state.peer, p_kind: "photo",
|
|
2861
|
+
p_image_data: canvas.toDataURL("image/jpeg", 0.7), p_filter: "none",
|
|
2862
|
+
});
|
|
2863
|
+
toast("Photo yap sent", "ok");
|
|
2864
|
+
await openThread(state.peer);
|
|
2865
|
+
} catch (err) { toast(err.message, "err"); }
|
|
2866
|
+
});
|
|
2867
|
+
|
|
2868
|
+
</script>
|
|
2869
|
+
<script>
|
|
2870
|
+
|
|
2871
|
+
/* =======================================================================
|
|
2872
|
+
CAMERA
|
|
2873
|
+
======================================================================= */
|
|
2874
|
+
const FILTERS = [
|
|
2875
|
+
{ id: "none", label: "None", css: "none" },
|
|
2876
|
+
{ id: "warm", label: "Warm", css: "saturate(1.25) sepia(0.18) hue-rotate(-12deg)" },
|
|
2877
|
+
{ id: "cool", label: "Cool", css: "saturate(1.2) hue-rotate(18deg) brightness(1.04)" },
|
|
2878
|
+
{ id: "noir", label: "Noir", css: "grayscale(1) contrast(1.18)" },
|
|
2879
|
+
{ id: "vivid", label: "Vivid", css: "saturate(1.75) contrast(1.12)" },
|
|
2880
|
+
{ id: "fade", label: "Fade", css: "saturate(0.8) brightness(1.08) contrast(0.92)" },
|
|
2881
|
+
{ id: "dream", label: "Dream", css: "blur(0.6px) saturate(1.3) brightness(1.06)" },
|
|
2882
|
+
{ id: "toxic", label: "Toxic", css: "hue-rotate(70deg) saturate(1.5)" },
|
|
2883
|
+
];
|
|
2884
|
+
|
|
2885
|
+
function renderFilters() {
|
|
2886
|
+
const row = $("#filter-row");
|
|
2887
|
+
row.innerHTML = FILTERS.map((f) => `
|
|
2888
|
+
<button class="fchip" data-filter="${f.id}" data-on="${state.filter === f.id}" role="radio" aria-checked="${state.filter === f.id}">
|
|
2889
|
+
<span class="fswatch" style="filter:${f.css}"></span>${esc(f.label)}
|
|
2890
|
+
</button>`).join("");
|
|
2891
|
+
$$("#filter-row [data-filter]").forEach((b) => b.addEventListener("click", () => {
|
|
2892
|
+
setFilter(b.dataset.filter);
|
|
2893
|
+
}));
|
|
2894
|
+
$$("#filter-row [data-filter]").forEach((b) => b.addEventListener("keydown", (e) => {
|
|
2895
|
+
const i = FILTERS.findIndex((f) => f.id === b.dataset.filter);
|
|
2896
|
+
if (e.key === "ArrowRight") { e.preventDefault(); setFilter(FILTERS[(i + 1) % FILTERS.length].id, true); }
|
|
2897
|
+
if (e.key === "ArrowLeft") { e.preventDefault(); setFilter(FILTERS[(i - 1 + FILTERS.length) % FILTERS.length].id, true); }
|
|
2898
|
+
}));
|
|
2899
|
+
}
|
|
2900
|
+
function setFilter(id, focus = false) {
|
|
2901
|
+
state.filter = id;
|
|
2902
|
+
$$("#filter-row [data-filter]").forEach((b) => {
|
|
2903
|
+
const on = b.dataset.filter === id;
|
|
2904
|
+
b.dataset.on = String(on);
|
|
2905
|
+
b.setAttribute("aria-checked", String(on));
|
|
2906
|
+
if (on && focus) b.focus();
|
|
2907
|
+
});
|
|
2908
|
+
applyPreviewFilter();
|
|
2909
|
+
}
|
|
2910
|
+
const filterCss = () => (FILTERS.find((f) => f.id === state.filter) || FILTERS[0]).css;
|
|
2911
|
+
const applyPreviewFilter = () => {
|
|
2912
|
+
const v = $("#cam-video");
|
|
2913
|
+
const s = $("#cam-shot");
|
|
2914
|
+
if (v) v.style.filter = filterCss();
|
|
2915
|
+
if (s) s.style.filter = filterCss();
|
|
2916
|
+
};
|
|
2917
|
+
|
|
2918
|
+
function showCamBlocked(err) {
|
|
2919
|
+
state.camError = err;
|
|
2920
|
+
const box = $("#cam-box");
|
|
2921
|
+
box.dataset.blocked = "true";
|
|
2922
|
+
box.dataset.live = "false";
|
|
2923
|
+
$("#cam-empty").classList.remove("hidden");
|
|
2924
|
+
$("#cam-video").classList.add("hidden");
|
|
2925
|
+
const name = (err && err.name) || "NotAllowedError";
|
|
2926
|
+
const copy = {
|
|
2927
|
+
NotAllowedError: "Your browser is holding the lens back. Allow camera access in the address bar — or drop a photo in instead.",
|
|
2928
|
+
NotFoundError: "No camera turned up on this machine. You can still upload a photo.",
|
|
2929
|
+
NotReadableError: "Something else is already using the camera. Close it and try again, or upload a photo.",
|
|
2930
|
+
SecurityError: "This page can't reach the camera. Upload a photo instead.",
|
|
2931
|
+
}[name] || "The camera didn't start. You can still upload a photo.";
|
|
2932
|
+
$("#cam-empty-copy").textContent = copy;
|
|
2933
|
+
$("#cam-empty-title").textContent = name === "NotFoundError" ? "no camera here" : "camera's blocked";
|
|
2934
|
+
$("#cam-empty-detail").textContent = name + (err && err.message ? "\n" + err.message : "");
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
async function startCamera() {
|
|
2938
|
+
renderFilters();
|
|
2939
|
+
if (state.camStream || state.camReview) return;
|
|
2940
|
+
/* NotSupportedError will not heal between automatic re-entries (headless or
|
|
2941
|
+
no camera API); keep the upload fallback quiet. The explicit retry button
|
|
2942
|
+
clears camError first, so users can still force another attempt. */
|
|
2943
|
+
if (state.camError?.name === "NotSupportedError") { showCamBlocked(state.camError); return; }
|
|
2944
|
+
const video = $("#cam-video");
|
|
2945
|
+
try {
|
|
2946
|
+
state.camStream = await navigator.mediaDevices.getUserMedia({
|
|
2947
|
+
video: { facingMode: "user", width: { ideal: 1080 }, height: { ideal: 1440 } },
|
|
2948
|
+
audio: false,
|
|
2949
|
+
});
|
|
2950
|
+
video.srcObject = state.camStream;
|
|
2951
|
+
video.classList.remove("hidden");
|
|
2952
|
+
$("#cam-empty").classList.add("hidden");
|
|
2953
|
+
$("#cam-box").dataset.blocked = "false";
|
|
2954
|
+
$("#cam-box").dataset.live = "true";
|
|
2955
|
+
applyPreviewFilter();
|
|
2956
|
+
} catch (err) {
|
|
2957
|
+
console.error("[yap] camera:", err.name, err.message);
|
|
2958
|
+
showCamBlocked(err);
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
function stopCamera() {
|
|
2962
|
+
if (state.camStream) {
|
|
2963
|
+
state.camStream.getTracks().forEach((t) => t.stop());
|
|
2964
|
+
state.camStream = null;
|
|
2965
|
+
const v = $("#cam-video");
|
|
2966
|
+
if (v) v.srcObject = null;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
function drawShot(source, w, h) {
|
|
2971
|
+
const canvas = document.createElement("canvas");
|
|
2972
|
+
canvas.width = w; canvas.height = h;
|
|
2973
|
+
const ctx = canvas.getContext("2d");
|
|
2974
|
+
const srcW = source.videoWidth || source.naturalWidth || source.width || w;
|
|
2975
|
+
const srcH = source.videoHeight || source.naturalHeight || source.height || h;
|
|
2976
|
+
const target = w / h;
|
|
2977
|
+
let sw = srcW, sh = srcH, sx = 0, sy = 0;
|
|
2978
|
+
if (srcW / srcH > target) { sh = srcH; sw = srcH * target; sx = (srcW - sw) / 2; }
|
|
2979
|
+
else { sw = srcW; sh = srcW / target; sy = (srcH - sh) / 2; }
|
|
2980
|
+
try { ctx.filter = filterCss(); } catch { /* older browsers ignore canvas filters */ }
|
|
2981
|
+
ctx.drawImage(source, sx, sy, sw, sh, 0, 0, w, h);
|
|
2982
|
+
return canvas;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
function flash() {
|
|
2986
|
+
const f = $("#cam-flash");
|
|
2987
|
+
f.dataset.go = "false";
|
|
2988
|
+
void f.offsetWidth;
|
|
2989
|
+
f.dataset.go = "true";
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
/* ------------------------------------------------------------ snap text */
|
|
2993
|
+
const camTextBase = () => Math.max(22, Math.min(40, ($("#cam-box")?.clientWidth || 420) * .075));
|
|
2994
|
+
const camTextById = (id) => state.camTexts.find((o) => o.id === id);
|
|
2995
|
+
const activeCamText = () => camTextById(state.activeTextId) || state.camTexts[state.camTexts.length - 1] || null;
|
|
2996
|
+
|
|
2997
|
+
function camTextMarkup(o) {
|
|
2998
|
+
const n = normalizeOverlayText(o);
|
|
2999
|
+
const active = state.activeTextId === o.id;
|
|
3000
|
+
if (!n.t) return "";
|
|
3001
|
+
return `<div class="snap-text" data-text-id="${esc(o.id)}" data-bar="${n.bar}" data-active="${active}" data-scale="${n.scale}"
|
|
3002
|
+
style="left:${n.x * 100}%;top:${n.y * 100}%;--tx-color:${n.color};color:${n.color};font-size:${camTextBase() * n.scale}px">
|
|
3003
|
+
<span>${esc(n.t)}</span><button class="snap-text-remove" type="button" aria-label="Remove text">×</button>
|
|
3004
|
+
</div>`;
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
function renderCamTextColors() {
|
|
3008
|
+
const box = $("#cam-text-colors");
|
|
3009
|
+
if (!box || box.dataset.ready) return;
|
|
3010
|
+
box.dataset.ready = "1";
|
|
3011
|
+
box.innerHTML = SNAP_TEXT_COLORS.map((c) => `<button class="cam-color" type="button" data-color="${c}" style="--swatch:${c}" aria-label="Text color ${c}"></button>`).join("");
|
|
3012
|
+
box.querySelectorAll("[data-color]").forEach((b) => b.addEventListener("click", () => {
|
|
3013
|
+
mutateActiveText((o) => { o.color = b.dataset.color; });
|
|
3014
|
+
}));
|
|
3015
|
+
}
|
|
3016
|
+
function syncCamTextControls() {
|
|
3017
|
+
const o = activeCamText();
|
|
3018
|
+
$$("#cam-text-colors [data-color]").forEach((b) => { b.dataset.on = String(!!o && cleanTextColor(o.color) === b.dataset.color); });
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
function renderCamTexts() {
|
|
3022
|
+
const layer = $("#cam-text-layer");
|
|
3023
|
+
if (!layer) return;
|
|
3024
|
+
layer.innerHTML = state.camReview ? state.camTexts.map(camTextMarkup).join("") : "";
|
|
3025
|
+
$$(".snap-text", layer).forEach((el) => {
|
|
3026
|
+
const id = el.dataset.textId;
|
|
3027
|
+
const remove = el.querySelector(".snap-text-remove");
|
|
3028
|
+
remove.addEventListener("pointerdown", (e) => e.stopPropagation());
|
|
3029
|
+
remove.addEventListener("click", (e) => {
|
|
3030
|
+
e.stopPropagation();
|
|
3031
|
+
state.camTexts = state.camTexts.filter((o) => o.id !== id);
|
|
3032
|
+
if (state.activeTextId === id) state.activeTextId = state.camTexts[state.camTexts.length - 1]?.id || null;
|
|
3033
|
+
renderCamTexts();
|
|
3034
|
+
});
|
|
3035
|
+
el.addEventListener("pointerdown", (e) => startTextDrag(e, id, el));
|
|
3036
|
+
});
|
|
3037
|
+
syncCamTextControls();
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
function startTextDrag(e, id, el) {
|
|
3041
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
3042
|
+
if (e.target.closest("button,textarea,input")) return;
|
|
3043
|
+
const o = camTextById(id);
|
|
3044
|
+
if (!o) return;
|
|
3045
|
+
e.preventDefault();
|
|
3046
|
+
state.activeTextId = id;
|
|
3047
|
+
$$("#cam-text-layer .snap-text").forEach((x) => { x.dataset.active = String(x === el); });
|
|
3048
|
+
syncCamTextControls();
|
|
3049
|
+
const rect = $("#cam-box").getBoundingClientRect();
|
|
3050
|
+
const startX = e.clientX, startY = e.clientY;
|
|
3051
|
+
const ox = clamp01(o.x), oy = clamp01(o.y);
|
|
3052
|
+
let moved = false;
|
|
3053
|
+
try { el.setPointerCapture(e.pointerId); } catch { /* capture is best-effort */ }
|
|
3054
|
+
const move = (ev) => {
|
|
3055
|
+
const dx = ev.clientX - startX, dy = ev.clientY - startY;
|
|
3056
|
+
if (Math.hypot(dx, dy) > 4) moved = true;
|
|
3057
|
+
if (!moved) return;
|
|
3058
|
+
o.x = clamp01(ox + dx / Math.max(1, rect.width));
|
|
3059
|
+
o.y = clamp01(oy + dy / Math.max(1, rect.height));
|
|
3060
|
+
el.style.left = o.x * 100 + "%";
|
|
3061
|
+
el.style.top = o.y * 100 + "%";
|
|
3062
|
+
};
|
|
3063
|
+
const up = () => {
|
|
3064
|
+
el.removeEventListener("pointermove", move);
|
|
3065
|
+
el.removeEventListener("pointerup", up);
|
|
3066
|
+
el.removeEventListener("pointercancel", up);
|
|
3067
|
+
if (!moved) editCamText(id);
|
|
3068
|
+
else renderCamTexts();
|
|
3069
|
+
};
|
|
3070
|
+
el.addEventListener("pointermove", move);
|
|
3071
|
+
el.addEventListener("pointerup", up);
|
|
3072
|
+
el.addEventListener("pointercancel", up);
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
function editCamText(id) {
|
|
3076
|
+
const o = camTextById(id);
|
|
3077
|
+
if (!o || !state.camReview) return;
|
|
3078
|
+
state.activeTextId = id;
|
|
3079
|
+
renderCamTexts();
|
|
3080
|
+
const layer = $("#cam-text-layer");
|
|
3081
|
+
const input = document.createElement("textarea");
|
|
3082
|
+
input.className = "snap-text-input";
|
|
3083
|
+
input.maxLength = 160;
|
|
3084
|
+
input.rows = 1;
|
|
3085
|
+
input.placeholder = "type something";
|
|
3086
|
+
input.value = o.t || "";
|
|
3087
|
+
input.dataset.bar = String(!!o.bar);
|
|
3088
|
+
input.style.left = clamp01(o.x) * 100 + "%";
|
|
3089
|
+
input.style.top = clamp01(o.y) * 100 + "%";
|
|
3090
|
+
input.style.setProperty("--tx-color", cleanTextColor(o.color));
|
|
3091
|
+
input.style.color = cleanTextColor(o.color);
|
|
3092
|
+
input.style.fontSize = camTextBase() * clampScale(o.scale) + "px";
|
|
3093
|
+
input.addEventListener("pointerdown", (e) => e.stopPropagation());
|
|
3094
|
+
const fit = () => {
|
|
3095
|
+
input.style.height = "auto";
|
|
3096
|
+
input.style.height = Math.max(42, input.scrollHeight) + "px";
|
|
3097
|
+
};
|
|
3098
|
+
let done = false, cancelled = false;
|
|
3099
|
+
const finish = () => {
|
|
3100
|
+
if (done) return;
|
|
3101
|
+
done = true;
|
|
3102
|
+
const value = cancelled ? (o.t || "") : input.value.trim();
|
|
3103
|
+
if (value) {
|
|
3104
|
+
o.t = value;
|
|
3105
|
+
} else {
|
|
3106
|
+
state.camTexts = state.camTexts.filter((x) => x.id !== id);
|
|
3107
|
+
if (state.activeTextId === id) state.activeTextId = null;
|
|
3108
|
+
}
|
|
3109
|
+
renderCamTexts();
|
|
3110
|
+
};
|
|
3111
|
+
input.addEventListener("input", fit);
|
|
3112
|
+
input.addEventListener("keydown", (e) => {
|
|
3113
|
+
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); finish(); }
|
|
3114
|
+
if (e.key === "Escape") { e.preventDefault(); cancelled = true; finish(); }
|
|
3115
|
+
});
|
|
3116
|
+
input.addEventListener("blur", finish);
|
|
3117
|
+
layer.appendChild(input);
|
|
3118
|
+
fit();
|
|
3119
|
+
input.focus();
|
|
3120
|
+
input.select();
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
function addCamText() {
|
|
3124
|
+
if (!state.camReview) return;
|
|
3125
|
+
const o = {
|
|
3126
|
+
id: crypto.randomUUID ? crypto.randomUUID() : "t" + Date.now() + Math.random().toString(16).slice(2),
|
|
3127
|
+
t: "", x: .5, y: .42, scale: 1, color: "#FFFFFF", bar: false,
|
|
3128
|
+
};
|
|
3129
|
+
state.camTexts.push(o);
|
|
3130
|
+
state.activeTextId = o.id;
|
|
3131
|
+
renderCamTexts();
|
|
3132
|
+
editCamText(o.id);
|
|
3133
|
+
}
|
|
3134
|
+
function mutateActiveText(fn) {
|
|
3135
|
+
const o = activeCamText();
|
|
3136
|
+
if (!o) { toast("Add text first", "err"); return; }
|
|
3137
|
+
state.activeTextId = o.id;
|
|
3138
|
+
fn(o);
|
|
3139
|
+
renderCamTexts();
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
renderCamTextColors();
|
|
3143
|
+
$("#cam-text-add").addEventListener("click", addCamText);
|
|
3144
|
+
$("#cam-text-style").addEventListener("click", () => mutateActiveText((o) => { o.bar = !o.bar; }));
|
|
3145
|
+
$("#cam-text-plus").addEventListener("click", () => mutateActiveText((o) => { o.scale = clampScale(o.scale + .12); }));
|
|
3146
|
+
$("#cam-text-minus").addEventListener("click", () => mutateActiveText((o) => { o.scale = clampScale(o.scale - .12); }));
|
|
3147
|
+
$("#cam-box").addEventListener("wheel", (e) => {
|
|
3148
|
+
if (!state.camReview || !activeCamText() || e.target.closest("textarea,input")) return;
|
|
3149
|
+
e.preventDefault();
|
|
3150
|
+
mutateActiveText((o) => { o.scale = clampScale(o.scale + (e.deltaY < 0 ? .07 : -.07)); });
|
|
3151
|
+
}, { passive: false });
|
|
3152
|
+
document.addEventListener("keydown", (e) => {
|
|
3153
|
+
const typing = e.target.closest?.("input,textarea,[contenteditable='true']");
|
|
3154
|
+
if (typing || state.view !== "camera" || !state.camReview) return;
|
|
3155
|
+
if (e.key.toLowerCase() === "t") { e.preventDefault(); addCamText(); }
|
|
3156
|
+
if (e.key === "+" || e.key === "=") mutateActiveText((o) => { o.scale = clampScale(o.scale + .12); });
|
|
3157
|
+
if (e.key === "-" || e.key === "_") mutateActiveText((o) => { o.scale = clampScale(o.scale - .12); });
|
|
3158
|
+
});
|
|
3159
|
+
window.addEventListener("resize", () => { if (state.camReview) renderCamTexts(); sizeStoryTexts(); });
|
|
3160
|
+
|
|
3161
|
+
function setReview(on) {
|
|
3162
|
+
state.camReview = on;
|
|
3163
|
+
$("#cam-box").dataset.review = String(on);
|
|
3164
|
+
$("#cam-shot").classList.toggle("hidden", !on);
|
|
3165
|
+
$("#cam-video").classList.toggle("hidden", on);
|
|
3166
|
+
$("#cam-cap").textContent = on ? $("#cap-input").value : "";
|
|
3167
|
+
$("#cap-input").classList.toggle("hidden", !on);
|
|
3168
|
+
if (on) {
|
|
3169
|
+
/* Uploading while the camera is blocked must enter the exact same review
|
|
3170
|
+
surface as a capture: no empty-state panel covering the photo. */
|
|
3171
|
+
$("#cam-empty").classList.add("hidden");
|
|
3172
|
+
$("#cam-box").dataset.blocked = "false";
|
|
3173
|
+
$("#cam-box").dataset.live = "true";
|
|
3174
|
+
}
|
|
3175
|
+
renderCamTexts();
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
function clearCaption() {
|
|
3179
|
+
$("#cap-input").value = "";
|
|
3180
|
+
$("#cam-cap").textContent = "";
|
|
3181
|
+
}
|
|
3182
|
+
function clearCamTexts() {
|
|
3183
|
+
state.camTexts = [];
|
|
3184
|
+
state.activeTextId = null;
|
|
3185
|
+
renderCamTexts();
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
function enterReview(canvas) {
|
|
3189
|
+
state.shot = canvas.toDataURL("image/jpeg", 0.72);
|
|
3190
|
+
state.shotBlob = null;
|
|
3191
|
+
canvas.toBlob((blob) => { state.shotBlob = blob; }, "image/jpeg", 0.72);
|
|
3192
|
+
$("#cam-shot").src = state.shot;
|
|
3193
|
+
state.hasShotOnce = true;
|
|
3194
|
+
clearCaption();
|
|
3195
|
+
clearCamTexts();
|
|
3196
|
+
setReview(true);
|
|
3197
|
+
$("#cam-send").disabled = false;
|
|
3198
|
+
$("#cam-story").disabled = false;
|
|
3199
|
+
applyPreviewFilter();
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
function takeShot() {
|
|
3203
|
+
const video = $("#cam-video");
|
|
3204
|
+
if (!video.videoWidth) {
|
|
3205
|
+
toast("Camera is not ready yet — upload a photo instead.", "err");
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
flash();
|
|
3209
|
+
enterReview(drawShot(video, 1080, 1440));
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
function retake() {
|
|
3213
|
+
state.shot = null;
|
|
3214
|
+
state.shotBlob = null;
|
|
3215
|
+
$("#cam-shot").src = "";
|
|
3216
|
+
clearCamTexts();
|
|
3217
|
+
setReview(false);
|
|
3218
|
+
$("#cam-send").disabled = true;
|
|
3219
|
+
$("#cam-story").disabled = true;
|
|
3220
|
+
startCamera();
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
async function acceptImage(file) {
|
|
3224
|
+
if (!file) return;
|
|
3225
|
+
if (!file.type.startsWith("image/")) return toast("That's not an image", "err");
|
|
3226
|
+
try {
|
|
3227
|
+
const bitmap = await createImageBitmap(file);
|
|
3228
|
+
enterReview(drawShot(bitmap, 1080, 1440));
|
|
3229
|
+
} catch (err) { toast("Couldn't read that image: " + err.message, "err"); }
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
$("#shutter").addEventListener("click", takeShot);
|
|
3233
|
+
$("#cam-retake").addEventListener("click", retake);
|
|
3234
|
+
$("#cam-file").addEventListener("click", () => $("#cam-fileinput").click());
|
|
3235
|
+
$("#cam-empty-upload").addEventListener("click", () => $("#cam-fileinput").click());
|
|
3236
|
+
$("#cam-empty-retry").addEventListener("click", () => {
|
|
3237
|
+
state.camError = null;
|
|
3238
|
+
$("#cam-empty").classList.add("hidden");
|
|
3239
|
+
$("#cam-box").dataset.blocked = "false";
|
|
3240
|
+
startCamera();
|
|
3241
|
+
});
|
|
3242
|
+
$("#cam-fileinput").addEventListener("change", async (e) => {
|
|
3243
|
+
const file = e.target.files[0];
|
|
3244
|
+
e.target.value = "";
|
|
3245
|
+
await acceptImage(file);
|
|
3246
|
+
});
|
|
3247
|
+
$("#cap-input").addEventListener("input", (e) => { $("#cam-cap").textContent = e.target.value; });
|
|
3248
|
+
|
|
3249
|
+
/* drag, drop and paste anywhere on the stage */
|
|
3250
|
+
const stage = $("#cam-box");
|
|
3251
|
+
["dragenter", "dragover"].forEach((ev) => stage.addEventListener(ev, (e) => {
|
|
3252
|
+
e.preventDefault();
|
|
3253
|
+
stage.dataset.drop = "true";
|
|
3254
|
+
}));
|
|
3255
|
+
["dragleave", "drop"].forEach((ev) => stage.addEventListener(ev, (e) => {
|
|
3256
|
+
e.preventDefault();
|
|
3257
|
+
stage.dataset.drop = "false";
|
|
3258
|
+
}));
|
|
3259
|
+
stage.addEventListener("drop", (e) => {
|
|
3260
|
+
const file = e.dataTransfer?.files?.[0];
|
|
3261
|
+
if (file) acceptImage(file);
|
|
3262
|
+
});
|
|
3263
|
+
window.addEventListener("paste", (e) => {
|
|
3264
|
+
if (state.view !== "camera") return;
|
|
3265
|
+
const item = [...(e.clipboardData?.items || [])].find((i) => i.type.startsWith("image/"));
|
|
3266
|
+
if (!item) return;
|
|
3267
|
+
const file = item.getAsFile();
|
|
3268
|
+
if (file) acceptImage(file);
|
|
3269
|
+
});
|
|
3270
|
+
|
|
3271
|
+
function storyMeta() {
|
|
3272
|
+
return {
|
|
3273
|
+
texts: state.camTexts.map(normalizeOverlayText).filter((o) => o.t),
|
|
3274
|
+
};
|
|
3275
|
+
}
|
|
3276
|
+
async function getShotBlob() {
|
|
3277
|
+
if (state.shotBlob) return state.shotBlob;
|
|
3278
|
+
if (!state.shot) throw new Error("Take or upload a photo first");
|
|
3279
|
+
const res = await fetch(state.shot);
|
|
3280
|
+
return await res.blob();
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
/* Feed posts and DMs have no overlay-metadata channel, so bake the same text
|
|
3284
|
+
treatment into those copies. Stories intentionally use the raw photo plus
|
|
3285
|
+
p_meta instead, otherwise the viewer would double-render the overlays. */
|
|
3286
|
+
function wrapCanvasText(ctx, text, maxWidth) {
|
|
3287
|
+
const lines = [];
|
|
3288
|
+
for (const part of String(text).split("\n")) {
|
|
3289
|
+
const words = part.split(/\s+/).filter(Boolean);
|
|
3290
|
+
if (!words.length) { lines.push(""); continue; }
|
|
3291
|
+
let line = "";
|
|
3292
|
+
for (const word of words) {
|
|
3293
|
+
const next = line ? line + " " + word : word;
|
|
3294
|
+
if (ctx.measureText(next).width <= maxWidth || !line) line = next;
|
|
3295
|
+
else { lines.push(line); line = word; }
|
|
3296
|
+
}
|
|
3297
|
+
if (line) lines.push(line);
|
|
3298
|
+
}
|
|
3299
|
+
return lines.slice(0, 8);
|
|
3300
|
+
}
|
|
3301
|
+
function roundedCanvasRect(ctx, x, y, w, h, r) {
|
|
3302
|
+
r = Math.min(r, w / 2, h / 2);
|
|
3303
|
+
ctx.beginPath();
|
|
3304
|
+
ctx.moveTo(x + r, y);
|
|
3305
|
+
ctx.arcTo(x + w, y, x + w, y + h, r);
|
|
3306
|
+
ctx.arcTo(x + w, y + h, x, y + h, r);
|
|
3307
|
+
ctx.arcTo(x, y + h, x, y, r);
|
|
3308
|
+
ctx.arcTo(x, y, x + w, y, r);
|
|
3309
|
+
ctx.closePath();
|
|
3310
|
+
}
|
|
3311
|
+
async function compositeShotCanvas() {
|
|
3312
|
+
if (!state.shot) return null;
|
|
3313
|
+
const texts = state.camTexts.map(normalizeOverlayText).filter((o) => o.t);
|
|
3314
|
+
const img = new Image();
|
|
3315
|
+
img.src = state.shot;
|
|
3316
|
+
await img.decode();
|
|
3317
|
+
const canvas = document.createElement("canvas");
|
|
3318
|
+
canvas.width = img.naturalWidth || 1080;
|
|
3319
|
+
canvas.height = img.naturalHeight || 1440;
|
|
3320
|
+
const ctx = canvas.getContext("2d");
|
|
3321
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
3322
|
+
for (const o of texts) {
|
|
3323
|
+
const px = canvas.width * .075 * o.scale;
|
|
3324
|
+
const lineHeight = px * 1.12;
|
|
3325
|
+
ctx.font = `800 ${px}px "Bricolage Grotesque", Figtree, sans-serif`;
|
|
3326
|
+
ctx.textAlign = "center";
|
|
3327
|
+
ctx.textBaseline = "middle";
|
|
3328
|
+
const maxWidth = canvas.width * .86;
|
|
3329
|
+
const lines = wrapCanvasText(ctx, o.t, maxWidth);
|
|
3330
|
+
const widest = Math.max(...lines.map((line) => ctx.measureText(line).width), 1);
|
|
3331
|
+
const totalH = lines.length * lineHeight;
|
|
3332
|
+
const cx = o.x * canvas.width;
|
|
3333
|
+
const cy = o.y * canvas.height;
|
|
3334
|
+
if (o.bar) {
|
|
3335
|
+
const padX = px * .38, padY = px * .22;
|
|
3336
|
+
ctx.fillStyle = "rgba(0,0,0,.74)";
|
|
3337
|
+
roundedCanvasRect(ctx, cx - widest / 2 - padX, cy - totalH / 2 - padY, widest + padX * 2, totalH + padY * 2, Math.max(2, px * .06));
|
|
3338
|
+
ctx.fill();
|
|
3339
|
+
}
|
|
3340
|
+
ctx.fillStyle = o.color;
|
|
3341
|
+
ctx.shadowColor = o.bar ? "transparent" : "rgba(0,0,0,.88)";
|
|
3342
|
+
ctx.shadowBlur = o.bar ? 0 : px * .32;
|
|
3343
|
+
ctx.shadowOffsetY = o.bar ? 0 : px * .06;
|
|
3344
|
+
lines.forEach((line, i) => {
|
|
3345
|
+
ctx.fillText(line, cx, cy + (i - (lines.length - 1) / 2) * lineHeight, maxWidth);
|
|
3346
|
+
});
|
|
3347
|
+
ctx.shadowColor = "transparent";
|
|
3348
|
+
ctx.shadowBlur = 0;
|
|
3349
|
+
ctx.shadowOffsetY = 0;
|
|
3350
|
+
}
|
|
3351
|
+
return canvas;
|
|
3352
|
+
}
|
|
3353
|
+
async function compositeShotBlob() {
|
|
3354
|
+
try {
|
|
3355
|
+
const canvas = await compositeShotCanvas();
|
|
3356
|
+
if (canvas) {
|
|
3357
|
+
const blob = await new Promise((res) => canvas.toBlob(res, "image/jpeg", .72));
|
|
3358
|
+
if (blob) return blob;
|
|
3359
|
+
}
|
|
3360
|
+
} catch { /* fall back to the already-working raw capture below */ }
|
|
3361
|
+
return getShotBlob();
|
|
3362
|
+
}
|
|
3363
|
+
async function compositeShotDataUrl() {
|
|
3364
|
+
try {
|
|
3365
|
+
const canvas = await compositeShotCanvas();
|
|
3366
|
+
if (canvas) return canvas.toDataURL("image/jpeg", .72);
|
|
3367
|
+
} catch { /* fall back to the already-working raw capture below */ }
|
|
3368
|
+
return state.shot;
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
async function postStoryDirect() {
|
|
3372
|
+
const btn = $("#cam-story");
|
|
3373
|
+
if (!state.shot || state.postingStory) return;
|
|
3374
|
+
state.postingStory = true;
|
|
3375
|
+
btn.disabled = true;
|
|
3376
|
+
$("#cam-send").disabled = true;
|
|
3377
|
+
const label = btn.innerHTML;
|
|
3378
|
+
btn.innerHTML = '<span class="spinner"></span>';
|
|
3379
|
+
try {
|
|
3380
|
+
const caption = $("#cap-input").value.trim();
|
|
3381
|
+
const url = await uploadBlob(await getShotBlob());
|
|
3382
|
+
await api("yap_story_add", { p_token: state.token, p_image_url: url, p_caption: caption, p_filter: state.filter, p_meta: storyMeta() });
|
|
3383
|
+
toast("Story added", "ok");
|
|
3384
|
+
await loadStories();
|
|
3385
|
+
clearCaption();
|
|
3386
|
+
retake();
|
|
3387
|
+
} catch (err) {
|
|
3388
|
+
toast(err.message, "err");
|
|
3389
|
+
} finally {
|
|
3390
|
+
state.postingStory = false;
|
|
3391
|
+
btn.innerHTML = label;
|
|
3392
|
+
const has = !!state.shot;
|
|
3393
|
+
btn.disabled = !has;
|
|
3394
|
+
$("#cam-send").disabled = !has;
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
$("#cam-story").addEventListener("click", postStoryDirect);
|
|
3398
|
+
|
|
3399
|
+
$("#cam-send").addEventListener("click", () => {
|
|
3400
|
+
if (!state.shot) return;
|
|
3401
|
+
const caption = $("#cap-input").value.trim();
|
|
3402
|
+
const sheet = openSheet(`<h3>Send your yap</h3>
|
|
3403
|
+
<p class="small" style="color:var(--tx-2);margin:6px 0 16px">It disappears after 24 hours.</p>
|
|
3404
|
+
<div class="sheet-actions">
|
|
3405
|
+
<button class="btn primary" data-dest="feed">Post to the feed</button>
|
|
3406
|
+
<button class="btn ghost" data-dest="dm">Send to a friend</button>
|
|
3407
|
+
</div>`);
|
|
3408
|
+
sheet.querySelectorAll("[data-dest]").forEach((b) => b.addEventListener("click", async () => {
|
|
3409
|
+
const dest = b.dataset.dest;
|
|
3410
|
+
try {
|
|
3411
|
+
if (dest === "dm") { closeSheet(); openSendTo(caption); return; }
|
|
3412
|
+
b.disabled = true;
|
|
3413
|
+
b.innerHTML = '<span class="spinner"></span>';
|
|
3414
|
+
const url = await uploadBlob(await compositeShotBlob());
|
|
3415
|
+
await api("yap_post", { p_token: state.token, p_body: caption, p_image_url: url });
|
|
3416
|
+
toast("Posted to the feed", "ok");
|
|
3417
|
+
await loadFeed();
|
|
3418
|
+
closeSheet();
|
|
3419
|
+
clearCaption();
|
|
3420
|
+
retake();
|
|
3421
|
+
go("feed");
|
|
3422
|
+
} catch (err) {
|
|
3423
|
+
toast(err.message, "err");
|
|
3424
|
+
b.disabled = false;
|
|
3425
|
+
b.textContent = "Post to the feed";
|
|
3426
|
+
}
|
|
3427
|
+
}));
|
|
3428
|
+
});
|
|
3429
|
+
|
|
3430
|
+
const IMAGE_EXT = { "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", "image/gif": "gif" };
|
|
3431
|
+
async function uploadBlob(blob) {
|
|
3432
|
+
const type = blob?.type || "image/jpeg";
|
|
3433
|
+
const ext = IMAGE_EXT[type] || (type.startsWith("image/") ? type.slice(6).split(";")[0].replace("jpeg", "jpg") : "jpg");
|
|
3434
|
+
const path = `${state.me.username}/${crypto.randomUUID()}.${ext}`;
|
|
3435
|
+
const { error } = await sb.storage.from(CONFIG.mediaBucket).upload(path, blob, { contentType: type });
|
|
3436
|
+
if (error) throw new Error(error.message);
|
|
3437
|
+
return sb.storage.from(CONFIG.mediaBucket).getPublicUrl(path).data.publicUrl;
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
async function openSendTo(caption) {
|
|
3441
|
+
let people = [];
|
|
3442
|
+
try { people = await api("yap_search_users", { p_token: state.token, p_q: "" }); } catch (err) { toast(err.message, "err"); }
|
|
3443
|
+
const sheet = openSheet(`<h3>Send to</h3>
|
|
3444
|
+
<input class="field" id="sendto-q" placeholder="Search people" style="margin-bottom:12px" />
|
|
3445
|
+
<div id="sendto-list"></div>`);
|
|
3446
|
+
const list = sheet.querySelector("#sendto-list");
|
|
3447
|
+
const draw = (rows) => {
|
|
3448
|
+
list.innerHTML = rows.length ? rows.map((p) => `
|
|
3449
|
+
<button class="chatrow" data-send="${esc(p.username)}">
|
|
3450
|
+
${avatarHtml(p)}
|
|
3451
|
+
<div class="who">
|
|
3452
|
+
<div class="name">${esc(p.display_name || p.username)}</div>
|
|
3453
|
+
<div class="snippet">@${esc(p.username)}</div>
|
|
3454
|
+
</div>
|
|
3455
|
+
<span class="btn sm ghost">Send</span>
|
|
3456
|
+
</button>`).join("") : `<p class="small" style="color:var(--tx-3);padding:12px">Nobody found.</p>`;
|
|
3457
|
+
list.querySelectorAll("[data-send]").forEach((b) => b.addEventListener("click", async () => {
|
|
3458
|
+
b.disabled = true;
|
|
3459
|
+
try {
|
|
3460
|
+
const imageData = await compositeShotDataUrl();
|
|
3461
|
+
await api("yap_send_yap", {
|
|
3462
|
+
p_token: state.token, p_to: b.dataset.send, p_kind: "photo",
|
|
3463
|
+
p_body: caption, p_image_data: imageData, p_filter: state.filter,
|
|
3464
|
+
});
|
|
3465
|
+
toast("Yap sent", "ok");
|
|
3466
|
+
closeSheet();
|
|
3467
|
+
retake();
|
|
3468
|
+
go("chats");
|
|
3469
|
+
await loadInbox();
|
|
3470
|
+
} catch (err) { toast(err.message, "err"); b.disabled = false; }
|
|
3471
|
+
}));
|
|
3472
|
+
};
|
|
3473
|
+
draw(people);
|
|
3474
|
+
sheet.querySelector("#sendto-q").addEventListener("input", async (e) => {
|
|
3475
|
+
try { draw(await api("yap_search_users", { p_token: state.token, p_q: e.target.value.trim() })); } catch { /* ignore */ }
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
</script>
|
|
3480
|
+
<script>
|
|
3481
|
+
|
|
3482
|
+
/* =======================================================================
|
|
3483
|
+
PROFILE, DRAWER, ADMIN
|
|
3484
|
+
======================================================================= */
|
|
3485
|
+
const BANNER_CSS = {
|
|
3486
|
+
midnight: "linear-gradient(150deg,#070b12,#16295c)",
|
|
3487
|
+
aurora: "linear-gradient(150deg,#041a2e,#0e5f9e)",
|
|
3488
|
+
sunset: "linear-gradient(150deg,#0b1030,#2440a8)",
|
|
3489
|
+
royal: "linear-gradient(150deg,#16224d,#2f6bff)",
|
|
3490
|
+
carbon: "linear-gradient(150deg,#0c1017,#2a3140)",
|
|
3491
|
+
};
|
|
3492
|
+
const BANNER_LABEL = { midnight: "Midnight", aurora: "Aurora", sunset: "Sunset", royal: "Royal", carbon: "Carbon" };
|
|
3493
|
+
const FRAME_LABEL = { none: "None", ring: "Ring", verified: "Ice" };
|
|
3494
|
+
const bannerImgHtml = (url) => url ? `<img class="banner-img" src="${esc(url)}" alt="" onerror="this.remove()" />` : "";
|
|
3495
|
+
function paintBannerBox(el, deco = {}, picked = null) {
|
|
3496
|
+
if (!el) return;
|
|
3497
|
+
const banner = picked || deco.banner || "midnight";
|
|
3498
|
+
el.style.background = BANNER_CSS[banner] || BANNER_CSS.midnight;
|
|
3499
|
+
el.innerHTML = bannerImgHtml(deco.banner_img);
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3502
|
+
function renderProfile() {
|
|
3503
|
+
const me = state.me;
|
|
3504
|
+
if (!me) return;
|
|
3505
|
+
const deco = me.decoration || {};
|
|
3506
|
+
const banner = deco.banner || "midnight";
|
|
3507
|
+
const frame = deco.frame || "none";
|
|
3508
|
+
paintBannerBox($("#prof-banner"), deco);
|
|
3509
|
+
const av = $("#prof-avatar");
|
|
3510
|
+
av.dataset.frame = frame;
|
|
3511
|
+
av.style.setProperty("--av", toneFor(me.username));
|
|
3512
|
+
av.style.setProperty("--av-fg", toneFg(me.username));
|
|
3513
|
+
av.innerHTML = (me.avatar_url ? `<img src="${esc(me.avatar_url)}" alt="" onerror="this.remove()" />` : esc(initials(me.display_name || me.username))) + decorImg(deco, true);
|
|
3514
|
+
setPlateLayer($("#prof-plate"), $("#prof-ident"), deco);
|
|
3515
|
+
$("#prof-name").textContent = me.display_name || me.username;
|
|
3516
|
+
$("#prof-handle").textContent = "@" + me.username;
|
|
3517
|
+
$("#prof-joined").textContent = "joined " + new Date(me.created_at).toLocaleDateString(undefined, { month: "short", year: "numeric" });
|
|
3518
|
+
const bio = $("#prof-bio");
|
|
3519
|
+
bio.textContent = me.bio || "add a bio";
|
|
3520
|
+
bio.dataset.empty = String(!me.bio);
|
|
3521
|
+
$("#prof-stories").textContent = me.stories ?? 0;
|
|
3522
|
+
countUp($("#prof-posts"), me.posts ?? 0);
|
|
3523
|
+
const np = me.posts ?? 0, ns = me.stories ?? 0;
|
|
3524
|
+
$("#prof-posts").nextElementSibling.textContent = np === 1 ? "post" : "posts";
|
|
3525
|
+
$("#prof-stories").nextElementSibling.textContent = ns === 1 ? "live story" : "live stories";
|
|
3526
|
+
$("#prof-badges").innerHTML = [
|
|
3527
|
+
me.is_admin ? '<span class="badge admin"><svg class="ico"><use href="#i-bolt"/></svg>admin</span>' : "",
|
|
3528
|
+
me.is_support ? '<span class="badge support">support</span>' : "",
|
|
3529
|
+
me.is_verified ? '<span class="badge verified"><svg class="ico"><use href="#i-check"/></svg>verified</span>' : "",
|
|
3530
|
+
].join("");
|
|
3531
|
+
$("#pop-admin").classList.toggle("hidden", !me.is_admin);
|
|
3532
|
+
|
|
3533
|
+
$("#pf-name").value = me.display_name || me.username;
|
|
3534
|
+
$("#pf-bio").value = me.bio || "";
|
|
3535
|
+
$$("#pf-banner-pick button").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.banner === banner)));
|
|
3536
|
+
$$("#pf-frame-pick button").forEach((b) => b.classList.toggle("on", b.dataset.frame === frame));
|
|
3537
|
+
positionSegPill($("#pf-frame-pick"));
|
|
3538
|
+
syncCosmeticPickers();
|
|
3539
|
+
|
|
3540
|
+
/* rail + popover identity */
|
|
3541
|
+
const fillAv = (el) => {
|
|
3542
|
+
if (!el) return;
|
|
3543
|
+
el.dataset.frame = frame;
|
|
3544
|
+
el.style.setProperty("--av", toneFor(me.username));
|
|
3545
|
+
el.style.setProperty("--av-fg", toneFg(me.username));
|
|
3546
|
+
el.innerHTML = (me.avatar_url ? `<img src="${esc(me.avatar_url)}" alt="" />` : esc(initials(me.display_name || me.username))) + decorImg(deco);
|
|
3547
|
+
};
|
|
3548
|
+
fillAv($("#rail-avatar"));
|
|
3549
|
+
fillAv($("#mob-av"));
|
|
3550
|
+
$("#rail-name").textContent = me.display_name || me.username;
|
|
3551
|
+
$("#rail-handle").textContent = "@" + me.username;
|
|
3552
|
+
fillAv($("#pop-avatar"));
|
|
3553
|
+
setPlateLayer($("#pop-plate"), $("#userpop-head"), deco);
|
|
3554
|
+
$("#pop-name").textContent = me.display_name || me.username;
|
|
3555
|
+
$("#pop-handle").textContent = "@" + me.username;
|
|
3556
|
+
$("#composer-avatar").innerHTML = avatarHtml(me, "sm");
|
|
3557
|
+
|
|
3558
|
+
renderMyPosts();
|
|
3559
|
+
paintUploadRows();
|
|
3560
|
+
paintPreview();
|
|
3561
|
+
if (state.view === "profile") updateRouteChrome();
|
|
3562
|
+
}
|
|
3563
|
+
function renderMyPosts() {
|
|
3564
|
+
const box = $("#prof-post-list");
|
|
3565
|
+
if (!box) return;
|
|
3566
|
+
const mine = state.feed.filter((p) => p.mine);
|
|
3567
|
+
if (!mine.length) {
|
|
3568
|
+
box.innerHTML = `<p class="muted-line">nothing yet. yaps stay up for 24 hours.</p>`;
|
|
3569
|
+
return;
|
|
3570
|
+
}
|
|
3571
|
+
box.innerHTML = mine.map((p) => `
|
|
3572
|
+
<article class="post static" data-post="${esc(p.id)}">
|
|
3573
|
+
<div class="post-head">
|
|
3574
|
+
${avatarHtml(p.author || state.me, "", true)}
|
|
3575
|
+
<div class="post-who">
|
|
3576
|
+
<span class="post-name">${esc((p.author || state.me).display_name || (p.author || state.me).username)}</span>
|
|
3577
|
+
<div class="post-meta"><span>@${esc((p.author || state.me).username)}</span><i class="dot"></i><time>${esc(fmtTime(p.created_at))}</time></div>
|
|
3578
|
+
</div>
|
|
3579
|
+
</div>
|
|
3580
|
+
<p class="post-body">${esc(p.body || "photo yap")}</p>
|
|
3581
|
+
<div class="post-acts">
|
|
3582
|
+
<span class="act"><svg class="ico"><use href="#i-heart"/></svg><span class="count">${p.likes}</span></span>
|
|
3583
|
+
<span class="act"><svg class="ico"><use href="#i-reply"/></svg><span class="count">${p.replies ?? 0}</span></span>
|
|
3584
|
+
</div>
|
|
3585
|
+
</article>`).join("");
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3588
|
+
/* ------------------------------------------------------------- preview */
|
|
3589
|
+
function editDecoration() {
|
|
3590
|
+
const deco = { ...(state.me?.decoration || {}) };
|
|
3591
|
+
if (state.pickedDecor !== undefined) {
|
|
3592
|
+
if (state.pickedDecor) deco.decor = state.pickedDecor;
|
|
3593
|
+
else delete deco.decor;
|
|
3594
|
+
}
|
|
3595
|
+
if (state.pickedPlate !== undefined) {
|
|
3596
|
+
if (state.pickedPlate) deco.plate = state.pickedPlate;
|
|
3597
|
+
else delete deco.plate;
|
|
3598
|
+
}
|
|
3599
|
+
if (state.bannerImgCleared) delete deco.banner_img;
|
|
3600
|
+
else if (state.bannerPreview) deco.banner_img = state.bannerPreview;
|
|
3601
|
+
return deco;
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
function paintPreview() {
|
|
3605
|
+
const me = state.me;
|
|
3606
|
+
if (!me) return;
|
|
3607
|
+
const deco = editDecoration();
|
|
3608
|
+
const banner = state.pickedBanner || deco.banner || "midnight";
|
|
3609
|
+
const frame = state.pickedFrame || deco.frame || "none";
|
|
3610
|
+
const name = $("#pf-name").value.trim() || me.display_name || me.username;
|
|
3611
|
+
const bio = $("#pf-bio").value.trim();
|
|
3612
|
+
const avatarUrl = state.avatarPreview || me.avatar_url;
|
|
3613
|
+
const plate = plateVideoHtml(deco.plate);
|
|
3614
|
+
const html = `
|
|
3615
|
+
<div class="pv-banner" style="background:${BANNER_CSS[banner] || BANNER_CSS.midnight}">${bannerImgHtml(deco.banner_img)}</div>
|
|
3616
|
+
<div class="pv-body">
|
|
3617
|
+
<div class="avatar sm pv-av" data-frame="${esc(frame)}" style="--av:${toneFor(me.username)};--av-fg:${toneFg(me.username)};width:56px;height:56px;font-size:20px">
|
|
3618
|
+
${(avatarUrl ? `<img src="${esc(avatarUrl)}" alt="" />` : esc(initials(name))) + decorImg(deco)}
|
|
3619
|
+
</div>
|
|
3620
|
+
<div class="pv-idblock" data-plate="${plate ? "true" : "false"}">
|
|
3621
|
+
${plate ? `<div class="plate-layer">${plate}</div>` : ""}
|
|
3622
|
+
<div class="pv-name">${esc(name)}</div>
|
|
3623
|
+
<div class="pv-handle">@${esc(me.username)}</div>
|
|
3624
|
+
</div>
|
|
3625
|
+
<p style="font-size:12px;color:var(--tx-2);margin-top:8px">${esc(bio || "add a bio")}</p>
|
|
3626
|
+
</div>`;
|
|
3627
|
+
const a = $("#pf-preview");
|
|
3628
|
+
if (a) a.innerHTML = html;
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
/* cosmetics pickers */
|
|
3632
|
+
function currentPicked(kind) {
|
|
3633
|
+
const key = kind === "decor" ? "pickedDecor" : "pickedPlate";
|
|
3634
|
+
return state[key] !== undefined ? state[key] : (state.me?.decoration?.[kind] || null);
|
|
3635
|
+
}
|
|
3636
|
+
function syncCosmeticPickers() {
|
|
3637
|
+
const decor = currentPicked("decor");
|
|
3638
|
+
const plate = currentPicked("plate");
|
|
3639
|
+
$$("#pf-decor-pick [data-decor]").forEach((b) => {
|
|
3640
|
+
const on = (b.dataset.decor || null) === decor || (!b.dataset.decor && !decor);
|
|
3641
|
+
b.dataset.on = String(on);
|
|
3642
|
+
b.setAttribute("aria-pressed", String(on));
|
|
3643
|
+
});
|
|
3644
|
+
$$("#pf-plate-pick [data-plate]").forEach((b) => {
|
|
3645
|
+
const on = (b.dataset.plate || null) === plate || (!b.dataset.plate && !plate);
|
|
3646
|
+
b.dataset.on = String(on);
|
|
3647
|
+
b.setAttribute("aria-pressed", String(on));
|
|
3648
|
+
});
|
|
3649
|
+
}
|
|
3650
|
+
function renderCosmeticPickers() {
|
|
3651
|
+
const dg = $("#pf-decor-pick");
|
|
3652
|
+
const pg = $("#pf-plate-pick");
|
|
3653
|
+
if (!dg || !pg) return;
|
|
3654
|
+
dg.innerHTML = `<button type="button" class="cosmetic-tile none" data-decor="" aria-label="No avatar decoration" aria-pressed="false">None</button>` +
|
|
3655
|
+
SHOP.decorations.map((d) => `<button type="button" class="cosmetic-tile decor" data-decor="${esc(d.id)}" aria-label="${esc(d.name)}" aria-pressed="false" title="${esc(d.name)}">
|
|
3656
|
+
<img src="${esc(d.url)}" alt="" loading="lazy" /><span class="cosmetic-name">${esc(d.name)}</span>
|
|
3657
|
+
</button>`).join("");
|
|
3658
|
+
pg.innerHTML = `<button type="button" class="cosmetic-tile none" data-plate="" aria-label="No nameplate" aria-pressed="false">None</button>` +
|
|
3659
|
+
SHOP.nameplates.map((n) => `<button type="button" class="cosmetic-tile" data-plate="${esc(n.id)}" aria-label="${esc(n.name)}" aria-pressed="false" title="${esc(n.name)}">
|
|
3660
|
+
${plateVideoHtml(n.id)}<span class="cosmetic-name">${esc(n.name)}</span>
|
|
3661
|
+
</button>`).join("");
|
|
3662
|
+
dg.querySelectorAll("[data-decor]").forEach((b) => b.addEventListener("click", () => {
|
|
3663
|
+
const id = b.dataset.decor || null;
|
|
3664
|
+
state.pickedDecor = (!id || currentPicked("decor") === id) ? null : id;
|
|
3665
|
+
syncCosmeticPickers();
|
|
3666
|
+
checkDirty();
|
|
3667
|
+
}));
|
|
3668
|
+
pg.querySelectorAll("[data-plate]").forEach((b) => b.addEventListener("click", () => {
|
|
3669
|
+
const id = b.dataset.plate || null;
|
|
3670
|
+
state.pickedPlate = (!id || currentPicked("plate") === id) ? null : id;
|
|
3671
|
+
syncCosmeticPickers();
|
|
3672
|
+
checkDirty();
|
|
3673
|
+
}));
|
|
3674
|
+
syncCosmeticPickers();
|
|
3675
|
+
}
|
|
3676
|
+
renderCosmeticPickers();
|
|
3677
|
+
|
|
3678
|
+
/* profile media uploads */
|
|
3679
|
+
const PROFILE_IMAGE_MIMES = ["image/jpeg", "image/png", "image/webp", "image/gif"];
|
|
3680
|
+
const PROFILE_IMAGE_MAX = 5 * 1024 * 1024;
|
|
3681
|
+
function validProfileImage(file) {
|
|
3682
|
+
if (!file) return false;
|
|
3683
|
+
if (!PROFILE_IMAGE_MIMES.includes(file.type)) {
|
|
3684
|
+
toast("Use a JPEG, PNG, WebP or GIF image", "err");
|
|
3685
|
+
return false;
|
|
3686
|
+
}
|
|
3687
|
+
if (file.size > PROFILE_IMAGE_MAX) {
|
|
3688
|
+
toast("That image is over 5MB — pick a smaller one", "err");
|
|
3689
|
+
return false;
|
|
3690
|
+
}
|
|
3691
|
+
return true;
|
|
3692
|
+
}
|
|
3693
|
+
function clearProfileUploads() {
|
|
3694
|
+
if (state.avatarPreview?.startsWith("blob:")) URL.revokeObjectURL(state.avatarPreview);
|
|
3695
|
+
if (state.bannerPreview?.startsWith("blob:")) URL.revokeObjectURL(state.bannerPreview);
|
|
3696
|
+
state.avatarFile = null;
|
|
3697
|
+
state.avatarPreview = null;
|
|
3698
|
+
state.bannerFile = null;
|
|
3699
|
+
state.bannerPreview = null;
|
|
3700
|
+
state.bannerImgCleared = false;
|
|
3701
|
+
const ai = $("#pf-avatar-input"), bi = $("#pf-banner-img-input");
|
|
3702
|
+
if (ai) ai.value = "";
|
|
3703
|
+
if (bi) bi.value = "";
|
|
3704
|
+
}
|
|
3705
|
+
function paintUploadRows() {
|
|
3706
|
+
const me = state.me;
|
|
3707
|
+
if (!me) return;
|
|
3708
|
+
const thumb = $("#pf-avatar-thumb");
|
|
3709
|
+
if (thumb) {
|
|
3710
|
+
const deco = editDecoration();
|
|
3711
|
+
const url = state.avatarPreview || me.avatar_url;
|
|
3712
|
+
thumb.dataset.frame = deco.frame || "none";
|
|
3713
|
+
thumb.style.setProperty("--av", toneFor(me.username));
|
|
3714
|
+
thumb.style.setProperty("--av-fg", toneFg(me.username));
|
|
3715
|
+
thumb.innerHTML = (url ? `<img src="${esc(url)}" alt="" />` : esc(initials(me.display_name || me.username))) + decorImg(deco);
|
|
3716
|
+
}
|
|
3717
|
+
const ac = $("#pf-avatar-clear");
|
|
3718
|
+
if (ac) ac.classList.toggle("hidden", !state.avatarFile);
|
|
3719
|
+
const bc = $("#pf-banner-img-clear");
|
|
3720
|
+
const existing = !!(state.me.decoration?.banner_img);
|
|
3721
|
+
if (bc) {
|
|
3722
|
+
bc.classList.toggle("hidden", !(state.bannerFile || existing));
|
|
3723
|
+
bc.textContent = state.bannerImgCleared ? "Keep image" : state.bannerFile && !existing ? "Clear selection" : "Remove image";
|
|
3724
|
+
}
|
|
3725
|
+
const note = $("#pf-banner-img-note");
|
|
3726
|
+
if (note) {
|
|
3727
|
+
note.textContent = state.bannerFile ? `${state.bannerFile.name} · uploads when you save`
|
|
3728
|
+
: state.bannerImgCleared ? "Banner image will be removed when you save"
|
|
3729
|
+
: existing ? "Custom banner image active — it overrides the color"
|
|
3730
|
+
: "Overrides the banner color · JPEG, PNG, WebP or GIF · up to 5MB";
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
$("#pf-avatar-btn").addEventListener("click", () => $("#pf-avatar-input").click());
|
|
3734
|
+
$("#pf-banner-img-btn").addEventListener("click", () => $("#pf-banner-img-input").click());
|
|
3735
|
+
$("#pf-avatar-input").addEventListener("change", (e) => {
|
|
3736
|
+
const file = e.target.files[0];
|
|
3737
|
+
e.target.value = "";
|
|
3738
|
+
if (!file || !validProfileImage(file)) return;
|
|
3739
|
+
if (state.avatarPreview?.startsWith("blob:")) URL.revokeObjectURL(state.avatarPreview);
|
|
3740
|
+
state.avatarFile = file;
|
|
3741
|
+
state.avatarPreview = URL.createObjectURL(file);
|
|
3742
|
+
paintUploadRows();
|
|
3743
|
+
checkDirty();
|
|
3744
|
+
});
|
|
3745
|
+
$("#pf-banner-img-input").addEventListener("change", (e) => {
|
|
3746
|
+
const file = e.target.files[0];
|
|
3747
|
+
e.target.value = "";
|
|
3748
|
+
if (!file || !validProfileImage(file)) return;
|
|
3749
|
+
if (state.bannerPreview?.startsWith("blob:")) URL.revokeObjectURL(state.bannerPreview);
|
|
3750
|
+
state.bannerFile = file;
|
|
3751
|
+
state.bannerPreview = URL.createObjectURL(file);
|
|
3752
|
+
state.bannerImgCleared = false;
|
|
3753
|
+
paintUploadRows();
|
|
3754
|
+
checkDirty();
|
|
3755
|
+
});
|
|
3756
|
+
$("#pf-avatar-clear").addEventListener("click", () => {
|
|
3757
|
+
if (state.avatarPreview?.startsWith("blob:")) URL.revokeObjectURL(state.avatarPreview);
|
|
3758
|
+
state.avatarFile = null;
|
|
3759
|
+
state.avatarPreview = null;
|
|
3760
|
+
paintUploadRows();
|
|
3761
|
+
checkDirty();
|
|
3762
|
+
});
|
|
3763
|
+
$("#pf-banner-img-clear").addEventListener("click", () => {
|
|
3764
|
+
if (state.bannerFile) {
|
|
3765
|
+
if (state.bannerPreview?.startsWith("blob:")) URL.revokeObjectURL(state.bannerPreview);
|
|
3766
|
+
state.bannerFile = null;
|
|
3767
|
+
state.bannerPreview = null;
|
|
3768
|
+
state.bannerImgCleared = false;
|
|
3769
|
+
} else if (state.me?.decoration?.banner_img) {
|
|
3770
|
+
state.bannerImgCleared = !state.bannerImgCleared;
|
|
3771
|
+
}
|
|
3772
|
+
paintUploadRows();
|
|
3773
|
+
checkDirty();
|
|
3774
|
+
});
|
|
3775
|
+
|
|
3776
|
+
/* --------------------------------------------------------------- drawer */
|
|
3777
|
+
const drawer = $("#edit-drawer");
|
|
3778
|
+
const scrim = $("#drawer-scrim");
|
|
3779
|
+
function snapshotForm() {
|
|
3780
|
+
const deco = state.me?.decoration || {};
|
|
3781
|
+
return {
|
|
3782
|
+
name: $("#pf-name").value.trim(),
|
|
3783
|
+
bio: $("#pf-bio").value.trim(),
|
|
3784
|
+
banner: state.pickedBanner || deco.banner || "midnight",
|
|
3785
|
+
frame: state.pickedFrame || deco.frame || "none",
|
|
3786
|
+
decor: state.pickedDecor !== undefined ? state.pickedDecor : (deco.decor || null),
|
|
3787
|
+
plate: state.pickedPlate !== undefined ? state.pickedPlate : (deco.plate || null),
|
|
3788
|
+
bannerImg: state.bannerFile ? "__new__" : state.bannerImgCleared ? null : (deco.banner_img || null),
|
|
3789
|
+
avatarNew: !!state.avatarFile,
|
|
3790
|
+
};
|
|
3791
|
+
}
|
|
3792
|
+
function baselineForm() {
|
|
3793
|
+
const deco = state.me?.decoration || {};
|
|
3794
|
+
return {
|
|
3795
|
+
name: state.me?.display_name || state.me?.username || "",
|
|
3796
|
+
bio: state.me?.bio || "",
|
|
3797
|
+
banner: deco.banner || "midnight",
|
|
3798
|
+
frame: deco.frame || "none",
|
|
3799
|
+
decor: deco.decor || null,
|
|
3800
|
+
plate: deco.plate || null,
|
|
3801
|
+
bannerImg: deco.banner_img || null,
|
|
3802
|
+
avatarNew: false,
|
|
3803
|
+
};
|
|
3804
|
+
}
|
|
3805
|
+
function checkDirty() {
|
|
3806
|
+
const a = snapshotForm(), b = baselineForm();
|
|
3807
|
+
const dirty = Object.keys(a).some((k) => a[k] !== b[k]);
|
|
3808
|
+
state.dirty = dirty;
|
|
3809
|
+
const sv = $("#pf-save");
|
|
3810
|
+
if (sv && !state.saving) sv.disabled = !dirty;
|
|
3811
|
+
const dc = $("#pf-discard");
|
|
3812
|
+
if (dc) dc.hidden = !dirty;
|
|
3813
|
+
paintUploadRows();
|
|
3814
|
+
paintPreview();
|
|
3815
|
+
return dirty;
|
|
3816
|
+
}
|
|
3817
|
+
function resetProfileEdits() {
|
|
3818
|
+
state.pickedBanner = null;
|
|
3819
|
+
state.pickedFrame = null;
|
|
3820
|
+
state.pickedDecor = undefined;
|
|
3821
|
+
state.pickedPlate = undefined;
|
|
3822
|
+
clearProfileUploads();
|
|
3823
|
+
}
|
|
3824
|
+
function openDrawer() {
|
|
3825
|
+
if (!state.me) return;
|
|
3826
|
+
resetProfileEdits();
|
|
3827
|
+
renderProfile();
|
|
3828
|
+
drawer.dataset.open = "true";
|
|
3829
|
+
scrim.dataset.open = "true";
|
|
3830
|
+
drawer.removeAttribute("aria-hidden");
|
|
3831
|
+
checkDirty();
|
|
3832
|
+
setTimeout(() => $("#pf-name").focus(), 60);
|
|
3833
|
+
}
|
|
3834
|
+
function closeDrawer(force = false) {
|
|
3835
|
+
if (!force && checkDirty()) {
|
|
3836
|
+
toast("Save or discard your changes first", "err");
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
drawer.dataset.open = "false";
|
|
3840
|
+
scrim.dataset.open = "false";
|
|
3841
|
+
drawer.setAttribute("aria-hidden", "true");
|
|
3842
|
+
}
|
|
3843
|
+
$("#prof-edit").addEventListener("click", openDrawer);
|
|
3844
|
+
$("#act-edit")?.addEventListener("click", openDrawer);
|
|
3845
|
+
$("#drawer-close").addEventListener("click", () => closeDrawer());
|
|
3846
|
+
scrim.addEventListener("click", () => closeDrawer());
|
|
3847
|
+
$("#pf-discard").addEventListener("click", () => {
|
|
3848
|
+
resetProfileEdits();
|
|
3849
|
+
renderProfile();
|
|
3850
|
+
checkDirty();
|
|
3851
|
+
});
|
|
3852
|
+
$$("#pf-banner-pick button").forEach((b) => b.addEventListener("click", () => {
|
|
3853
|
+
state.pickedBanner = b.dataset.banner;
|
|
3854
|
+
$$("#pf-banner-pick button").forEach((x) => x.setAttribute("aria-pressed", String(x === b)));
|
|
3855
|
+
$("#prof-banner").style.background = BANNER_CSS[state.pickedBanner];
|
|
3856
|
+
checkDirty();
|
|
3857
|
+
}));
|
|
3858
|
+
$$("#pf-frame-pick button").forEach((b) => b.addEventListener("click", () => {
|
|
3859
|
+
state.pickedFrame = b.dataset.frame;
|
|
3860
|
+
$$("#pf-frame-pick button").forEach((x) => x.classList.toggle("on", x === b));
|
|
3861
|
+
positionSegPill($("#pf-frame-pick"));
|
|
3862
|
+
$("#prof-avatar").dataset.frame = state.pickedFrame;
|
|
3863
|
+
checkDirty();
|
|
3864
|
+
}));
|
|
3865
|
+
$("#pf-name").addEventListener("input", checkDirty);
|
|
3866
|
+
$("#pf-bio").addEventListener("input", checkDirty);
|
|
3867
|
+
$("#prof-bio").addEventListener("click", () => { if ($("#prof-bio").dataset.empty === "true") { openDrawer(); setTimeout(() => $("#pf-bio").focus(), 120); } });
|
|
3868
|
+
|
|
3869
|
+
function syncMeIntoContent() {
|
|
3870
|
+
const me = state.me;
|
|
3871
|
+
if (!me) return;
|
|
3872
|
+
const patch = {
|
|
3873
|
+
display_name: me.display_name,
|
|
3874
|
+
avatar_url: me.avatar_url,
|
|
3875
|
+
decoration: me.decoration,
|
|
3876
|
+
is_support: me.is_support,
|
|
3877
|
+
is_verified: me.is_verified,
|
|
3878
|
+
};
|
|
3879
|
+
state.feed.forEach((post) => {
|
|
3880
|
+
if (post.mine) post.author = { ...(post.author || {}), ...patch, username: me.username };
|
|
3881
|
+
});
|
|
3882
|
+
const mineStory = state.stories.find((st) => st.is_me);
|
|
3883
|
+
if (mineStory) Object.assign(mineStory, patch, { username: me.username });
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
$("#pf-save").addEventListener("click", async () => {
|
|
3887
|
+
const btn = $("#pf-save");
|
|
3888
|
+
state.saving = true;
|
|
3889
|
+
btn.disabled = true;
|
|
3890
|
+
btn.innerHTML = '<span class="spinner"></span>';
|
|
3891
|
+
try {
|
|
3892
|
+
let avatarUrl = state.me.avatar_url || null;
|
|
3893
|
+
if (state.avatarFile) avatarUrl = await uploadBlob(state.avatarFile);
|
|
3894
|
+
let bannerImgUrl = null;
|
|
3895
|
+
if (state.bannerFile) bannerImgUrl = await uploadBlob(state.bannerFile);
|
|
3896
|
+
|
|
3897
|
+
const deco = { ...(state.me.decoration || {}) };
|
|
3898
|
+
if (state.pickedBanner) deco.banner = state.pickedBanner;
|
|
3899
|
+
if (state.pickedFrame) deco.frame = state.pickedFrame;
|
|
3900
|
+
if (state.pickedDecor !== undefined) {
|
|
3901
|
+
if (state.pickedDecor) deco.decor = state.pickedDecor;
|
|
3902
|
+
else delete deco.decor;
|
|
3903
|
+
}
|
|
3904
|
+
if (state.pickedPlate !== undefined) {
|
|
3905
|
+
if (state.pickedPlate) deco.plate = state.pickedPlate;
|
|
3906
|
+
else delete deco.plate;
|
|
3907
|
+
}
|
|
3908
|
+
if (state.bannerImgCleared) delete deco.banner_img;
|
|
3909
|
+
if (bannerImgUrl) deco.banner_img = bannerImgUrl;
|
|
3910
|
+
|
|
3911
|
+
state.me = await api("yap_update_profile", {
|
|
3912
|
+
p_token: state.token,
|
|
3913
|
+
p_display_name: $("#pf-name").value.trim(),
|
|
3914
|
+
p_bio: $("#pf-bio").value.trim(),
|
|
3915
|
+
p_avatar_url: avatarUrl,
|
|
3916
|
+
p_decoration: deco,
|
|
3917
|
+
});
|
|
3918
|
+
syncMeIntoContent();
|
|
3919
|
+
renderFeed();
|
|
3920
|
+
resetProfileEdits();
|
|
3921
|
+
state.saving = false;
|
|
3922
|
+
renderProfile();
|
|
3923
|
+
checkDirty();
|
|
3924
|
+
btn.innerHTML = '<svg class="ico"><use href="#i-check"/></svg>Saved';
|
|
3925
|
+
toast("Profile saved", "ok");
|
|
3926
|
+
setTimeout(() => { btn.innerHTML = "Save profile"; btn.disabled = !state.dirty; }, 1200);
|
|
3927
|
+
} catch (err) {
|
|
3928
|
+
state.saving = false;
|
|
3929
|
+
toast(err.message, "err");
|
|
3930
|
+
btn.innerHTML = "Save profile";
|
|
3931
|
+
btn.disabled = !state.dirty;
|
|
3932
|
+
}
|
|
3933
|
+
});
|
|
3934
|
+
|
|
3935
|
+
$("#prof-logout").addEventListener("click", logout);
|
|
3936
|
+
$("#pop-logout").addEventListener("click", logout);
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
/* ----------------------------------------------------------------- admin */
|
|
3940
|
+
async function loadAdmin() {
|
|
3941
|
+
$("#admin-body").innerHTML = `<div class="skeleton"><i style="width:40%"></i><i style="width:70%"></i><i style="width:55%"></i></div>`;
|
|
3942
|
+
try {
|
|
3943
|
+
state.admin = await api("yap_admin_overview", { p_token: state.token });
|
|
3944
|
+
renderAdmin();
|
|
3945
|
+
} catch (err) {
|
|
3946
|
+
$("#admin-body").innerHTML = emptyState("plane", "no access", err.message);
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
function askText(title, placeholder, initial = "") {
|
|
3951
|
+
return new Promise((resolve) => {
|
|
3952
|
+
const sheet = openSheet(`<h3>${esc(title)}</h3>
|
|
3953
|
+
<input class="field" id="ask-input" placeholder="${esc(placeholder)}" value="${esc(initial)}" />
|
|
3954
|
+
<div class="row" style="display:flex;gap:8px;margin-top:14px">
|
|
3955
|
+
<button class="btn ghost" id="ask-cancel" style="flex:1">Cancel</button>
|
|
3956
|
+
<button class="btn primary" id="ask-ok" style="flex:1">Confirm</button>
|
|
3957
|
+
</div>`);
|
|
3958
|
+
sheet.querySelector("#ask-input").focus();
|
|
3959
|
+
const done = (val) => { closeSheet(); resolve(val); };
|
|
3960
|
+
sheet.querySelector("#ask-cancel").addEventListener("click", () => done(null));
|
|
3961
|
+
sheet.querySelector("#ask-ok").addEventListener("click", () => done(sheet.querySelector("#ask-input").value.trim()));
|
|
3962
|
+
sheet.querySelector("#ask-input").addEventListener("keydown", (e) => { if (e.key === "Enter") done(e.target.value.trim()); });
|
|
3963
|
+
});
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
async function renderAdmin() {
|
|
3967
|
+
const body = $("#admin-body");
|
|
3968
|
+
const d = state.admin;
|
|
3969
|
+
if (!d) return loadAdmin();
|
|
3970
|
+
$$("#admin-tabs button").forEach((b) => b.classList.toggle("on", b.dataset.atab === state.atab));
|
|
3971
|
+
|
|
3972
|
+
if (state.atab === "overview") {
|
|
3973
|
+
const s = d.stats || {};
|
|
3974
|
+
body.innerHTML = `
|
|
3975
|
+
<div class="grid2">
|
|
3976
|
+
<div class="tile"><div class="k">${s.users ?? 0}</div><div class="l">people</div></div>
|
|
3977
|
+
<div class="tile"><div class="k">${s.posts ?? 0}</div><div class="l">posts</div></div>
|
|
3978
|
+
<div class="tile"><div class="k">${s.stories ?? 0}</div><div class="l">live stories</div></div>
|
|
3979
|
+
<div class="tile"><div class="k">${s.yaps ?? 0}</div><div class="l">yaps live</div></div>
|
|
3980
|
+
<div class="tile"><div class="k" style="color:var(--accent-hi)">${s.reports_open ?? 0}</div><div class="l">open reports</div></div>
|
|
3981
|
+
<div class="tile"><div class="k" style="color:var(--tx-1)">${s.blocked ?? 0}</div><div class="l">blocked (7d)</div></div>
|
|
3982
|
+
</div>
|
|
3983
|
+
<div class="section-head"><h3>Filter activity</h3><span class="pill">${s.terms ?? 0} terms</span></div>
|
|
3984
|
+
<div id="admin-log"></div>`;
|
|
3985
|
+
$("#admin-log").innerHTML = (d.log || []).length ? d.log.map((g) => `
|
|
3986
|
+
<div class="listitem">
|
|
3987
|
+
<div class="row" style="display:flex;align-items:center;gap:8px">
|
|
3988
|
+
<span class="small" style="flex:1;min-width:0"><strong>${esc(g.username)}</strong> ${esc(g.action)} <span class="pill">${esc(g.area)}</span></span>
|
|
3989
|
+
<span class="mono" style="color:var(--tx-3)">${esc(fmtTime(g.created_at))}</span>
|
|
3990
|
+
</div>
|
|
3991
|
+
${g.hits && g.hits.length ? `<div class="mono" style="color:var(--tx-1);margin-top:6px">${esc(g.hits.join(", "))}</div>` : ""}
|
|
3992
|
+
${g.excerpt ? `<div class="small truncate" style="color:var(--tx-3);margin-top:6px">${esc(g.excerpt)}</div>` : ""}
|
|
3993
|
+
</div>`).join("") : `<p class="small" style="color:var(--tx-3)">Nothing blocked yet.</p>`;
|
|
3994
|
+
return;
|
|
3995
|
+
}
|
|
3996
|
+
|
|
3997
|
+
if (state.atab === "reports") {
|
|
3998
|
+
body.innerHTML = (d.reports || []).length ? d.reports.map((r) => `
|
|
3999
|
+
<div class="listitem" data-report="${esc(r.id)}">
|
|
4000
|
+
<div class="row" style="display:flex;align-items:center;gap:8px">
|
|
4001
|
+
<span class="small" style="flex:1"><strong>${esc(r.reason)}</strong> <span class="pill">${esc(r.target_type)}</span></span>
|
|
4002
|
+
<span class="mono" style="color:var(--tx-3)">${esc(fmtTime(r.created_at))}</span>
|
|
4003
|
+
</div>
|
|
4004
|
+
<div class="small truncate" style="color:var(--tx-3);margin-top:6px">${esc(r.target_label || "")} — by @${esc(r.reporter)}</div>
|
|
4005
|
+
${r.detail ? `<div class="small" style="margin-top:8px">${esc(r.detail)}</div>` : ""}
|
|
4006
|
+
<div class="row" style="display:flex;gap:8px;margin-top:12px">
|
|
4007
|
+
<button class="btn sm primary" data-resolve="${esc(r.id)}">Actioned</button>
|
|
4008
|
+
<button class="btn sm ghost" data-dismiss="${esc(r.id)}">Dismiss</button>
|
|
4009
|
+
</div>
|
|
4010
|
+
</div>`).join("") : emptyState("plane", "queue is clear", "Nothing waiting on a human right now.");
|
|
4011
|
+
body.querySelectorAll("[data-resolve]").forEach((b) => b.addEventListener("click", () => resolveReport(b.dataset.resolve, "resolve")));
|
|
4012
|
+
body.querySelectorAll("[data-dismiss]").forEach((b) => b.addEventListener("click", () => resolveReport(b.dataset.dismiss, "dismiss")));
|
|
4013
|
+
return;
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
if (state.atab === "users") {
|
|
4017
|
+
body.innerHTML = `
|
|
4018
|
+
<div style="margin-bottom:12px"><input class="field" id="admin-user-q" placeholder="Search username" /></div>
|
|
4019
|
+
<div id="admin-users"></div>`;
|
|
4020
|
+
const drawRows = (rows) => {
|
|
4021
|
+
const box = $("#admin-users");
|
|
4022
|
+
box.innerHTML = rows.length ? rows.map((u) => `
|
|
4023
|
+
<div class="listitem">
|
|
4024
|
+
<div class="row" style="display:flex;align-items:center;gap:12px">
|
|
4025
|
+
${avatarHtml({ ...u, is_support: u.is_support })}
|
|
4026
|
+
<div style="flex:1;min-width:0">
|
|
4027
|
+
<div class="row" style="display:flex;gap:6px;flex-wrap:wrap;align-items:center">
|
|
4028
|
+
<strong style="font-size:14px">${esc(u.display_name || u.username)}</strong>
|
|
4029
|
+
${u.is_admin ? '<span class="badge admin">admin</span>' : ""}
|
|
4030
|
+
${u.is_support ? '<span class="badge support">support</span>' : ""}
|
|
4031
|
+
${u.banned_until ? '<span class="badge banned">banned</span>' : ""}
|
|
4032
|
+
</div>
|
|
4033
|
+
<div class="mono" style="color:var(--tx-3);margin-top:4px">@${esc(u.username)} · ${u.posts} posts · ${u.strikes} strikes</div>
|
|
4034
|
+
</div>
|
|
4035
|
+
</div>
|
|
4036
|
+
<div class="row" style="display:flex;gap:8px;margin-top:12px;flex-wrap:wrap">
|
|
4037
|
+
${u.banned_until
|
|
4038
|
+
? `<button class="btn sm ghost" data-unban="${esc(u.username)}">Unban</button>`
|
|
4039
|
+
: `<button class="btn sm danger" data-ban="${esc(u.username)}">Ban</button>`}
|
|
4040
|
+
<button class="btn sm ghost" data-msg="${esc(u.username)}">Open chat</button>
|
|
4041
|
+
</div>
|
|
4042
|
+
</div>`).join("") : `<p class="small" style="color:var(--tx-3)">No users found.</p>`;
|
|
4043
|
+
box.querySelectorAll("[data-ban]").forEach((b) => b.addEventListener("click", () => banUser(b.dataset.ban)));
|
|
4044
|
+
box.querySelectorAll("[data-unban]").forEach((b) => b.addEventListener("click", () => unbanUser(b.dataset.unban)));
|
|
4045
|
+
box.querySelectorAll("[data-msg]").forEach((b) => b.addEventListener("click", () => openThread(b.dataset.msg)));
|
|
4046
|
+
};
|
|
4047
|
+
drawRows(d.users || []);
|
|
4048
|
+
$("#admin-user-q").addEventListener("input", async (e) => {
|
|
4049
|
+
const q = e.target.value.trim();
|
|
4050
|
+
if (!q) return drawRows(d.users || []);
|
|
4051
|
+
try { drawRows(await api("yap_admin_search", { p_token: state.token, p_kind: "users", p_q: q })); } catch (err) { toast(err.message, "err"); }
|
|
4052
|
+
});
|
|
4053
|
+
return;
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
if (state.atab === "posts") {
|
|
4057
|
+
body.innerHTML = (d.posts || []).length ? d.posts.map((p) => `
|
|
4058
|
+
<div class="listitem">
|
|
4059
|
+
<div class="row" style="display:flex;align-items:center;gap:8px">
|
|
4060
|
+
<span class="small" style="flex:1"><strong>@${esc(p.author)}</strong> <span class="pill">${p.likes} likes</span></span>
|
|
4061
|
+
<span class="mono" style="color:var(--tx-3)">${esc(fmtTime(p.created_at))}</span>
|
|
4062
|
+
</div>
|
|
4063
|
+
${p.body ? `<div class="small truncate" style="margin-top:6px">${esc(p.body)}</div>` : ""}
|
|
4064
|
+
${p.image_url || p.gif_url ? `<div class="mono" style="color:var(--tx-3);margin-top:6px">media attached</div>` : ""}
|
|
4065
|
+
${p.removed ? `<div class="mono" style="color:var(--tx-1);margin-top:6px">removed: ${esc(p.removed_reason || "")}</div>` : ""}
|
|
4066
|
+
${p.removed ? "" : `<button class="btn sm danger" style="margin-top:12px" data-remove="${esc(p.id)}">Remove post</button>`}
|
|
4067
|
+
</div>`).join("") : `<p class="small" style="color:var(--tx-3)">No posts yet.</p>`;
|
|
4068
|
+
body.querySelectorAll("[data-remove]").forEach((b) => b.addEventListener("click", () => removePost(b.dataset.remove)));
|
|
4069
|
+
return;
|
|
4070
|
+
}
|
|
4071
|
+
|
|
4072
|
+
if (state.atab === "filter") {
|
|
4073
|
+
body.innerHTML = `
|
|
4074
|
+
<div class="row" style="display:flex;gap:8px;margin-bottom:12px">
|
|
4075
|
+
<input class="field" id="admin-term-q" placeholder="Search banned terms" />
|
|
4076
|
+
<button class="btn primary sm" id="admin-term-add">Add</button>
|
|
4077
|
+
</div>
|
|
4078
|
+
<div id="admin-terms"></div>`;
|
|
4079
|
+
const list = await api("yap_admin_search", { p_token: state.token, p_kind: "terms", p_q: "" }).catch(() => []);
|
|
4080
|
+
const drawTerms = (rows) => {
|
|
4081
|
+
$("#admin-terms").innerHTML = rows.length ? rows.slice(0, 80).map((t) => `
|
|
4082
|
+
<div class="listitem" style="display:flex;align-items:center;gap:10px">
|
|
4083
|
+
<span class="small" style="flex:1;min-width:0"><code>${esc(t.term)}</code>
|
|
4084
|
+
<span class="pill">${esc(t.kind)}</span> <span class="pill">s${t.severity}</span></span>
|
|
4085
|
+
<button class="btn sm ghost" data-delterm="${esc(t.term)}">Remove</button>
|
|
4086
|
+
</div>`).join("") : `<p class="small" style="color:var(--tx-3)">Nothing matches.</p>`;
|
|
4087
|
+
$$("#admin-terms [data-delterm]").forEach((b) => b.addEventListener("click", async () => {
|
|
4088
|
+
try {
|
|
4089
|
+
await api("yap_admin_remove_term", { p_token: state.token, p_term: b.dataset.delterm });
|
|
4090
|
+
toast("Term removed", "ok");
|
|
4091
|
+
drawTerms(rows.filter((r) => r.term !== b.dataset.delterm));
|
|
4092
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4093
|
+
}));
|
|
4094
|
+
};
|
|
4095
|
+
drawTerms(list);
|
|
4096
|
+
$("#admin-term-add").addEventListener("click", async () => {
|
|
4097
|
+
const term = $("#admin-term-q").value.trim();
|
|
4098
|
+
if (term.length < 2) return toast("That is too short", "err");
|
|
4099
|
+
try {
|
|
4100
|
+
await api("yap_admin_add_term", { p_token: state.token, p_term: term, p_kind: "word" });
|
|
4101
|
+
toast("Term added", "ok");
|
|
4102
|
+
drawTerms(await api("yap_admin_search", { p_token: state.token, p_kind: "terms", p_q: "" }));
|
|
4103
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4104
|
+
});
|
|
4105
|
+
$("#admin-term-q").addEventListener("input", async (e) => {
|
|
4106
|
+
drawTerms(await api("yap_admin_search", { p_token: state.token, p_kind: "terms", p_q: e.target.value.trim() }).catch(() => []));
|
|
4107
|
+
});
|
|
4108
|
+
return;
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
if (state.atab === "support") {
|
|
4112
|
+
body.innerHTML = `<p class="small" style="color:var(--tx-3);margin-bottom:12px">Messages people sent to @yapsupport.</p><div id="admin-support"></div>`;
|
|
4113
|
+
const rows = await api("yap_support_threads", { p_token: state.token }).catch((e) => { toast(e.message, "err"); return []; });
|
|
4114
|
+
$("#admin-support").innerHTML = rows.length ? rows.map((t) => `
|
|
4115
|
+
<div class="listitem">
|
|
4116
|
+
<div class="row" style="display:flex;align-items:center;gap:12px">
|
|
4117
|
+
${avatarHtml({ ...t, is_support: false })}
|
|
4118
|
+
<div style="flex:1;min-width:0">
|
|
4119
|
+
<strong style="font-size:14px">${esc(t.display_name || t.username)}</strong>
|
|
4120
|
+
<div class="small truncate" style="color:var(--tx-3)">${esc(t.last || "")}</div>
|
|
4121
|
+
</div>
|
|
4122
|
+
${t.unanswered ? '<span class="pill" style="color:var(--accent-hi)">waiting</span>' : ""}
|
|
4123
|
+
</div>
|
|
4124
|
+
<div class="row" style="display:flex;gap:8px;margin-top:12px">
|
|
4125
|
+
<button class="btn sm primary" data-sreply="${esc(t.username)}">Reply as support</button>
|
|
4126
|
+
<button class="btn sm ghost" data-sview="${esc(t.username)}">Open thread</button>
|
|
4127
|
+
</div>
|
|
4128
|
+
</div>`).join("") : `<p class="small" style="color:var(--tx-3)">No support messages.</p>`;
|
|
4129
|
+
$$("#admin-support [data-sreply]").forEach((b) => b.addEventListener("click", async () => {
|
|
4130
|
+
const text = await askText("Reply as Yap Support", "Type the reply…");
|
|
4131
|
+
if (!text) return;
|
|
4132
|
+
try {
|
|
4133
|
+
await api("yap_support_reply", { p_token: state.token, p_to: b.dataset.sreply, p_body: text });
|
|
4134
|
+
toast("Sent as support", "ok");
|
|
4135
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4136
|
+
}));
|
|
4137
|
+
$$("#admin-support [data-sview]").forEach((b) => b.addEventListener("click", () => openThread(b.dataset.sview)));
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
|
|
4141
|
+
async function resolveReport(id, action) {
|
|
4142
|
+
try {
|
|
4143
|
+
const note = await askText(action === "dismiss" ? "Why dismiss?" : "What did you do?", "optional note");
|
|
4144
|
+
await api("yap_admin_resolve", { p_token: state.token, p_report_id: id, p_action: action, p_note: note || null });
|
|
4145
|
+
toast("Report " + (action === "dismiss" ? "dismissed" : "actioned"), "ok");
|
|
4146
|
+
loadAdmin();
|
|
4147
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4148
|
+
}
|
|
4149
|
+
async function banUser(username) {
|
|
4150
|
+
const reason = await askText("Ban @" + username, "Reason (shown to them)");
|
|
4151
|
+
if (reason === null) return;
|
|
4152
|
+
try {
|
|
4153
|
+
await api("yap_admin_ban", { p_token: state.token, p_username: username, p_days: 0, p_reason: reason || "broke the rules" });
|
|
4154
|
+
toast("Banned", "ok");
|
|
4155
|
+
loadAdmin();
|
|
4156
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4157
|
+
}
|
|
4158
|
+
async function unbanUser(username) {
|
|
4159
|
+
try {
|
|
4160
|
+
await api("yap_admin_unban", { p_token: state.token, p_username: username });
|
|
4161
|
+
toast("Unbanned", "ok");
|
|
4162
|
+
loadAdmin();
|
|
4163
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4164
|
+
}
|
|
4165
|
+
async function removePost(id) {
|
|
4166
|
+
const reason = await askText("Remove this post", "Reason");
|
|
4167
|
+
if (reason === null) return;
|
|
4168
|
+
try {
|
|
4169
|
+
await api("yap_admin_remove_post", { p_token: state.token, p_post_id: id, p_reason: reason || "broke the rules" });
|
|
4170
|
+
toast("Post removed", "ok");
|
|
4171
|
+
loadAdmin();
|
|
4172
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
$$("#admin-tabs button").forEach((b) => b.addEventListener("click", () => {
|
|
4176
|
+
state.atab = b.dataset.atab;
|
|
4177
|
+
renderAdmin();
|
|
4178
|
+
}));
|
|
4179
|
+
$("#admin-back").addEventListener("click", () => go("profile"));
|
|
4180
|
+
|
|
4181
|
+
</script>
|
|
4182
|
+
<script>
|
|
4183
|
+
|
|
4184
|
+
/* =======================================================================
|
|
4185
|
+
SYSTEMS — context panel, keys, boot
|
|
4186
|
+
======================================================================= */
|
|
4187
|
+
|
|
4188
|
+
/* ------------------------------------------------------- custom context */
|
|
4189
|
+
const ctxmenu = $("#ctxmenu");
|
|
4190
|
+
let ctxMenuItems = [];
|
|
4191
|
+
const ctxIcon = (name) => `<svg class="ico" aria-hidden="true"><use href="#i-${name}"/></svg>`;
|
|
4192
|
+
|
|
4193
|
+
function cleanCtxItems(items) {
|
|
4194
|
+
const out = [];
|
|
4195
|
+
for (const item of items) {
|
|
4196
|
+
if (!item) continue;
|
|
4197
|
+
if (item.sep && (!out.length || out[out.length - 1].sep)) continue;
|
|
4198
|
+
out.push(item);
|
|
4199
|
+
}
|
|
4200
|
+
while (out.length && out[out.length - 1].sep) out.pop();
|
|
4201
|
+
return out;
|
|
4202
|
+
}
|
|
4203
|
+
function closeCtxMenu() {
|
|
4204
|
+
ctxmenu.classList.add("hidden");
|
|
4205
|
+
ctxmenu.innerHTML = "";
|
|
4206
|
+
ctxMenuItems = [];
|
|
4207
|
+
}
|
|
4208
|
+
function showCtxMenu(items, x, y) {
|
|
4209
|
+
ctxMenuItems = cleanCtxItems(items);
|
|
4210
|
+
if (!ctxMenuItems.length) return;
|
|
4211
|
+
ctxmenu.innerHTML = ctxMenuItems.map((item, i) => item.sep
|
|
4212
|
+
? `<div class="ctxmenu-sep" role="separator"></div>`
|
|
4213
|
+
: `<button class="ctxmenu-item" type="button" role="menuitem" data-ctxi="${i}">${ctxIcon(item.icon || "more")}<span>${esc(item.label)}</span></button>`).join("");
|
|
4214
|
+
ctxmenu.classList.remove("hidden");
|
|
4215
|
+
const pad = 8;
|
|
4216
|
+
const mw = ctxmenu.offsetWidth || 238;
|
|
4217
|
+
const mh = ctxmenu.offsetHeight || 320;
|
|
4218
|
+
ctxmenu.style.left = Math.max(pad, Math.min(x, window.innerWidth - mw - pad)) + "px";
|
|
4219
|
+
ctxmenu.style.top = Math.max(pad, Math.min(y, window.innerHeight - mh - pad)) + "px";
|
|
4220
|
+
$$(".ctxmenu-item", ctxmenu).forEach((b) => b.addEventListener("click", () => {
|
|
4221
|
+
const item = ctxMenuItems[Number(b.dataset.ctxi)];
|
|
4222
|
+
closeCtxMenu();
|
|
4223
|
+
item?.run?.();
|
|
4224
|
+
}));
|
|
4225
|
+
requestAnimationFrame(() => $(".ctxmenu-item", ctxmenu)?.focus());
|
|
4226
|
+
}
|
|
4227
|
+
function focusCtxStep(dir) {
|
|
4228
|
+
const buttons = $$(".ctxmenu-item", ctxmenu);
|
|
4229
|
+
if (!buttons.length) return;
|
|
4230
|
+
const i = buttons.indexOf(document.activeElement);
|
|
4231
|
+
buttons[(i + dir + buttons.length) % buttons.length].focus();
|
|
4232
|
+
}
|
|
4233
|
+
|
|
4234
|
+
async function copyPostText(text) {
|
|
4235
|
+
const value = text || "";
|
|
4236
|
+
try {
|
|
4237
|
+
await navigator.clipboard.writeText(value);
|
|
4238
|
+
toast("Copied", "ok");
|
|
4239
|
+
} catch {
|
|
4240
|
+
const tmp = document.createElement("textarea");
|
|
4241
|
+
tmp.value = value;
|
|
4242
|
+
tmp.style.position = "fixed";
|
|
4243
|
+
tmp.style.opacity = "0";
|
|
4244
|
+
document.body.appendChild(tmp);
|
|
4245
|
+
tmp.select();
|
|
4246
|
+
try { document.execCommand("copy"); toast("Copied", "ok"); }
|
|
4247
|
+
catch { toast("Couldn't copy that", "err"); }
|
|
4248
|
+
tmp.remove();
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
function currentStoryImage() {
|
|
4252
|
+
return state.storyList?.[state.storyIdx]?.image_url || null;
|
|
4253
|
+
}
|
|
4254
|
+
function buildCtxItems(target) {
|
|
4255
|
+
const items = [];
|
|
4256
|
+
const seen = new Set();
|
|
4257
|
+
const add = (label, icon, run) => {
|
|
4258
|
+
if (!label || seen.has(label)) return;
|
|
4259
|
+
seen.add(label);
|
|
4260
|
+
items.push({ label, icon, run });
|
|
4261
|
+
};
|
|
4262
|
+
|
|
4263
|
+
/* images first: post media and the active story image */
|
|
4264
|
+
let imageUrl = null;
|
|
4265
|
+
const zoom = target.closest("[data-zoom]");
|
|
4266
|
+
if (zoom) imageUrl = zoom.dataset.zoom;
|
|
4267
|
+
if (!imageUrl && target.closest("#storyview")) imageUrl = currentStoryImage();
|
|
4268
|
+
if (!imageUrl && target.matches?.("img") && target.closest(".post-media,.story,#storyview")) imageUrl = target.currentSrc || target.src;
|
|
4269
|
+
if (imageUrl) {
|
|
4270
|
+
add("Open full size", "image", () => openLightbox([imageUrl], 0));
|
|
4271
|
+
items.push({ sep: true });
|
|
4272
|
+
}
|
|
4273
|
+
|
|
4274
|
+
const postEl = target.closest("[data-post], .post");
|
|
4275
|
+
const postId = postEl?.dataset.post;
|
|
4276
|
+
const post = postId ? state.feed.find((p) => String(p.id) === String(postId)) : null;
|
|
4277
|
+
if (post) {
|
|
4278
|
+
const likeBtn = () => document.querySelector(`[data-like="${CSS.escape ? CSS.escape(post.id) : post.id}"]`);
|
|
4279
|
+
add(post.liked ? "Unlike" : "Like", "heart", () => { const b = likeBtn(); if (b) likePost(b); });
|
|
4280
|
+
add("Reply", "reply", () => toggleReplies(post.id));
|
|
4281
|
+
if (post.body) add("Copy text", "copy", () => copyPostText(post.body));
|
|
4282
|
+
add("Report post", "help", () => reportPost(post.id));
|
|
4283
|
+
if (canDeletePost(post)) add(post.mine ? "Delete post" : "Remove post", "x", () => deletePostById(post.id));
|
|
4284
|
+
items.push({ sep: true });
|
|
4285
|
+
}
|
|
4286
|
+
|
|
4287
|
+
const chatEl = target.closest("[data-chat], [data-ctx-chat], [data-found]");
|
|
4288
|
+
let chatUser = chatEl?.dataset.chat || chatEl?.dataset.ctxChat || chatEl?.dataset.found || null;
|
|
4289
|
+
if (!chatUser && target.closest(".avatar") && post?.author?.username && post.author.username !== state.me?.username) chatUser = post.author.username;
|
|
4290
|
+
if (chatUser) add("Open chat", "chat", () => openThread(chatUser));
|
|
4291
|
+
|
|
4292
|
+
const storyEl = target.closest("[data-story], [data-ctx-story], #story-add");
|
|
4293
|
+
if (storyEl) {
|
|
4294
|
+
const username = storyEl.dataset.story || storyEl.dataset.ctxStory || null;
|
|
4295
|
+
if (username) add("View story", "cam", () => openStory(username));
|
|
4296
|
+
else {
|
|
4297
|
+
const mine = state.stories.find((s) => s.is_me);
|
|
4298
|
+
if (mine?.items?.length) add("View your story", "cam", () => openStory(mine.username));
|
|
4299
|
+
else add("Add to your story", "cam", () => go("camera"));
|
|
4300
|
+
}
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4303
|
+
if (!items.length) {
|
|
4304
|
+
add("New yap", "plus", () => { go("feed"); setTimeout(() => $("#composer-text").focus(), 40); });
|
|
4305
|
+
items.push({ sep: true });
|
|
4306
|
+
add("Go to Feed", "feed", () => go("feed"));
|
|
4307
|
+
add("Go to Camera", "cam", () => go("camera"));
|
|
4308
|
+
add("Go to Chats", "chat", () => go("chats"));
|
|
4309
|
+
add("Go to You", "me", () => go("profile"));
|
|
4310
|
+
items.push({ sep: true });
|
|
4311
|
+
add("Refresh", "refresh", refreshCurrent);
|
|
4312
|
+
add("Help", "help", messageSupport);
|
|
4313
|
+
}
|
|
4314
|
+
return cleanCtxItems(items);
|
|
4315
|
+
}
|
|
4316
|
+
|
|
4317
|
+
document.addEventListener("contextmenu", (e) => {
|
|
4318
|
+
if (e.target.closest("#ctxmenu")) { e.preventDefault(); return; }
|
|
4319
|
+
if (e.target.closest("input, textarea") || e.target.isContentEditable) return;
|
|
4320
|
+
e.preventDefault();
|
|
4321
|
+
showCtxMenu(buildCtxItems(e.target), e.clientX, e.clientY);
|
|
4322
|
+
});
|
|
4323
|
+
document.addEventListener("pointerdown", (e) => {
|
|
4324
|
+
if (!ctxmenu.classList.contains("hidden") && !ctxmenu.contains(e.target)) closeCtxMenu();
|
|
4325
|
+
}, true);
|
|
4326
|
+
window.addEventListener("scroll", () => closeCtxMenu(), { passive: true, capture: true });
|
|
4327
|
+
window.addEventListener("resize", closeCtxMenu);
|
|
4328
|
+
document.addEventListener("keydown", (e) => {
|
|
4329
|
+
if (ctxmenu.classList.contains("hidden")) return;
|
|
4330
|
+
if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); closeCtxMenu(); return; }
|
|
4331
|
+
if (e.key === "ArrowDown") { e.preventDefault(); focusCtxStep(1); }
|
|
4332
|
+
if (e.key === "ArrowUp") { e.preventDefault(); focusCtxStep(-1); }
|
|
4333
|
+
if (e.key === "Home") { e.preventDefault(); $(".ctxmenu-item", ctxmenu)?.focus(); }
|
|
4334
|
+
if (e.key === "End") { e.preventDefault(); $$(".ctxmenu-item", ctxmenu).at(-1)?.focus(); }
|
|
4335
|
+
}, true);
|
|
4336
|
+
|
|
4337
|
+
function renderContext() {
|
|
4338
|
+
const chats = $("#ctx-chats");
|
|
4339
|
+
const stories = $("#ctx-stories");
|
|
4340
|
+
if (!chats || !stories) return;
|
|
4341
|
+
const show = state.view === "feed" || state.view === "profile";
|
|
4342
|
+
chats.style.display = show ? "" : "none";
|
|
4343
|
+
stories.style.display = show ? "" : "none";
|
|
4344
|
+
if (show) {
|
|
4345
|
+
const top = state.inbox.slice(0, 5);
|
|
4346
|
+
chats.innerHTML = `
|
|
4347
|
+
<div class="ctx-block">
|
|
4348
|
+
<div class="ctx-head"><div class="ctx-label">Chats</div><button class="ctx-more" id="ctx-chats-more">See all</button></div>
|
|
4349
|
+
${top.length
|
|
4350
|
+
? top.map((c) => `
|
|
4351
|
+
<button class="ctx-row" data-ctx-chat="${esc(c.username)}">
|
|
4352
|
+
${avatarHtml(c, "sm")}
|
|
4353
|
+
<div class="ctx-who">
|
|
4354
|
+
<div class="name truncate">${esc(c.display_name || c.username)}${c.streak >= 3 ? ` <span class="ctx-streak"><svg class="ico"><use href="#i-flame"/></svg>${c.streak}</span>` : ""}</div>
|
|
4355
|
+
<div class="meta truncate">${c.last_from_me ? "You: " : ""}${esc(c.last || "say hi")}</div>
|
|
4356
|
+
</div>
|
|
4357
|
+
${c.unread ? `<span class="unread">${c.unread > 9 ? "9+" : c.unread}</span>` : ""}
|
|
4358
|
+
</button>`).join("")
|
|
4359
|
+
: `<p class="small" style="color:var(--tx-3)">No conversations yet.</p>`}
|
|
4360
|
+
</div>`;
|
|
4361
|
+
$("#ctx-chats-more").addEventListener("click", () => go("chats"));
|
|
4362
|
+
$$("[data-ctx-chat]", chats).forEach((b) => b.addEventListener("click", () => openThread(b.dataset.ctxChat)));
|
|
4363
|
+
const others = state.stories.filter((s) => !s.is_me);
|
|
4364
|
+
stories.innerHTML = `
|
|
4365
|
+
<div class="ctx-block">
|
|
4366
|
+
<div class="ctx-label">Live stories</div>
|
|
4367
|
+
${others.length
|
|
4368
|
+
? others.slice(0, 6).map((s) => `
|
|
4369
|
+
<button class="ctx-row" data-ctx-story="${esc(s.username)}" style="width:100%;text-align:left;background:none">
|
|
4370
|
+
${avatarHtml(s, "sm")}
|
|
4371
|
+
<div class="ctx-who">
|
|
4372
|
+
<div class="name truncate">${esc(s.display_name || s.username)}</div>
|
|
4373
|
+
<div class="meta">${s.items ? s.items.length : 0} ${(s.items ? s.items.length : 0) === 1 ? "snap" : "snaps"} · ${esc(fmtTime(s.items?.[0]?.created_at || Date.now()))}</div>
|
|
4374
|
+
</div>
|
|
4375
|
+
</button>`).join("")
|
|
4376
|
+
: `<p class="small" style="color:var(--tx-3)">Nobody's posted a story in the last 24 hours.</p>`}
|
|
4377
|
+
</div>`;
|
|
4378
|
+
$$("[data-ctx-story]", stories).forEach((b) => b.addEventListener("click", () => openStory(b.dataset.ctxStory)));
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
/* ------------------------------------------------------------ popover */
|
|
4383
|
+
const userpop = $("#userpop");
|
|
4384
|
+
const anchorPop = (btn) => {
|
|
4385
|
+
setTimeout(() => {
|
|
4386
|
+
const r = btn.getBoundingClientRect();
|
|
4387
|
+
const pw = userpop.offsetWidth, ph = userpop.offsetHeight;
|
|
4388
|
+
const above = btn.id === "rail-user";
|
|
4389
|
+
userpop.style.transformOrigin = above ? "bottom left" : "top right";
|
|
4390
|
+
userpop.style.left = Math.max(8, Math.min(window.innerWidth - pw - 8, above ? r.left : r.right - pw)) + "px";
|
|
4391
|
+
userpop.style.top = (above ? Math.max(8, r.top - ph - 12) : r.bottom + 10) + "px";
|
|
4392
|
+
}, 0);
|
|
4393
|
+
};
|
|
4394
|
+
$("#rail-user").addEventListener("click", () => anchorPop($("#rail-user")));
|
|
4395
|
+
$("#mob-avatar").addEventListener("click", () => anchorPop($("#mob-avatar")));
|
|
4396
|
+
|
|
4397
|
+
/* ---------------------------------------------------------- refresh */
|
|
4398
|
+
async function refreshCurrent() {
|
|
4399
|
+
const v = state.view;
|
|
4400
|
+
if (v === "feed") await Promise.all([loadFeed({ silent: true }), loadStories(), loadInbox()]);
|
|
4401
|
+
else if (v === "chats") await loadInbox();
|
|
4402
|
+
else if (v === "thread" && state.peer) await openThread(state.peer);
|
|
4403
|
+
else if (v === "admin") await loadAdmin();
|
|
4404
|
+
else if (v === "profile") { await loadMe(); renderProfile(); }
|
|
4405
|
+
toast("Refreshed");
|
|
4406
|
+
}
|
|
4407
|
+
$("#top-refresh").addEventListener("click", () => { userpop.hidePopover?.(); refreshCurrent(); });
|
|
4408
|
+
|
|
4409
|
+
async function messageSupport() {
|
|
4410
|
+
userpop.hidePopover?.();
|
|
4411
|
+
try {
|
|
4412
|
+
const people = await api("yap_search_users", { p_token: state.token, p_q: "yap" });
|
|
4413
|
+
const support = people.find((p) => p.is_support);
|
|
4414
|
+
if (support) openThread(support.username);
|
|
4415
|
+
else toast("Support is not available right now", "err");
|
|
4416
|
+
} catch (err) { toast(err.message, "err"); }
|
|
4417
|
+
}
|
|
4418
|
+
$("#top-support").addEventListener("click", messageSupport);
|
|
4419
|
+
$("#pop-admin").addEventListener("click", () => { userpop.hidePopover?.(); go("admin"); renderAdmin(); });
|
|
4420
|
+
|
|
4421
|
+
/* ------------------------------------------------------------- scroll */
|
|
4422
|
+
window.addEventListener("scroll", () => {
|
|
4423
|
+
$(".rail").dataset.stuck = String(window.scrollY > 8);
|
|
4424
|
+
}, { passive: true });
|
|
4425
|
+
window.addEventListener("resize", () => moveRailPill());
|
|
4426
|
+
|
|
4427
|
+
/* --------------------------------------------------------- nav wiring */
|
|
4428
|
+
$$("[data-tab]").forEach((b) => b.addEventListener("click", () => go(b.dataset.tab)));
|
|
4429
|
+
const newYap = () => {
|
|
4430
|
+
go("feed");
|
|
4431
|
+
setTimeout(() => $("#composer-text").focus(), 40);
|
|
4432
|
+
};
|
|
4433
|
+
$("#rail-new").addEventListener("click", newYap);
|
|
4434
|
+
$("#tab-new").addEventListener("click", newYap);
|
|
4435
|
+
$("#rail-logo").addEventListener("click", (e) => { e.preventDefault(); go("feed"); });
|
|
4436
|
+
$("#auth-brand").addEventListener("click", (e) => e.preventDefault());
|
|
4437
|
+
|
|
4438
|
+
/* -------------------------------------------------------- global keys */
|
|
4439
|
+
document.addEventListener("keydown", (e) => {
|
|
4440
|
+
if (e.key !== "Escape") return;
|
|
4441
|
+
if ($("#lightbox").open) { $("#lightbox").close(); return; }
|
|
4442
|
+
if (drawer.dataset.open === "true") { closeDrawer(); return; }
|
|
4443
|
+
if (userpop.matches(":popover-open")) { userpop.hidePopover?.(); return; }
|
|
4444
|
+
});
|
|
4445
|
+
|
|
4446
|
+
/* ---------------------------------------------------------------- boot */
|
|
4447
|
+
async function boot() {
|
|
4448
|
+
renderFilters();
|
|
4449
|
+
$$(".seg").forEach(positionSegPill);
|
|
4450
|
+
$("#composer-avatar").innerHTML = "";
|
|
4451
|
+
const saved = localStorage.getItem(TOKEN_KEY);
|
|
4452
|
+
if (!saved) { showApp(false); requestAnimationFrame(() => positionSegPill($("#auth-tabs"))); return; }
|
|
4453
|
+
state.token = saved;
|
|
4454
|
+
try {
|
|
4455
|
+
await loadMe();
|
|
4456
|
+
await enterApp();
|
|
4457
|
+
renderProfile();
|
|
4458
|
+
} catch (err) {
|
|
4459
|
+
localStorage.removeItem(TOKEN_KEY);
|
|
4460
|
+
state.token = null;
|
|
4461
|
+
showApp(false);
|
|
4462
|
+
}
|
|
4463
|
+
requestAnimationFrame(() => positionSegPill($("#auth-tabs")));
|
|
4464
|
+
}
|
|
4465
|
+
boot();
|
|
4466
|
+
|
|
4467
|
+
window.addEventListener("pagehide", () => stopCamera());
|
|
4468
|
+
document.addEventListener("visibilitychange", () => {
|
|
4469
|
+
if (document.hidden) stopCamera();
|
|
4470
|
+
else if (state.view === "camera") startCamera();
|
|
4471
|
+
});
|
|
4472
|
+
|
|
4473
|
+
</script>
|
|
4474
|
+
</body>
|
|
4475
|
+
</html>
|