Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Start adding post download success dialog

Scott Petrovic985e93f39672
diff --git a/src/dialog.css b/src/dialog.css
index d144e1d..94a7e68 100644
--- a/src/dialog.css
+++ b/src/dialog.css
@@ -204,3 +204,80 @@
margin-top: 1rem;
}
+/* ── Download Success Dialog ── */
+
+.download-success-dialog-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 10000;
+}
+
+.download-success-dialog-content {
+ background: var(--bg-primary);
+ border-radius: 8px;
+ padding: 2rem;
+ max-width: 600px;
+ max-height: 80vh;
+ overflow-y: auto;
+ box-shadow: 0 0 5rem rgba(0, 0, 0, 0.5);
+ animation: download-success-bounce-in 0.3s ease-out;
+ color: var(--text-primary);
+}
+
+@keyframes download-success-bounce-in {
+ 0% {
+ transform: scale(0.4);
+ opacity: 0;
+ }
+ 70% {
+ transform: scale(1.1);
+ opacity: 1;
+ }
+ 100% {
+ transform: scale(1);
+ }
+}
+
+.download-success-dialog-content h2 {
+ margin: 0 0 1.5rem 0;
+ font-size: 1.8rem;
+ color: var(--text-primary);
+}
+
+.download-success-dialog-body {
+ color: var(--text-primary);
+ font-size: 1rem;
+ line-height: 1.5;
+}
+
+.download-success-dialog-body p {
+ margin: 0.5rem 0;
+}
+
+.download-success-dialog-close {
+ margin-top: 1.5rem;
+ padding: 0.75rem 1.5rem;
+ font-size: 1rem;
+ cursor: pointer;
+ border: none;
+ border-radius: 4px;
+ background: var(--button-primary-bg);
+ color: var(--button-primary-text);
+ transition: opacity 0.2s;
+}
+
+.download-success-dialog-close:hover {
+ opacity: 0.8;
+}
+
+.download-success-dialog-close:active {
+ opacity: 0.9;
+}
+
diff --git a/src/lib/DownloadSuccessDialog.ts b/src/lib/DownloadSuccessDialog.ts
new file mode 100644
index 0000000..6cce91b
--- /dev/null
+++ b/src/lib/DownloadSuccessDialog.ts
@@ -0,0 +1,40 @@
+export class DownloadSuccessDialog {
+ private dialog_element: HTMLDivElement | null = null
+ private readonly title = 'Export Successful'
+ private readonly content_html = '<p>Your animation export is ready!</p>'
+
+ constructor (private readonly options?: { onClose?: () => void }) {}
+
+ public show (): void {
+ this.remove()
+ this.dialog_element = document.createElement('div')
+ this.dialog_element.className = 'download-success-dialog-overlay'
+
+ // HTML template for the content
+ this.dialog_element.innerHTML = `
+ <div class="download-success-dialog-content">
+ <h2>${this.title}</h2>
+ <div class="download-success-dialog-body">${this.content_html}</div>
+ <button class="download-success-dialog-close">Close</button>
+ </div>
+ `
+ document.body.appendChild(this.dialog_element)
+
+ // Close button handler
+ const close_button = this.dialog_element.querySelector('.download-success-dialog-close')
+ close_button?.addEventListener('click', () => { this.remove() })
+
+ // Close on overlay click
+ this.dialog_element.addEventListener('click', (e) => {
+ if (e.target === this.dialog_element) this.remove()
+ })
+ }
+
+ private remove (): void {
+ if (this.dialog_element && this.dialog_element.parentNode) {
+ this.dialog_element.parentNode.removeChild(this.dialog_element)
+ this.dialog_element = null
+ if (this.options?.onClose) this.options.onClose()
+ }
+ }
+}
diff --git a/src/lib/EventListeners.ts b/src/lib/EventListeners.ts
index 94c24e7..660ca89 100644
--- a/src/lib/EventListeners.ts
+++ b/src/lib/EventListeners.ts
@@ -4,6 +4,7 @@ import { ProcessStep } from './enums/ProcessStep'
import { TransformSpace } from './enums/TransformSpace'
import { Utility } from './Utilities'
import { ModelCleanupUtility } from './processes/load-model/ModelCleanupUtility'
+import { DownloadSuccessDialog } from './DownloadSuccessDialog'
import { type Bone } from 'three'
export class EventListeners {
@@ -203,6 +204,7 @@ export class EventListeners {
'exported-model',
this.bootstrap.download_settings
)
+ new DownloadSuccessDialog().show()
})
// going back to edit skeleton step after skinning