Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Elmish" + Todo List Example? #44

Closed
32 of 33 tasks
nelsonic opened this issue Jul 5, 2018 · 5 comments
Closed
32 of 33 tasks

"Elmish" + Todo List Example? #44

nelsonic opened this issue Jul 5, 2018 · 5 comments

Comments

@nelsonic
Copy link
Member

nelsonic commented Jul 5, 2018

Can we split the DOM-creation and mount code into it's own file elmish.js and use it as an opportunity to create a basic Todo List using TodoMVC styles?

Tasks

@nelsonic
Copy link
Member Author

nelsonic commented Jul 9, 2018

While this is not a "high priority", I feel that it's good practice
and will help a complete beginner to understand TEA + TodoMVC a bit better.

So ... I'm thinking of tackling it.

@nelsonic
Copy link
Member Author

@nelsonic
Copy link
Member Author

nelsonic commented Jul 12, 2018

View Source of TodoMVC to analyse what HTML elements we need to create.
todomvc-elements-browser-devtools

<section class="todoapp">
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" placeholder="What needs to be done?" autofocus="">
  </header>
  <section class="main" style="display: block;">
    <input id="toggle-all" class="toggle-all" type="checkbox">
    <label for="toggle-all">Mark all as complete</label>
    <ul class="todo-list">
      <li data-id="1531397960010" class="completed">
        <div class="view">
          <input class="toggle" type="checkbox" checked="">
          <label>Learn The Elm Architecture ("TEA")</label>
          <button class="destroy"></button>
        </div>
      </li>
      <li data-id="1531397981603" class="">
        <div class="view">
          <input class="toggle" type="checkbox">
          <label>Build TEA Todo List App</label>
          <button class="destroy">
          </button>
        </div>
      </li>
    </ul>
  </section>
  <footer class="footer" style="display: block;">
    <span class="todo-count"><strong>1</strong> item left</span>
    <ul class="filters">
      <li>
        <a href="#/" class="selected">All</a>
      </li>
      <li>
        <a href="#/active" class="">Active</a>
      </li>
      <li>
        <a href="#/completed">Completed</a>
      </li>
    </ul>
    <button class="clear-completed" style="display: block;">Clear completed</button>
  </footer>
</section>

nelsonic added a commit that referenced this issue Jul 14, 2018
@nelsonic
Copy link
Member Author

localStorage sample code:

var model = { 'one': 1, 'two': 2, 'three': 3 };

// save the model (data) into storage as a stringified object:
localStorage.setItem('elmish_store', JSON.stringify(model));

// Retrieve the stringified object from localStorage:
var retrieved_model = localStorage.getItem('elmish_store');

console.log('Retrieved model: ', JSON.parse(retrieved_model));

image

nelsonic added a commit that referenced this issue Jul 31, 2018
@nelsonic
Copy link
Member Author

nelsonic commented Aug 1, 2018

It's occurred to me that I have the incorrect parameter order in the update function ...
The function signature in Elm is: update : Msg -> Model -> ( Model, Cmd Msg )
https://www.elm-tutorial.org/en/08-edit/05-update.html
We have update(model, action)
Let's "fix" this.

nelsonic added a commit that referenced this issue Aug 2, 2018
nelsonic added a commit that referenced this issue Aug 2, 2018
nelsonic added a commit that referenced this issue Aug 3, 2018
@nelsonic nelsonic closed this as completed Sep 7, 2018
iteles added a commit that referenced this issue Sep 8, 2018
PR: Elm(ish) Todo List (TodoMVC) Example issue #44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant