diff --git a/intro/part3/elm.json b/intro/part3/elm.json index b20be45..fbfc4f8 100644 --- a/intro/part3/elm.json +++ b/intro/part3/elm.json @@ -6,13 +6,15 @@ "elm-version": "0.19.0", "dependencies": { "direct": { + "elm/browser": "1.0.0", "elm/core": "1.0.0", "elm/html": "1.0.0" }, "indirect": { "elm/json": "1.0.0", "elm/time": "1.0.0", - "elm/url": "1.0.0" + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.0" } }, "test-dependencies": { diff --git a/intro/part3/src/Main.elm b/intro/part3/src/Main.elm index e41e705..418d345 100644 --- a/intro/part3/src/Main.elm +++ b/intro/part3/src/Main.elm @@ -25,15 +25,11 @@ initialModel = update msg model = - {- 👉 TODO: If `msg.description` is "ClickedTag", then - set the model's `selectedTag` field to be `msg.data` + if msg.description == "ClickedTag" then + { model | selectedTag = msg.data } - 💡 HINT: record update syntax looks like this: - - { model | foo = bar } - - -} - model + else + model @@ -42,16 +38,8 @@ update msg model = view model = let - {- 👉 TODO: Filter the articles down to only the ones - that include the currently selected tag. - - 💡 HINT: Replace `True` below with something involving - `List.member`, `article.tags`, and `model.selectedTag` - - Docs for List.member: http://package.elm-lang.org/packages/elm-lang/core/latest/List#member - -} articles = - List.filter (\article -> True) + List.filter (\article -> List.member model.selectedTag article.tags) model.allArticles feed = @@ -101,17 +89,7 @@ viewTag selectedTagName tagName = in button [ class ("tag-pill " ++ otherClass) - - {- 👉 TODO: Add an `onClick` handler which sends a msg - that our `update` function above will use - to set the currently selected tag to `tagName`. - - 💡 HINT: It should look something like this: - - , onClick { description = … , data = … } - - 👆 Don't forget to add a comma before `onClick`! - -} + , onClick { description = "ClickedTag", data = tagName } ] [ text tagName ]