Revise part4

This commit is contained in:
Richard Feldman
2016-08-16 02:40:50 -07:00
parent 3a050f408d
commit ea6e074ddf
2 changed files with 15 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ module Main exposing (..)
import Html exposing (..) import Html exposing (..)
import Html.App import Html.App
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput) import Html.Events exposing (onClick)
type alias Model = type alias Model =
@@ -13,21 +13,17 @@ type alias Model =
type alias SearchResult = type alias SearchResult =
{ id : ResultId { id : Int
, name : String , name : String
, stars : Int , stars : Int
} }
type alias ResultId = type Msg
Int = SetQuery String
| DeleteById Int
{- See https://developer.github.com/v3/search/#example -}
initialModel : Model
initialModel = initialModel =
{ query = "tutorial" { query = "tutorial"
, results = , results =
@@ -55,12 +51,19 @@ initialModel =
} }
elmHubHeader =
header []
[ h1 [] [ text "ElmHub" ]
, span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
]
view : Model -> Html Msg view : Model -> Html Msg
view model = view model =
div [ class "content" ] div [ class "content" ]
[ header [] [ header []
[ h1 [] [ text "ElmHub" ] [ h1 [] [ text "ElmHub" ]
, span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ] , span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
] ]
, input , input
[ class "search-query" [ class "search-query"
@@ -86,19 +89,12 @@ viewSearchResult result =
] ]
type Msg
= SetQuery String
| DeleteById ResultId
update : Msg -> Model -> Model
update msg model = update msg model =
-- TODO if we get a SetQuery action, use it to set the model's query field, -- TODO if we get a SetQuery action, use it to set the model's query field,
-- and if we get a DeleteById action, delete the appropriate result -- and if we get a DeleteById action, delete the appropriate result
model model
main : Program Never
main = main =
Html.App.beginnerProgram Html.App.beginnerProgram
{ view = view { view = view

View File

@@ -8,8 +8,8 @@
], ],
"exposed-modules": [], "exposed-modules": [],
"dependencies": { "dependencies": {
"elm-lang/core": "4.0.1 <= v < 5.0.0", "elm-lang/core": "4.0.5 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0" "elm-lang/html": "1.1.0 <= v < 2.0.0"
}, },
"elm-version": "0.17.0 <= v < 0.18.0" "elm-version": "0.17.0 <= v < 0.18.0"
} }