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 = type alias Model =
{ tags : List String { tags : List String
, selectedTag : String , selectedTag : String
, allArticles : List Article
{- 👉 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
}
} }
{-| 👉 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 = initialModel =
{ tags = Article.tags { tags = Article.tags
, selectedTag = "elm" , 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 = update msg model =
if msg.description == "ClickedTag" then if msg.description == "ClickedTag" then
{ model | selectedTag = msg.data } { model | selectedTag = msg.data }
@@ -66,8 +58,7 @@ update msg model =
-- VIEW -- VIEW
{-| 👉 TODO: Replace this comment with a type annotation for `view` view : Model -> Html Msg
-}
view model = view model =
let let
articles = articles =
@@ -93,8 +84,7 @@ view model =
] ]
{-| 👉 TODO: Replace this comment with a type annotation for `view` viewArticle : Article -> Html Msg
-}
viewArticle article = viewArticle article =
div [ class "article-preview" ] div [ class "article-preview" ]
[ h1 [] [ text article.title ] [ h1 [] [ text article.title ]
@@ -103,8 +93,7 @@ viewArticle article =
] ]
{-| 👉 TODO: Replace this comment with a type annotation for `viewBanner` viewBanner : Html Msg
-}
viewBanner = viewBanner =
div [ class "banner" ] div [ class "banner" ]
[ div [ class "container" ] [ 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 = viewTag selectedTagName tagName =
let let
otherClass = otherClass =