Writing a timer, learning elm, need help

Hi all!

I got some free time recently and did this thing

here’s the code

If you’re lazy like me, you’re not reading code right away, so here’s the idea -

I wanted to learn Elm and write a simple app to create timers of a different kind, like counting how long you’ve stopped smoking or how many days left until X event will happen, like someone’s birthday or your next payday, etc.

So after the first attempt with classic CRUD stuff on a backend side, I decided to store the event in the URL, by base64-ing a pre-encoded string and stay backend-less. I’m storing event as “12411342342342<|>Event title” where number is POSIX milliseconds for now, and it’s not the best choice either since it has 2038 problem

For now, I haven’t read a lot of guides on how to do things in Elm except few libs documentation and things like elm.christmas, copy-pasted few code examples and made this weird event and timer types (most likely wrong), and Ticking stuff to update time left

So I’m looking for advice on how to build this thing right

Ideally, I would like it to support

  • localization
  • templates for a timer (maybe strftime-like format for displaying time left)
  • form for timer creation (datetime + text + supposedly template with html+css and interpolation)

Hi @bobishh! It’s a pretty broad question, but I’ll throw in a few thoughts =)

For localization, there are a few different approaches, but I really like this one which seems very clean and flexible. (Disclaimer: I haven’t actually used it myself, but I really like the concept and I know that others have used it successfully.)

For general UI creation, I’d suggest checking out elm-ui, which is a popular and fantastic package for laying out UIs without having to worry about the weird bits of HTML and CSS (this one I have used on several projects and it’s great).

I’d also suggest using elm-format to format your code - it can take a bit of getting used to depending on what you expect, but it’s great not to have to worry about formatting (and the majority of Elm developers do use elm-format, so if you get used to its style then it should be easy for you to read other people’s code and collaborate with them).

Also, for quick questions, definitely join the Elm Slack which is very active - #general, #beginners and #help may be useful, plus more specific channels like #elm-ui depending what direction you go in.

Hi Ian, thanks!
I’m already playing with elm-ui and definitely will take a look at elm-i18n

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.