Solution to intro/part4
This commit is contained in:
@@ -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
|
||||
, allArticles : List Article
|
||||
}
|
||||
|
||||
|
||||
💡 HINT: You'll need to move the existing annotation to a `type alias`.
|
||||
-}
|
||||
, allArticles :
|
||||
List
|
||||
type alias Article =
|
||||
{ title : String
|
||||
, description : String
|
||||
, body : String
|
||||
, tags : List String
|
||||
, slug : String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{-| 👉 TODO: Replace this comment with a type annotation for `initialModel`
|
||||
-}
|
||||
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 =
|
||||
|
||||
Reference in New Issue
Block a user