Published
Edited
May 16, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof badGuessColor = Inputs.color({value: "#bb0000"})
Insert cell
viewof goodGuessColor = Inputs.color({value: "#16a716"})
Insert cell
viewof outerCirclerColor = Inputs.color({value: "#e5c348"})
Insert cell
viewof backgroundColor = Inputs.color({value: "#dbd6d6"})
Insert cell
focus = {
//feels like there's a better way to do this
guess;
document.getElementById('guess').focus()
}
Insert cell
drawRecord = (x) => {
return htl.html.fragment `<tr>
<td style="color:${x.points ? goodGuessColor : badGuessColor}">${x.guess}</td>
<td style="color:${x.points ? goodGuessColor : badGuessColor}">${x.currentWord}</td>
<td>${x.currentWord.length}</td>
</tr>
`
}
Insert cell
circlePts = (word,cx,cy,r) => {
let letters = word.split('')
let n = word.length
let angle = Math.PI * 2 / n
const pts = []
for (let i = 0; i < n; i++) {
pts.push({
x: cx + r * Math.cos(i*angle),
y: cy + r * Math.sin(i*angle),
letter: letters[i]
})
}
return pts
}
Insert cell
guessValue = {
while(true){
try {yield document.getElementById('guess').value.toUpperCase()}
catch {yield Promises.delay(100)}
}
}
Insert cell
handleEnter = (guess) => {
const isGoodGuess = guess.toUpperCase() === currentWord
const points = isGoodGuess ? 1 : 0

let scoreAfter = score + points
mutable score = scoreAfter
const ts = new Date()
log({guess: guess.toUpperCase(), currentWord, isGoodGuess, points})
mutable currentWord = pickWord(wordLengthBounds[0], wordLengthBounds[1])
}
Insert cell
mutable currentWord = pickWord(wordLengthBounds[0], wordLengthBounds[1])
Insert cell
splitCurrent = splitWordInHalf(currentWord)
Insert cell
splitGuess = [guessValue.slice(0,splitCurrent[0].length), guessValue.slice(splitCurrent[0].length)]
Insert cell
mutable history = []
Insert cell
mutable score = 0
Insert cell
log = (data) => {
mutable history = [data, ...history]
}
Insert cell
import {pickWord} from '@a-lexwein/find-a-big-word-boggle-like'
Insert cell
import {rangeSlider} from '@mootari/range-slider@1312'
Insert cell
splitWordInHalf = word => {
let i = Math.ceil(word.length / 2)
const halves = [word.slice(0, i), word.slice(i)]
return halves.map(x => _.shuffle(x).join(''))
}
Insert cell
## things to improve

* colored feedback on input
* validate correct guess that's not from seed
* Think through colors
* responsive sizing
* name
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more