DJAKOUA KWANKAM BRAYAN STEVE commited on
Commit
c49f2ba
·
1 Parent(s): 3da5847

feat: replace alerts with custom toasts

Browse files
cypher-chat-app/public/app.js CHANGED
@@ -168,7 +168,7 @@ function processFiles(files) {
168
  Array.from(files).forEach(file => {
169
  // File size limit 500KB to avoid blowing context window
170
  if (file.size > 500 * 1024) {
171
- alert(`Le fichier "${file.name}" est trop volumineux (max 500 Ko pour les fichiers de code).`);
172
  return;
173
  }
174
 
@@ -177,7 +177,7 @@ function processFiles(files) {
177
  const textContent = event.target.result;
178
  // Check if file is text-based (rough heuristic: check for null bytes)
179
  if (textContent.includes("\0")) {
180
- alert(`Le fichier "${file.name}" semble être binaire. Seuls les fichiers de texte/code sont acceptés.`);
181
  return;
182
  }
183
 
@@ -354,7 +354,7 @@ function renderMessage(role, content) {
354
  shareText += `${m.role === 'user' ? 'Utilisateur' : 'Cypher AI'}:\n${m.content}\n\n`;
355
  });
356
  navigator.clipboard.writeText(shareText).then(() => {
357
- alert("Discussion copiée dans le presse-papiers pour partage !");
358
  });
359
  });
360
 
@@ -848,3 +848,42 @@ function saveSettings() {
848
  // Force rerender messages labels if username changed
849
  loadConversation(currentConversationId);
850
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  Array.from(files).forEach(file => {
169
  // File size limit 500KB to avoid blowing context window
170
  if (file.size > 500 * 1024) {
171
+ showToast(`Le fichier "${file.name}" est trop volumineux (max 500 Ko).`, "error");
172
  return;
173
  }
174
 
 
177
  const textContent = event.target.result;
178
  // Check if file is text-based (rough heuristic: check for null bytes)
179
  if (textContent.includes("\0")) {
180
+ showToast(`Le fichier "${file.name}" semble être binaire. Seuls les fichiers texte sont acceptés.`, "error");
181
  return;
182
  }
183
 
 
354
  shareText += `${m.role === 'user' ? 'Utilisateur' : 'Cypher AI'}:\n${m.content}\n\n`;
355
  });
356
  navigator.clipboard.writeText(shareText).then(() => {
357
+ showToast("Discussion copiée dans le presse-papiers !", "success");
358
  });
359
  });
360
 
 
848
  // Force rerender messages labels if username changed
849
  loadConversation(currentConversationId);
850
  }
851
+
852
+ // Custom Premium Toast Notification System
853
+ function showToast(message, type = "info") {
854
+ let container = document.getElementById("toastContainer");
855
+ if (!container) {
856
+ container = document.createElement("div");
857
+ container.id = "toastContainer";
858
+ container.className = "toast-container";
859
+ document.body.appendChild(container);
860
+ }
861
+
862
+ const toast = document.createElement("div");
863
+ toast.className = `toast-message ${type} animate-fade-in`;
864
+
865
+ let iconName = "info";
866
+ if (type === "success") iconName = "check-circle";
867
+ else if (type === "error") iconName = "alert-triangle";
868
+ else if (type === "warning") iconName = "alert-circle";
869
+
870
+ toast.innerHTML = `
871
+ <i data-lucide="${iconName}"></i>
872
+ <span>${message}</span>
873
+ `;
874
+
875
+ container.appendChild(toast);
876
+ lucide.createIcons({ scope: toast });
877
+
878
+ // Auto-remove after 4 seconds
879
+ setTimeout(() => {
880
+ toast.classList.remove("animate-fade-in");
881
+ toast.classList.add("animate-fade-out");
882
+ toast.addEventListener("animationend", () => {
883
+ toast.remove();
884
+ if (container.children.length === 0) {
885
+ container.remove();
886
+ }
887
+ });
888
+ }, 4000);
889
+ }
cypher-chat-app/public/style.css CHANGED
@@ -1210,3 +1210,78 @@ input:checked + .slider:before {
1210
  background: rgba(30, 34, 53, 0.8);
1211
  }
1212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1210
  background: rgba(30, 34, 53, 0.8);
1211
  }
1212
 
1213
+ /* -----------------------------------------------------
1214
+ CUSTOM TOAST NOTIFICATIONS (GLASSMORPHIC SYSTEM)
1215
+ ----------------------------------------------------- */
1216
+ .toast-container {
1217
+ position: fixed;
1218
+ top: 20px;
1219
+ right: 20px;
1220
+ z-index: 10000;
1221
+ display: flex;
1222
+ flex-direction: column;
1223
+ gap: 10px;
1224
+ max-width: 380px;
1225
+ width: calc(100% - 40px);
1226
+ }
1227
+
1228
+ .toast-message {
1229
+ display: flex;
1230
+ align-items: center;
1231
+ gap: 12px;
1232
+ padding: 12px 16px;
1233
+ border-radius: 10px;
1234
+ font-size: 13.5px;
1235
+ font-weight: 600;
1236
+ color: var(--text-primary);
1237
+ background: rgba(12, 14, 23, 0.9);
1238
+ border: 1px solid var(--border-color);
1239
+ box-shadow: var(--shadow-app);
1240
+ backdrop-filter: blur(10px);
1241
+ transition: all 0.3s ease;
1242
+ }
1243
+
1244
+ .toast-message i {
1245
+ flex-shrink: 0;
1246
+ width: 18px;
1247
+ height: 18px;
1248
+ }
1249
+
1250
+ .toast-message.info {
1251
+ border-color: rgba(0, 229, 255, 0.4);
1252
+ }
1253
+ .toast-message.info i {
1254
+ color: var(--accent-cyan);
1255
+ }
1256
+
1257
+ .toast-message.success {
1258
+ border-color: rgba(0, 255, 170, 0.4);
1259
+ }
1260
+ .toast-message.success i {
1261
+ color: var(--accent-green);
1262
+ }
1263
+
1264
+ .toast-message.warning {
1265
+ border-color: rgba(245, 158, 11, 0.4);
1266
+ }
1267
+ .toast-message.warning i {
1268
+ color: #F59E0B;
1269
+ }
1270
+
1271
+ .toast-message.error {
1272
+ border-color: rgba(239, 68, 68, 0.4);
1273
+ }
1274
+ .toast-message.error i {
1275
+ color: #EF4444;
1276
+ }
1277
+
1278
+ /* Toast Animations */
1279
+ .animate-fade-out {
1280
+ animation: fadeOut 0.3s ease forwards;
1281
+ }
1282
+
1283
+ @keyframes fadeOut {
1284
+ from { opacity: 1; transform: scale(1); }
1285
+ to { opacity: 0; transform: scale(0.95); }
1286
+ }
1287
+