BriranSus commited on
Commit
da41992
·
1 Parent(s): c3c6ba2

feat: fix alert css

Browse files
Files changed (1) hide show
  1. app.py +67 -24
app.py CHANGED
@@ -312,27 +312,41 @@ def close_modal():
312
  # JS for Copying text and Toggling Modal
313
  js_head = """
314
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  function copyToClipboard(text) {
316
  if (!text) {
317
- alert("No caption to copy!");
318
  return;
319
  }
320
 
321
  navigator.clipboard.writeText(text).then(function() {
322
- const toast = document.createElement("div");
323
- toast.innerText = "Caption Copied!";
324
- toast.style.position = "fixed";
325
- toast.style.bottom = "20px";
326
- toast.style.right = "20px";
327
- toast.style.backgroundColor = "#10B981";
328
- toast.style.color = "#FFFFFF";
329
- toast.style.padding = "10px 20px";
330
- toast.style.borderRadius = "5px";
331
- toast.style.zIndex = "9999";
332
- toast.style.boxShadow = "0 4px 6px rgba(0,0,0,0.1)";
333
- document.body.appendChild(toast);
334
- setTimeout(() => toast.remove(), 2000);
335
  }, function(err) {
 
336
  console.error('Async: Could not copy text: ', err);
337
  });
338
  }
@@ -353,28 +367,57 @@ body { background-color: #111827; }
353
  }
354
  .loading-box { animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  /* Modal Floating Style */
357
  .modal-container {
358
  position: fixed !important;
359
  top: 0;
360
  left: 0;
361
- width: 100%;
362
- height: 100%;
363
  background-color: rgba(0,0,0,0.8);
364
  z-index: 9999;
365
- display: flex;
366
- justify-content: center;
367
- align-items: center;
368
- backdrop-filter: blur(5px);
369
  }
370
  .modal-content-box {
 
 
 
 
 
371
  background-color: #1F2937;
372
- padding: 30px;
373
  border: 1px solid #374151;
374
- border-radius: 10px;
375
  width: 90%;
376
- max-width: 600px;
377
- box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
378
  color: #F3F4F6;
379
  }
380
  code {
 
312
  # JS for Copying text and Toggling Modal
313
  js_head = """
314
  <script>
315
+ function showToast(message, type) {
316
+ // Create Toast Element
317
+ const toast = document.createElement("div");
318
+ toast.className = "toast";
319
+ toast.innerText = message;
320
+
321
+ // Color Logic
322
+ if (type === 'error') {
323
+ toast.style.backgroundColor = "#EF4444"; // Red
324
+ toast.style.color = "#FFFFFF";
325
+ } else {
326
+ toast.style.backgroundColor = "#10B981"; // Green
327
+ toast.style.color = "#FFFFFF";
328
+ }
329
+
330
+ document.body.appendChild(toast);
331
+
332
+ // Remove after animation/timeout
333
+ setTimeout(() => {
334
+ toast.classList.add('hiding');
335
+ // Wait for fadeOut animation to finish before removing
336
+ toast.addEventListener('animationend', () => toast.remove());
337
+ }, 2500);
338
+ }
339
+
340
  function copyToClipboard(text) {
341
  if (!text) {
342
+ showToast("No caption to copy!", "error");
343
  return;
344
  }
345
 
346
  navigator.clipboard.writeText(text).then(function() {
347
+ showToast("Caption Copied!", "success");
 
 
 
 
 
 
 
 
 
 
 
 
348
  }, function(err) {
349
+ showToast("Failed to copy", "error");
350
  console.error('Async: Could not copy text: ', err);
351
  });
352
  }
 
367
  }
368
  .loading-box { animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
369
 
370
+ @keyframes slideUpFadeIn {
371
+ from { opacity: 0; transform: translate(-50%, 100%); }
372
+ to { opacity: 1; transform: translate(-50%, 0); }
373
+ }
374
+
375
+ @keyframes fadeOutSlideDown {
376
+ from { opacity: 1; transform: translate(-50%, 0); }
377
+ to { opacity: 0; transform: translate(-50%, 100%); }
378
+ }
379
+
380
+ .toast {
381
+ position: fixed;
382
+ bottom: 30px;
383
+ left: 50%;
384
+ transform: translate(-50%, 0); /* Center horizontally */
385
+ padding: 12px 24px;
386
+ border-radius: 8px;
387
+ z-index: 10000;
388
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
389
+ font-weight: 500;
390
+ animation: slideUpFadeIn 0.5s ease forwards;
391
+ }
392
+
393
+ .toast.hiding {
394
+ animation: fadeOutSlideDown 0.5s ease forwards;
395
+ }
396
+
397
  /* Modal Floating Style */
398
  .modal-container {
399
  position: fixed !important;
400
  top: 0;
401
  left: 0;
402
+ width: 100vw;
403
+ height: 100vh;
404
  background-color: rgba(0,0,0,0.8);
405
  z-index: 9999;
406
+ backdrop-filter: blur(3px);
 
 
 
407
  }
408
  .modal-content-box {
409
+ position: absolute;
410
+ top: 50%;
411
+ left: 50%;
412
+ transform: translate(-50%, -50%);
413
+
414
  background-color: #1F2937;
415
+ padding: 25px;
416
  border: 1px solid #374151;
417
+ border-radius: 12px;
418
  width: 90%;
419
+ max-width: 450px; /* Smaller width as requested */
420
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
421
  color: #F3F4F6;
422
  }
423
  code {