Solution to intro/part3

This commit is contained in:
Richard Feldman
2018-08-14 01:55:58 -04:00
parent a329bd2f40
commit 3e6c780a93
2 changed files with 9 additions and 29 deletions

View File

@@ -6,13 +6,15 @@
"elm-version": "0.19.0", "elm-version": "0.19.0",
"dependencies": { "dependencies": {
"direct": { "direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0", "elm/core": "1.0.0",
"elm/html": "1.0.0" "elm/html": "1.0.0"
}, },
"indirect": { "indirect": {
"elm/json": "1.0.0", "elm/json": "1.0.0",
"elm/time": "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": { "test-dependencies": {

View File

@@ -25,14 +25,10 @@ initialModel =
update msg model = update msg model =
{- 👉 TODO: If `msg.description` is "ClickedTag", then if msg.description == "ClickedTag" then
set the model's `selectedTag` field to be `msg.data` { model | selectedTag = msg.data }
💡 HINT: record update syntax looks like this: else
{ model | foo = bar }
-}
model model
@@ -42,16 +38,8 @@ update msg model =
view model = view model =
let 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 = articles =
List.filter (\article -> True) List.filter (\article -> List.member model.selectedTag article.tags)
model.allArticles model.allArticles
feed = feed =
@@ -101,17 +89,7 @@ viewTag selectedTagName tagName =
in in
button button
[ class ("tag-pill " ++ otherClass) [ class ("tag-pill " ++ otherClass)
, onClick { description = "ClickedTag", data = tagName }
{- 👉 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`!
-}
] ]
[ text tagName ] [ text tagName ]