Conversation
n1k0
left a comment
There was a problem hiding this comment.
Hey, this is awesome! Could you please install elm-format and apply automatic code formatting so we can land this? I'll probably take over next to tweat the styles a little, but thank you so much for this great patch 🎉
| main = | ||
| Browser.element | ||
| { init = init | ||
| { init = init English |
There was a problem hiding this comment.
We could probably detect users language from their browser environment, eg by using navigator.language and passing it to Flags, so we would preselect their language by default!
| toString : Language -> String | ||
| toString language = |
There was a problem hiding this comment.
maybe languageToString so it's a little more explicit/less vague?
| ( { model | currentTry = string }, Cmd.none ) | ||
|
|
||
| SwitchLanguage lang -> | ||
| update NewGame { model | language = lang } |
There was a problem hiding this comment.
It's usually better to avoid calling update recursively, so here we could just return ( { model | language = lang }, Cmd.none ) :)
There was a problem hiding this comment.
Ah no my bad, we need to init indeed. Scratch it, we won't bother destructuring just to update language here 👍
| let classes = if isActive then | ||
| "btn btn-secondary active" | ||
| else | ||
| "btn btn-secondary" | ||
| in | ||
| label [ class classes ] |
There was a problem hiding this comment.
You have a convenient classList helper which may be easier to use here https://package.elm-lang.org/packages/elm/html/latest/Html-Attributes#classList
| try : Language -> WordToFind -> UserInput -> Result String Attempt | ||
| try lang word input = |
There was a problem hiding this comment.
There's probably an error string to update as well in this function:
Err <| "Sorry, " ++ input ++ " must be a word known from our dictionary"
-- -----------------------------------------------------------------^ French/EnglishAlso btw in English language names always take an uppercase letter first.
|
I took a lot of inspiration from your patch and went with a laaaarge refactor of the previous codebase. Unfortunately I couldn't cherry pick your commits as the diff was way too important, but thanks again for the ideas! FWIW I've credited you in the README, hope it's okay for you. Cheers! |
|
Yes, thanks! |
This add the possibility to choose alternates dictionaries.
See the result here : https://mmai.github.io/wordlem/
There is probably a way to make that prettier.