import { html } from "https://esm.town/v/stevekrouse/html";
const WebPage = () => (
<html>
<head>
<style>
{`
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #f27373, #f5ad1b);
font-family: 'Comic Sans MS', cursive, sans-serif;
color: white;
animation: backgroundAnimation 5s ease infinite;
}
@keyframes backgroundAnimation {
0% { background-color: #f27373; }
50% { background-color: #f5ad1b; }
100% { background-color: #f27373; }
}
#wordle {
display: grid;
grid-template-columns: repeat(5, 45px);
grid-gap: 5px;
}
.letter {
width: 40px;
height: 40px;
background-color: #333;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5em;
border-radius: 10px;
animation: pop 0.3s ease-in-out;
}
@keyframes pop {
0% { transform: scale(0.8); }
100% { transform: scale(1); }
}
`}
</style>
<script>
{`
let word = "CRANE"; // Change this for different words
let currentRow = 0;
const rows = [['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', '']];
function updateBoard() {
let html = '';
for (row of rows) {
for (cell of row) {
html += '<div class="letter">' + cell + '</div>';
}
}
document.getElementById('wordle').innerHTML = html;
}
document.addEventListener('keydown', (event) => {
const key = event.key.toUpperCase();
if (key === 'ENTER') {
currentRow++;
return;
} else if (key === 'BACKSPACE') {
rows[currentRow] = rows[currentRow].slice(0, -1);
} else if (key.match(/^[A-Z]$/)) {
if (rows[currentRow].length < 5) {
rows[currentRow].push(key);
}
}
updateBoard();
});
updateBoard();
`}
</script>
</head>
<body>
<div id="wordle"></div>
</body>
</html>
);
export default function main(): Response {
return html(<WebPage />);
}