Skip to content

AI-native design editor. Open-source Figma alternative.

Add minimalist splash loader during WASM initialization

Danila Poyarkovaa083206d94c
diff --git a/index.html b/index.html
index 21824c36a..1fc3e904c 100644
--- a/index.html
+++ b/index.html
@@ -5,10 +5,54 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenPencil</title>
-
+ <style>
+ body { margin: 0; background: #1e1e1e; }
+ #loader {
+ position: fixed;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 9999;
+ background: #1e1e1e;
+ transition: opacity 0.3s;
+ }
+ #loader.fade-out { opacity: 0; pointer-events: none; }
+ #loader svg { width: 32px; height: 32px; opacity: 0.4; }
+ #loader .bar {
+ position: absolute;
+ bottom: 50%;
+ left: 50%;
+ transform: translate(-50%, 40px);
+ width: 100px;
+ height: 2px;
+ background: rgba(255,255,255,0.08);
+ border-radius: 1px;
+ overflow: hidden;
+ }
+ #loader .bar::after {
+ content: '';
+ display: block;
+ height: 100%;
+ width: 40%;
+ background: rgba(255,255,255,0.25);
+ border-radius: 1px;
+ animation: slide 1s ease-in-out infinite;
+ }
+ @keyframes slide {
+ 0% { transform: translateX(-100%); }
+ 100% { transform: translateX(350%); }
+ }
+ </style>
</head>
<body>
+ <div id="loader">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" style="color: white">
+ <path d="m15.232 5.232 3.536 3.536m-2.036-5.036a2.5 2.5 0 0 1 3.536 3.536L6.5 21.036H3v-3.572L16.732 3.732Z"/>
+ </svg>
+ <div class="bar"></div>
+ </div>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
diff --git a/src/composables/use-canvas.ts b/src/composables/use-canvas.ts
index 2dc5ce65c..89c8601d3 100644
--- a/src/composables/use-canvas.ts
+++ b/src/composables/use-canvas.ts
@@ -21,6 +21,12 @@ export function useCanvas(canvasRef: Ref<HTMLCanvasElement | null>, store: Edito
await new Promise((r) => requestAnimationFrame(r))
createSurface(canvas)
+
+ const loader = document.getElementById('loader')
+ if (loader) {
+ loader.classList.add('fade-out')
+ setTimeout(() => loader.remove(), 300)
+ }
}
function createSurface(canvas: HTMLCanvasElement) {