-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon.html
More file actions
399 lines (360 loc) · 19.6 KB
/
Copy pathicon.html
File metadata and controls
399 lines (360 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Icon — Sednicon Community</title>
<meta name="robots" content="index, follow"/>
<link rel="icon" type="image/svg+xml" href="/favicon.svg"/>
<script>
(function() {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.classList.add('dark');
}
// Auto-update if system theme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
document.documentElement.classList.toggle('dark', e.matches);
});
})();
</script>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<style>
:root {
--bg: #ffffff; --surface: #f9f9fa; --surface2: #f0f0f1; --surface3: #e5e5e6;
--border: rgba(0,0,0,0.08); --border-bright: rgba(0,0,0,0.15);
--text: #0a0a0a; --text-muted: #525252; --text-dim: #858585;
--accent: #2563eb; --accent3: #0284c7; --bg-overlay: rgba(255,255,255,0.9);
--ai-gradient: linear-gradient(135deg, #6366f1, #2563eb, #0284c7);
}
html.dark {
--bg: #0a0a0b; --surface: #151517; --surface2: #1c1c1f; --surface3: #29292d;
--border: rgba(255,255,255,0.08); --border-bright: rgba(255,255,255,0.15);
--text: #f5f5f5; --text-muted: #a3a3a3; --text-dim: #6b6b6b;
--accent: #5b8def; --accent3: #38bdf8; --bg-overlay: rgba(10,10,11,0.85);
--ai-gradient: linear-gradient(135deg, #818cf8, #5b8def, #38bdf8);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a, button, [role="button"], input[type="button"], .btn-nav-signin { -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px; line-height: 1.6; transition: background 0.3s, color 0.3s; -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
nav { position: fixed; top: 0; left: 0; right: 0; z-index: 100; padding: 20px 48px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid transparent; transition: border-color 0.4s, background 0.4s; }
nav.scrolled { border-color: var(--border); background: var(--bg-overlay); backdrop-filter: blur(20px); }
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 15px; }
.nav-logo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 32px; list-style: none; }
.nav-links a { text-decoration: none; color: var(--text-muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.page { padding: 120px 48px 80px; max-width: 900px; margin: 0 auto; }
.icon-layout { display: grid; grid-template-columns: 280px 1fr; gap: 32px; align-items: start; }
/* Left: preview */
.icon-preview-card {
background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; position: sticky; top: 100px;
}
.icon-preview-area {
padding: 48px; display: flex; align-items: center; justify-content: center;
background-color: var(--surface);
background-image: linear-gradient(45deg, var(--surface3) 25%, transparent 25%, transparent 75%, var(--surface3) 75%), linear-gradient(45deg, var(--surface3) 25%, transparent 25%, transparent 75%, var(--surface3) 75%);
background-size: 16px 16px; background-position: 0 0, 8px 8px;
position: relative;
}
.icon-preview-area::before { content: ''; position: absolute; inset: 0; background: var(--bg); opacity: 0.55; }
.icon-preview-area > * { position: relative; z-index: 1; }
.icon-preview-area svg { width: 120px; height: 120px; }
.icon-preview-actions { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.btn-action-full { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; }
.btn-action-full:hover { border-color: var(--border-bright); }
.btn-action-full.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-action-full.primary:hover { opacity: 0.9; }
.btn-action-full .material-icons { font-size: 18px; }
/* Like button */
.btn-like { display: flex; align-items: center; gap: 8px; }
.like-count { font-size: 16px; font-weight: 700; }
.btn-action-full.liked { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #ef4444; }
/* Right: details */
.icon-details { display: flex; flex-direction: column; gap: 24px; }
.icon-prompt { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; }
.icon-meta-row { display: flex; flex-wrap: wrap; gap: 10px; }
.meta-chip { padding: 4px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.meta-chip .material-icons { font-size: 14px; color: var(--accent); }
/* Code snippets */
.snippets-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.snippet-tabs { display: flex; border-bottom: 1px solid var(--border); }
.snippet-tab { padding: 12px 16px; font-size: 11px; font-family: 'JetBrains Mono', monospace; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); cursor: pointer; transition: all 0.2s; border-bottom: 2px solid transparent; }
.snippet-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.snippet-body { padding: 16px; position: relative; }
.snippet-pre { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text); overflow-x: auto; white-space: pre; line-height: 1.7; -webkit-user-select: text; user-select: text; }
.btn-copy-snippet { position: absolute; top: 12px; right: 12px; padding: 4px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all 0.2s; }
.btn-copy-snippet:hover { color: var(--text); }
/* Comments */
.comments-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.comments-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.comments-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 12px; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.comment-avatar-placeholder { width: 32px; height: 32px; border-radius: 50%; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comment-avatar-placeholder .material-icons { font-size: 18px; color: var(--text-dim); }
.comment-body { flex: 1; }
.comment-author { font-weight: 600; font-size: 13px; }
.comment-time { font-size: 11px; color: var(--text-dim); margin-left: 8px; }
.comment-text { font-size: 13px; color: var(--text-muted); margin-top: 4px; -webkit-user-select: text; user-select: text; }
.comment-form { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.comment-input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-family: 'Inter', sans-serif; font-size: 13px; color: var(--text); -webkit-user-select: text; user-select: text; }
.comment-input:focus { outline: none; border-color: var(--accent); }
.btn-comment-submit { padding: 8px 16px; background: var(--accent); color: white; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.btn-comment-submit:hover { opacity: 0.9; }
.comments-empty { padding: 32px; text-align: center; color: var(--text-dim); font-size: 13px; }
/* Report */
.btn-report { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 12px; display: flex; align-items: center; gap: 4px; padding: 0; transition: color 0.2s; }
.btn-report:hover { color: #ef4444; }
.btn-report .material-icons { font-size: 14px; }
.not-found { text-align: center; padding: 80px 24px; }
.not-found .material-icons { font-size: 48px; color: var(--text-dim); display: block; margin-bottom: 16px; }
.not-found h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.not-found p { color: var(--text-muted); margin-bottom: 24px; }
@media (max-width: 960px) {
nav { padding: 16px 24px; }
.nav-links { gap: 16px; }
.nav-links li:not(:last-child):not(:nth-last-child(2)):not(:first-child) { display: none; }
.page { padding: 100px 24px 60px; }
.icon-layout { grid-template-columns: 1fr; }
.icon-preview-card { position: static; }
}
</style>
</head>
<body>
<nav id="navbar">
<a href="/" class="nav-logo"><div class="nav-logo-dot"></div>Sednicon</a>
<ul class="nav-links">
<li><a href="/library">Library</a></li>
<li><a href="/community" class="active">Community</a></li>
<li><a href="/generate">Generate</a></li>
<li><a href="/docs">Docs</a></li>
<li><a href="/status">Status</a></li>
</ul>
</nav>
<div class="page" id="page-content">
<div style="text-align:center; padding:80px; color:var(--text-dim);">
<span class="material-icons" style="font-size:40px; display:block; margin-bottom:12px;">hourglass_empty</span>
Loading icon...
</div>
</div>
<script type="module">
import { initNav, getUser, getSession, signInWithGoogle, getSupabase } from '/js/auth.js';
window.addEventListener('scroll', () => document.getElementById('navbar').classList.toggle('scrolled', scrollY > 40));
await initNav();
const user = await getUser();
const session = user ? await getSession() : null;
const supabase = await getSupabase();
// Get icon ID from URL: /icon/[uuid]
const iconId = window.location.pathname.split('/').pop();
if (!iconId || iconId === 'icon') {
window.location.href = '/library';
}
// Load icon + comments
const { data: icon, error } = await supabase
.from('icons')
.select('*')
.eq('id', iconId)
.single();
if (error || !icon || icon.hidden) {
document.getElementById('page-content').innerHTML = `
<div class="not-found">
<span class="material-icons">search_off</span>
<h2>Icon not found</h2>
<p>This icon may have been removed or the link is incorrect.</p>
<a href="/library" style="color:var(--accent); text-decoration:none; font-weight:600;">Browse the library →</a>
</div>`;
document.title = 'Icon Not Found — Sednicon';
return;
}
// Update page title/meta
document.title = `${icon.prompt.slice(0, 60)} — Sednicon`;
const { data: comments } = await supabase
.from('icon_comments')
.select('id, body, created_at, user_id')
.eq('icon_id', iconId)
.order('created_at', { ascending: true })
.limit(50);
// Check if user liked this icon
let userLiked = false;
if (user) {
const { data: like } = await supabase
.from('icon_likes')
.select('icon_id')
.eq('icon_id', iconId)
.eq('user_id', user.id)
.single();
userLiked = !!like;
}
const iconUrl = `https://sednicon.sednium.com/api/render?q=ai:${icon.id}`;
let activeTab = 'url';
const snippets = {
url: iconUrl,
html: `<img src="${iconUrl}" width="${icon.size}" height="${icon.size}" alt="${icon.prompt.slice(0,40)}" />`,
react: `<img src={\`${iconUrl}\`} width={${icon.size}} height={${icon.size}} alt="${icon.prompt.slice(0,40)}" />`,
css: `.icon {\n background-image: url('${iconUrl}');\n width: ${icon.size}px;\n height: ${icon.size}px;\n}`,
};
document.getElementById('page-content').innerHTML = `
<div class="icon-layout">
<div class="icon-preview-card">
<div class="icon-preview-area">
${icon.svg}
</div>
<div class="icon-preview-actions">
<button class="btn-action-full primary" id="btn-copy-svg">
<span class="material-icons">code</span> Copy SVG
</button>
<button class="btn-action-full" id="btn-copy-url">
<span class="material-icons">link</span> Copy URL
</button>
<button class="btn-action-full ${userLiked ? 'liked' : ''}" id="btn-like">
<span class="material-icons">${userLiked ? 'favorite' : 'favorite_border'}</span>
<span class="like-count" id="like-count">${icon.likes ?? 0}</span> likes
</button>
<button class="btn-report" id="btn-report">
<span class="material-icons">flag</span> Report
</button>
</div>
</div>
<div class="icon-details">
<div>
<div style="font-size:11px; font-weight:600; letter-spacing:0.1em; text-transform:uppercase; color:var(--text-dim); margin-bottom:8px;">Prompt</div>
<div class="icon-prompt">${icon.prompt}</div>
</div>
<div class="icon-meta-row">
<div class="meta-chip"><span class="material-icons">psychology</span>${icon.provider} · ${icon.model ?? 'auto'}</div>
<div class="meta-chip"><span class="material-icons">aspect_ratio</span>${icon.size}×${icon.size}px</div>
<div class="meta-chip"><span class="material-icons">palette</span>#${icon.color}</div>
<div class="meta-chip"><span class="material-icons">schedule</span>${new Date(icon.created_at).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}</div>
</div>
<div class="snippets-card">
<div class="snippet-tabs">
${Object.keys(snippets).map(tab => `<div class="snippet-tab ${tab === activeTab ? 'active' : ''}" data-tab="${tab}">${tab.toUpperCase()}</div>`).join('')}
</div>
<div class="snippet-body">
<pre class="snippet-pre" id="snippet-pre">${escapeHtml(snippets[activeTab])}</pre>
<button class="btn-copy-snippet" id="btn-copy-snippet">Copy</button>
</div>
</div>
<div class="comments-card">
<div class="comments-header">${comments?.length ?? 0} Comments</div>
<div class="comments-list" id="comments-list">
${comments?.length ? comments.map(c => `
<div class="comment">
<div class="comment-avatar-placeholder"><span class="material-icons">person</span></div>
<div class="comment-body">
<span class="comment-author">Community member</span>
<span class="comment-time">${new Date(c.created_at).toLocaleDateString()}</span>
<div class="comment-text">${escapeHtml(c.body)}</div>
</div>
</div>
`).join('') : '<div class="comments-empty">No comments yet. Be the first!</div>'}
</div>
<div class="comment-form">
${user
? `<input class="comment-input" id="comment-input" placeholder="Add a comment..." maxlength="500"/>
<button class="btn-comment-submit" id="btn-comment-submit">Post</button>`
: `<button class="btn-comment-submit" id="btn-comment-signin" style="width:100%;">Sign in to comment</button>`}
</div>
</div>
</div>
</div>
`;
// ── Snippet tabs ──
document.querySelectorAll('.snippet-tab').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('.snippet-tab').forEach(t => t.classList.remove('active'));
tab.classList.add('active');
activeTab = tab.dataset.tab;
document.getElementById('snippet-pre').textContent = snippets[activeTab];
});
});
// ── Copy snippet ──
document.getElementById('btn-copy-snippet').addEventListener('click', async () => {
await navigator.clipboard.writeText(snippets[activeTab]);
const btn = document.getElementById('btn-copy-snippet');
btn.textContent = 'Copied!';
setTimeout(() => btn.textContent = 'Copy', 2000);
});
// ── Copy SVG ──
document.getElementById('btn-copy-svg').addEventListener('click', async () => {
await navigator.clipboard.writeText(icon.svg);
const btn = document.getElementById('btn-copy-svg');
btn.innerHTML = '<span class="material-icons">check</span> Copied!';
setTimeout(() => btn.innerHTML = '<span class="material-icons">code</span> Copy SVG', 2000);
});
// ── Copy URL ──
document.getElementById('btn-copy-url').addEventListener('click', async () => {
await navigator.clipboard.writeText(iconUrl);
const btn = document.getElementById('btn-copy-url');
btn.innerHTML = '<span class="material-icons">check</span> Copied!';
setTimeout(() => btn.innerHTML = '<span class="material-icons">link</span> Copy URL', 2000);
});
// ── Like ──
let likeCount = icon.likes ?? 0;
document.getElementById('btn-like').addEventListener('click', async () => {
if (!user) { signInWithGoogle(); return; }
const btn = document.getElementById('btn-like');
if (userLiked) {
await supabase.from('icon_likes').delete().eq('icon_id', iconId).eq('user_id', user.id);
likeCount = Math.max(0, likeCount - 1);
userLiked = false;
btn.classList.remove('liked');
btn.querySelector('.material-icons').textContent = 'favorite_border';
} else {
await supabase.from('icon_likes').insert({ icon_id: iconId, user_id: user.id });
likeCount++;
userLiked = true;
btn.classList.add('liked');
btn.querySelector('.material-icons').textContent = 'favorite';
}
// Update like count in DB
await supabase.from('icons').update({ likes: likeCount }).eq('id', iconId);
document.getElementById('like-count').textContent = likeCount;
});
// ── Comment ──
if (user) {
document.getElementById('btn-comment-submit').addEventListener('click', async () => {
const input = document.getElementById('comment-input');
const body = input.value.trim();
if (!body) return;
const { data: comment } = await supabase
.from('icon_comments')
.insert({ icon_id: iconId, user_id: user.id, body })
.select().single();
if (comment) {
input.value = '';
const list = document.getElementById('comments-list');
if (list.querySelector('.comments-empty')) list.innerHTML = '';
const div = document.createElement('div');
div.className = 'comment';
div.innerHTML = `
<div class="comment-avatar-placeholder"><span class="material-icons">person</span></div>
<div class="comment-body">
<span class="comment-author">${user.user_metadata?.full_name ?? 'You'}</span>
<span class="comment-time">Just now</span>
<div class="comment-text">${escapeHtml(body)}</div>
</div>`;
list.appendChild(div);
}
});
} else {
document.getElementById('btn-comment-signin')?.addEventListener('click', signInWithGoogle);
}
// ── Report ──
document.getElementById('btn-report').addEventListener('click', async () => {
if (!user) { signInWithGoogle(); return; }
if (!confirm('Report this icon as inappropriate?')) return;
await supabase.from('icon_reports').upsert({ icon_id: iconId, user_id: user.id, reason: 'inappropriate' });
document.getElementById('btn-report').textContent = 'Reported';
document.getElementById('btn-report').disabled = true;
});
function escapeHtml(str) {
return str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
}
</script>
</body>
</html>