Revise parts 1, 2, and 3.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
||||
"elm-lang/core": "4.0.5 <= v < 5.0.0",
|
||||
"elm-lang/html": "1.1.0 <= v < 2.0.0"
|
||||
},
|
||||
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user