Revise parts 1, 2, and 3.

This commit is contained in:
Richard Feldman
2016-08-16 02:37:40 -07:00
parent b557ee0842
commit 3a050f408d
7 changed files with 49 additions and 61 deletions

View File

@@ -1,29 +1,12 @@
module Main exposing (..)
import Html exposing (..)
import Html.App
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
type alias Model =
{ query : String
, results : List SearchResult
}
type alias SearchResult =
{ id : ResultId
, name : String
, stars : Int
}
type alias ResultId =
Int
{-| TODO add a type annotation to this value
-}
model =
initialModel =
{ query = "tutorial"
, results =
[ { id = 1
@@ -50,35 +33,41 @@ model =
}
elmHubHeader : Html a
elmHubHeader =
header []
[ h1 [] [ text "ElmHub" ]
, span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
, span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
]
{-| TODO add a type annotation to this function
-}
view model =
div [ class "content" ]
[ elmHubHeader
, ul [ class "results" ]
[{- TODO use model.results and viewSearchResult to display results -}]
, ul [ class "results" ] (List.map viewSearchResult model.results)
]
{-| TODO add a type annotation to this function
-}
viewSearchResult result =
li []
[ span [ class "star-count" ] [ text (toString result.stars) ]
, a [ href ("https://github.com/" ++ result.name), target "_blank" ]
[ text result.name ]
, button
-- TODO add an onClick handler that sends a DELETE_BY_ID msg
[ class "hide-result" ]
[ text "X" ]
]
{-| TODO add a type annotation to this value
-}
update msg model =
-- TODO if msg.operation == "DELETE_BY_ID",
-- then return a new model without the given ID present anymore.
model
main =
view model
Html.App.beginnerProgram
{ view = view
, update = update
, model = initialModel
}