-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
352 lines (305 loc) · 14 KB
/
Copy pathindex.html
File metadata and controls
352 lines (305 loc) · 14 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Prompt Manager</title>
<link rel="icon" type="image/svg+xml" href="assets/favicon.svg" />
<script src="https://cdn.tailwindcss.com"></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:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined"
rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#4863F7',
secondary: '#7878D7',
background: '#111111',
border: '#424242',
textPrimary: '#FFFFFF',
textSecondary: '#737373',
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
}
},
},
};
</script>
<style>
/* Ajuste o scrollbar para melhor visualização no desktop */
#promptList {
max-height: calc(100vh - 300px);
overflow-y: auto;
}
.prompt-item:hover {
background-color: rgba(72, 99, 247, 0.1);
}
/* ⭐️ Estilos base para os Google Material Icons */
.material-icons-outlined {
font-family: 'Material Icons Outlined';
font-weight: normal;
font-style: normal;
font-size: 1.25rem; /* Padrão 20px (w-5 h-5) */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
}
/* Para ícones de 24px (w-6 h-6) */
.material-icons-lg {
font-size: 1.5rem; /* 24px */
}
</style>
</head>
<body class="bg-[#0D0D0D] text-textPrimary font-sans">
<div class="relative min-h-screen">
<div id="backdrop" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden md:hidden"></div>
<div class="flex flex-col md:flex-row h-screen">
<aside id="sidebar" class="sidebar fixed top-0 bottom-0 left-0 z-50 w-11/12 max-w-[400px] bg-[#111111] p-8 border-r border-border transform -translate-x-full md:translate-x-0 md:relative md:transform-none transition-transform duration-300">
<div class="flex justify-between items-center mb-6">
<div class="flex items-center gap-4">
<img src="assets/logo.svg" alt="Logo" class="w-22 h-8" />
</div>
<button id="closeSidebar" class="md:hidden p-2">
<span class="material-icons-outlined material-icons-lg">close</span>
</button>
</div>
<div class="flex flex-col gap-8">
<div class="flex flex-col gap-3">
<input id="searchInput" type="text" placeholder="Buscar por título..." class="w-full p-3 bg-[#0C0F12] border border-border rounded text-sm text-textPrimary h-11 focus:outline-none focus:border-primary" />
<button id="newPromptBtn" class="w-full bg-primary hover:bg-secondary text-textPrimary text-sm h-11 rounded transition duration-200">Novo prompt</button>
</div>
<hr class="border-border" />
<ul id="promptList" class="space-y-4"></ul>
</div>
</aside>
<main class="flex-1 p-6 md:py-[62px] md:px-[124px] md:ml-[400px] transition-all duration-300 overflow-y-auto">
<header class="flex justify-between items-center mb-8">
<div class="flex items-center gap-4">
<button id="openSidebar" class="md:hidden p-2" title="Abrir Menu">
<span class="material-icons-outlined material-icons-lg">menu</span>
</button>
</div>
<div class="flex gap-4">
<button class="btn-copy flex items-center gap-2 bg-[rgba(27,27,27,0.3)] border border-border text-sm px-6 py-2 rounded hover:bg-opacity-50 transition duration-200">
<span class="material-icons-outlined">content_copy</span>
<span>Copiar</span>
</button>
<button class="btn-save bg-primary hover:bg-secondary text-textPrimary text-sm px-6 py-2 rounded transition duration-200">Salvar</button>
</div>
</header>
<input id="titleInput" type="text" placeholder="⚡ Título do seu prompt" class="w-full text-[24px] md:text-[32px] font-semibold bg-transparent border-b border-border focus:outline-none focus:border-primary mb-6 pb-2" />
<textarea id="contentInput" placeholder="Digite o conteúdo do seu prompt aqui..." class="w-full h-96 md:h-[calc(100vh-250px)] bg-transparent border border-border rounded p-4 focus:outline-none focus:border-primary text-[16px] leading-[1.8em] text-textPrimary resize-none"></textarea>
</main>
</div>
</div>
<nav class="fixed bottom-4 left-1/2 transform -translate-x-1/2 md:hidden z-50">
<div class="bg-[#0C0F12] border border-border rounded-full px-3 py-2 flex items-center gap-3 shadow-xl">
<button id="mobileMenuBtn" class="p-2" title="Menu">
<span class="material-icons-outlined">menu</span>
</button>
<button id="mobileSearchBtn" class="p-2" title="Buscar">
<span class="material-icons-outlined">search</span>
</button>
<button id="mobileNewBtn" class="bg-primary hover:bg-secondary text-textPrimary text-sm px-3 py-2 rounded transition duration-200">Novo</button>
</div>
</nav>
<script>
// O código JS não precisa de grandes alterações, apenas na parte do renderList para o ícone de remoção.
// UI elements
const sidebar = document.getElementById('sidebar');
const backdrop = document.getElementById('backdrop');
const openBtn = document.getElementById('openSidebar');
const closeBtn = document.getElementById('closeSidebar');
const promptListEl = document.getElementById('promptList');
const newPromptBtn = document.getElementById('newPromptBtn');
const searchInput = document.getElementById('searchInput');
const titleInput = document.getElementById('titleInput');
const contentInput = document.getElementById('contentInput');
const copyBtn = document.querySelector('.btn-copy');
const saveBtn = document.querySelector('.btn-save');
const STORAGE_KEY = 'prompts_manager_v1';
let prompts = [];
let selectedId = null;
// === Drawer helpers (mantido) ===
function openSidebar() {
if (window.innerWidth < 768) {
sidebar.classList.remove('-translate-x-full');
sidebar.classList.add('translate-x-0');
backdrop.classList.remove('hidden');
document.body.style.overflow = 'hidden';
}
}
function closeSidebar() {
if (window.innerWidth < 768) {
sidebar.classList.add('-translate-x-full');
sidebar.classList.remove('translate-x-0');
backdrop.classList.add('hidden');
document.body.style.overflow = '';
}
}
openBtn && openBtn.addEventListener('click', openSidebar);
closeBtn && closeBtn.addEventListener('click', closeSidebar);
backdrop && backdrop.addEventListener('click', closeSidebar);
// === Persistence (mantido) ===
function loadPrompts() {
try {
const raw = localStorage.getItem(STORAGE_KEY);
prompts = raw ? JSON.parse(raw).sort((a, b) => b.id - a.id) : [];
} catch (e) {
console.error("Erro ao carregar prompts:", e);
prompts = [];
}
}
function savePrompts() {
localStorage.setItem(STORAGE_KEY, JSON.stringify(prompts));
}
// === Prompt Logic ===
function renderList(filter = '') {
promptListEl.innerHTML = '';
const filtered = prompts.filter(p => p.title.toLowerCase().includes(filter.toLowerCase()));
if (filtered.length === 0) {
const empty = document.createElement('div');
empty.className = 'text-[13px] text-textSecondary text-center mt-4';
empty.textContent = 'Nenhum prompt encontrado. Crie um novo!';
promptListEl.appendChild(empty);
return;
}
filtered.forEach(p => {
const isSelected = p.id === selectedId;
const li = document.createElement('li');
li.className = `prompt-item flex justify-between items-start gap-4 p-2 rounded ${isSelected ? 'bg-secondary/20' : ''}`;
const info = document.createElement('div');
info.className = 'flex-1 cursor-pointer';
const t = document.createElement('div');
t.className = 'text-[14px] font-medium truncate';
t.textContent = p.title || 'Sem título';
const d = document.createElement('div');
d.className = 'text-[12px] text-textSecondary truncate';
d.textContent = p.content ? (p.content.substring(0, 60) + (p.content.length > 60 ? '...' : '')) : 'Vazio...';
info.appendChild(t);
info.appendChild(d);
info.addEventListener('click', () => selectPrompt(p.id));
const delBtn = document.createElement('button');
delBtn.className = 'ml-4 p-1 hover:bg-border rounded transition duration-200 shrink-0';
// ⭐️ Criação do Material Icon para o botão de remover
const delIcon = document.createElement('span');
delIcon.className = 'material-icons-outlined text-base';
delIcon.textContent = 'delete';
delIcon.setAttribute('title', 'Remover');
delBtn.appendChild(delIcon);
delBtn.addEventListener('click', (ev) => { ev.stopPropagation(); removePrompt(p.id); });
li.appendChild(info);
li.appendChild(delBtn);
promptListEl.appendChild(li);
});
}
function selectPrompt(id) {
const p = prompts.find(x => x.id === id);
if (!p) return;
selectedId = id;
titleInput.value = p.title;
contentInput.value = p.content;
renderList(searchInput.value || '');
if (window.innerWidth < 768) closeSidebar();
}
function removePrompt(id) {
prompts = prompts.filter(p => p.id !== id);
if (selectedId === id) {
selectedId = null;
titleInput.value = '';
contentInput.value = '';
}
savePrompts();
renderList(searchInput.value || '');
if (!selectedId && prompts.length > 0) {
selectPrompt(prompts[0].id);
}
}
function createPrompt() {
const newP = { id: Date.now(), title: 'Novo prompt', content: '' };
prompts.unshift(newP);
savePrompts();
renderList(searchInput.value || '');
selectPrompt(newP.id);
if (window.innerWidth < 768) setTimeout(closeSidebar, 200);
}
function saveCurrent() {
if (!titleInput.value && !contentInput.value) {
alert('O título ou o conteúdo do prompt não podem estar vazios para salvar.');
return;
}
if (!selectedId) {
const newP = { id: Date.now(), title: titleInput.value || 'Sem título', content: contentInput.value || '' };
prompts.unshift(newP);
selectedId = newP.id;
} else {
const idx = prompts.findIndex(p => p.id === selectedId);
if (idx >= 0) {
prompts[idx].title = titleInput.value;
prompts[idx].content = contentInput.value;
}
}
prompts.sort((a, b) => b.id - a.id);
savePrompts();
renderList(searchInput.value || '');
}
function copyContent() {
const text = `${titleInput.value}\n\n${contentInput.value}`;
navigator.clipboard && navigator.clipboard.writeText(text).then(() => {
copyBtn.querySelector('span').textContent = 'Copiado!';
setTimeout(() => {
copyBtn.querySelector('span').textContent = 'Copiar';
}, 1500);
}).catch(err => {
console.error('Falha ao copiar:', err);
});
}
// === Events (mantido) ===
newPromptBtn && newPromptBtn.addEventListener('click', createPrompt);
saveBtn && saveBtn.addEventListener('click', saveCurrent);
copyBtn && copyBtn.addEventListener('click', copyContent);
searchInput && searchInput.addEventListener('input', (e) => renderList(e.target.value));
const mobileMenuBtn = document.getElementById('mobileMenuBtn');
const mobileSearchBtn = document.getElementById('mobileSearchBtn');
const mobileNewBtn = document.getElementById('mobileNewBtn');
mobileMenuBtn && mobileMenuBtn.addEventListener('click', openSidebar);
mobileSearchBtn && mobileSearchBtn.addEventListener('click', () => {
openSidebar();
setTimeout(() => searchInput && searchInput.focus(), 350);
});
mobileNewBtn && mobileNewBtn.addEventListener('click', createPrompt);
// === Initial Load (mantido) ===
loadPrompts();
renderList();
if (prompts.length > 0) {
selectPrompt(prompts[0].id);
} else {
createPrompt();
}
window.addEventListener('resize', () => {
if (window.innerWidth >= 768) {
sidebar.classList.remove('-translate-x-full');
sidebar.classList.remove('translate-x-0');
backdrop.classList.add('hidden');
document.body.style.overflow = '';
} else {
if (!backdrop.classList.contains('hidden')) {
document.body.style.overflow = 'hidden';
}
}
});
</script>
</body>
</html>