-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
244 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
|
||
export const counterButtonBuilder = ({ loop, resetFn, log, getInputIdFn }) => { | ||
return (val, updateFn, disabled) => { | ||
const button = document.createElement("button"); | ||
|
||
button.id = getInputIdFn(); | ||
button.classList = "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"; | ||
button.classList = | ||
"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"; | ||
button.disabled = disabled; | ||
|
||
button.textContent = val; | ||
|
||
button.addEventListener("click", () => { | ||
const newVal = updateFn(); | ||
|
||
log("new counter", newVal); | ||
|
||
resetFn(); | ||
|
||
requestAnimationFrame(loop); | ||
}); | ||
|
||
return button; | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
import { labelFor } from "../../../src/html.js"; | ||
|
||
export const incrementTextInputBuilder = ({ loop, log, resetFn, getInputIdFn }) => { | ||
export const incrementTextInputBuilder = ({ | ||
loop, | ||
log, | ||
resetFn, | ||
getInputIdFn, | ||
}) => { | ||
return (initVal, updateFn) => { | ||
const numberInput = document.createElement('input'); | ||
const numberInput = document.createElement("input"); | ||
|
||
numberInput.id = getInputIdFn(); | ||
numberInput.type = 'number'; | ||
|
||
numberInput.min = '1'; | ||
numberInput.max = '5'; | ||
|
||
numberInput.classList = "px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"; | ||
numberInput.style = "width: auto;" | ||
numberInput.type = "number"; | ||
|
||
numberInput.min = "1"; | ||
numberInput.max = "5"; | ||
|
||
numberInput.classList = | ||
"px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"; | ||
numberInput.style = "width: auto;"; | ||
numberInput.value = initVal; | ||
|
||
numberInput.addEventListener("change", (event) => { | ||
const currentVal = event.target.value; | ||
const newVal = updateFn(parseInt(currentVal)) | ||
const newVal = updateFn(parseInt(currentVal)); | ||
|
||
log("increment set to", newVal); | ||
resetFn(); | ||
|
||
resetFn(); | ||
requestAnimationFrame(loop); | ||
}); | ||
|
||
return labelFor({ | ||
input: numberInput, | ||
classList: "text-sm font-medium text-gray-700 mr-3", | ||
text: "Increment Value" | ||
return labelFor({ | ||
input: numberInput, | ||
classList: "text-sm font-medium text-gray-700 mr-3", | ||
text: "Increment Value", | ||
}); | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
|
||
export const resetButtonBuilder = ({ loop, log, resetFn, getInputIdFn }) => { | ||
return (updateFn) => { | ||
let button = document.createElement("button"); | ||
button.id = getInputIdFn(); | ||
button.classList = "bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-1 px-3 rounded"; | ||
button.classList = | ||
"bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-1 px-3 rounded"; | ||
|
||
button.textContent = "Reset Counter"; | ||
|
||
button.addEventListener("click", () => { | ||
const newVal = updateFn(); | ||
|
||
log("reset counter to", newVal); | ||
|
||
resetFn(); | ||
|
||
requestAnimationFrame(loop); | ||
}); | ||
|
||
return button; | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ export function logger({ state }) { | |
if (state.debug) { | ||
console.log(...text); | ||
} | ||
} | ||
}; | ||
} |
Oops, something went wrong.