Skip to content

Commit

Permalink
fix: submit button handler
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Apr 17, 2023
1 parent 8ee1b45 commit 268b5c2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div
class="h-1/4 flex order-2 sm:order-1 justify-center items-center w-full"
>
<form method="GET">
<form method="GET" action="javascript:void 0">
<div class="w-3/4 sm:w-1/2 mx-auto">
<label class="relative w-full">
<input
Expand All @@ -25,6 +25,7 @@
name="color"
/>
<button
id="color-input-button"
type="submit"
class="absolute inline-block top-1/2 right-1 px-4 py-2 rounded-md -translate-y-1/2 bg-accent text-on-accent"
>
Expand Down
8 changes: 8 additions & 0 deletions www/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function renderColors({color, container} = {}) {

function init() {
const colorInput = document.getElementById('color-input')
const submitButton = document.getElementById('color-input-button')
const colorContainer = document.getElementById('color-container')

const initialColor = '#18181b'
Expand All @@ -180,6 +181,13 @@ function init() {
container: colorContainer,
})

submitButton.addEventListener('click', e => {
renderColors({
color: colorInput.value,
container: colorContainer,
})
})

colorInput.addEventListener('keyup', e => {
if (e.key.toLowerCase() !== 'enter') {
return
Expand Down
19 changes: 12 additions & 7 deletions www/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion www/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ body,
html {
font-family: 'Inter var', sans-serif;
}
}
}

0 comments on commit 268b5c2

Please sign in to comment.