Solution to intro/part4

This commit is contained in:
Richard Feldman
2018-08-14 01:58:49 -04:00
parent 3e6c780a93
commit 412ddaa55f

View File

@@ -14,27 +14,20 @@ import Html.Events exposing (onClick)
type alias Model =
{ tags : List String
, selectedTag : String
{- 👉 TODO: change this `allArticles` annotation to the following:
allArticles : List Article
💡 HINT: You'll need to move the existing annotation to a `type alias`.
-}
, allArticles :
List
{ title : String
, description : String
, body : String
, tags : List String
, slug : String
}
, allArticles : List Article
}
{-| 👉 TODO: Replace this comment with a type annotation for `initialModel`
-}
type alias Article =
{ title : String
, description : String
, body : String
, tags : List String
, slug : String
}
initialModel : Model
initialModel =
{ tags = Article.tags
, selectedTag = "elm"
@@ -52,8 +45,7 @@ type alias Msg =
}
{-| 👉 TODO: Replace this comment with a type annotation for `update`
-}
update : Msg -> Model -> Model
update msg model =
if msg.description == "ClickedTag" then
{ model | selectedTag = msg.data }
@@ -66,8 +58,7 @@ update msg model =
-- VIEW
{-| 👉 TODO: Replace this comment with a type annotation for `view`
-}
view : Model -> Html Msg
view model =
let
articles =
@@ -93,8 +84,7 @@ view model =
]
{-| 👉 TODO: Replace this comment with a type annotation for `view`
-}
viewArticle : Article -> Html Msg
viewArticle article =
div [ class "article-preview" ]
[ h1 [] [ text article.title ]
@@ -103,8 +93,7 @@ viewArticle article =
]
{-| 👉 TODO: Replace this comment with a type annotation for `viewBanner`
-}
viewBanner : Html Msg
viewBanner =
div [ class "banner" ]
[ div [ class "container" ]
@@ -114,8 +103,7 @@ viewBanner =
]
{-| 👉 TODO: Replace this comment with a type annotation for `viewTag`
-}
viewTag : String -> String -> Html Msg
viewTag selectedTagName tagName =
let
otherClass =