class LoaderPreview extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; this.canvas = this.shadowRoot.getElementById('loader-canvas'); this.ctx = this.canvas.getContext('2d'); this.setupCanvas(); this.startAnimation(); } setupCanvas() { const container = this.shadowRoot.querySelector('.preview-container'); this.canvas.width = container.clientWidth; this.canvas.height = container.clientHeight; } startAnimation() { const animate = () => { this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); // Draw custom loader animation using canvas API const time = Date.now() * 0.001; const centerX = this.canvas.width / 2; const centerY = this.canvas.height / 2; const radius = Math.min(this.canvas.width, this.canvas.height) * 0.3; this.ctx.beginPath(); this.ctx.arc(centerX, centerY, radius, time % (Math.PI * 2), (time + Math.PI) % (Math.PI * 2)); this.ctx.lineWidth = 8; this.ctx.strokeStyle = '#3b82f6'; this.ctx.stroke(); requestAnimationFrame(animate); }; animate(); } } customElements.define('loader-preview', LoaderPreview);