import { LitElement, html, css, type PropertyDeclarations } from "lit" export default class Element extends LitElement { static override styles = css` .dinosaur-container { position: relative; width: full; height: 100px; overflow: hidden; /* Ensures the animation stays within bounds */ } .dinosaur { width: 100px; height: 100px; position: absolute; animation: walk 6s linear infinite; } @keyframes walk { 0% { left: 0; transform: scaleX(-1); /* Face right */ } 50% { left: calc(100% - 100px); /* Move to the right edge */ transform: scaleX(-1); /* Face right */ } 50.01% { transform: scaleX(1); /* Flip to face left */ } 100% { left: 0; /* Move back to the left edge */ transform: scaleX(1); /* Face left */ } } ` color: string static override properties = { color: { type: String }, } constructor() { super() this.color = "green" } /** * Generates a random color in hexadecimal format. * @returns {string} - The random color. */ randomColor(): string { const letters = "0123456789ABCDEF" let color = "#" for (let i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)] } return color } override render() { console.log("render") return html`
` } } customElements.define("walking-dinosaur", Element)