Various updates

This commit is contained in:
Richard Feldman
2016-03-26 09:09:09 -07:00
parent 236cd9057d
commit 47acee2c40
9 changed files with 33 additions and 52 deletions

View File

@@ -41,9 +41,7 @@ view address model =
<| if model.expanded then <| if model.expanded then
[ span [ class "star-count" ] [ text (toString model.stars) ] [ span [ class "star-count" ] [ text (toString model.stars) ]
, a , a
[ href ("https://github.com/" ++ model.name) [ href ("https://github.com/" ++ model.name), target "_blank" ]
, target "_blank"
]
[ text model.name ] [ text model.name ]
, button , button
[ class "hide-result", onClick address Collapse ] [ class "hide-result", onClick address Collapse ]

View File

@@ -7,14 +7,6 @@ import StartApp.Simple as StartApp
import Signal exposing (Address) import Signal exposing (Address)
main =
StartApp.start
{ view = view
, update = update
, model = initialModel
}
type alias Model = type alias Model =
{ query : String { query : String
, results : List SearchResult , results : List SearchResult
@@ -100,3 +92,11 @@ update action model =
-- TODO if we receive a DELETE_BY_ID action, -- TODO if we receive a DELETE_BY_ID action,
-- build a new model without the given ID present anymore. -- build a new model without the given ID present anymore.
model model
main =
StartApp.start
{ view = view
, update = update
, model = initialModel
}

View File

@@ -3,29 +3,11 @@ module Main (..) where
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (..) import Html.Events exposing (..)
import StartApp import StartApp.Simple as StartApp
import Task exposing (Task)
import Effects exposing (Effects)
import Json.Decode exposing (Decoder, (:=))
import Json.Encode import Json.Encode
import Signal exposing (Address) import Signal exposing (Address)
main : Signal Html
main =
app.html
app : StartApp.App Model
app =
StartApp.start
{ view = view
, update = update
, init = ( initialModel, Effects.none )
, inputs = []
}
type alias Model = type alias Model =
{ query : String { query : String
, results : List SearchResult , results : List SearchResult
@@ -84,7 +66,12 @@ view address model =
[ 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 [ class "search-query", onInput address SetQuery, defaultValue model.query ] [] , input
[ class "search-query"
-- TODO when we receive onInput, set the query in the model
, defaultValue model.query
]
[]
, button [ class "search-button" ] [ text "Search" ] , button [ class "search-button" ] [ text "Search" ]
, ul , ul
[ class "results" ] [ class "results" ]
@@ -92,6 +79,7 @@ view address model =
] ]
onInput : Address Action -> (String -> Action) -> Attribute
onInput address wrap = onInput address wrap =
on "input" targetValue (\val -> Signal.message address (wrap val)) on "input" targetValue (\val -> Signal.message address (wrap val))
@@ -106,9 +94,7 @@ viewSearchResult address result =
[] []
[ span [ class "star-count" ] [ text (toString result.stars) ] [ span [ class "star-count" ] [ text (toString result.stars) ]
, a , a
[ href ("https://github.com/" ++ result.name) [ href ("https://github.com/" ++ result.name), target "_blank" ]
, target "_blank"
]
[ text result.name ] [ text result.name ]
, button , button
-- TODO add an onClick handler that sends a DeleteById action -- TODO add an onClick handler that sends a DeleteById action
@@ -122,8 +108,16 @@ type Action
| DeleteById ResultId | DeleteById ResultId
update : Action -> Model -> ( Model, Effects Action ) update : Action -> Model -> Model
update action model = update action model =
-- TODO write a case-expression that makes SetQuery set the query -- TODO write a case-expression that makes SetQuery set the query
-- and DeleteById delete the appropriate result -- and DeleteById delete the appropriate result
( model, Effects.none ) model
main =
StartApp.start
{ view = view
, update = update
, model = initialModel
}

View File

@@ -9,7 +9,6 @@
"exposed-modules": [], "exposed-modules": [],
"dependencies": { "dependencies": {
"elm-lang/core": "3.0.0 <= v < 4.0.0", "elm-lang/core": "3.0.0 <= v < 4.0.0",
"evancz/elm-effects": "2.0.0 <= v < 3.0.0",
"evancz/elm-html": "4.0.0 <= v < 5.0.0", "evancz/elm-html": "4.0.0 <= v < 5.0.0",
"evancz/start-app": "2.0.0 <= v < 3.0.0" "evancz/start-app": "2.0.0 <= v < 3.0.0"
}, },

View File

@@ -118,9 +118,7 @@ viewSearchResult address result =
[] []
[ span [ class "star-count" ] [ text (toString result.stars) ] [ span [ class "star-count" ] [ text (toString result.stars) ]
, a , a
[ href ("https://github.com/" ++ result.name) [ href ("https://github.com/" ++ result.name), target "_blank" ]
, target "_blank"
]
[ text result.name ] [ text result.name ]
, button , button
[ class "hide-result", onClick address (DeleteById result.id) ] [ class "hide-result", onClick address (DeleteById result.id) ]

View File

@@ -96,9 +96,7 @@ viewSearchResult address result =
[] []
[ span [ class "star-count" ] [ text (toString result.stars) ] [ span [ class "star-count" ] [ text (toString result.stars) ]
, a , a
[ href ("https://github.com/" ++ result.name) [ href ("https://github.com/" ++ result.name), target "_blank" ]
, target "_blank"
]
[ text result.name ] [ text result.name ]
, button , button
[ class "hide-result", onClick address (DeleteById result.id) ] [ class "hide-result", onClick address (DeleteById result.id) ]

View File

@@ -96,9 +96,7 @@ viewSearchResult address result =
[] []
[ span [ class "star-count" ] [ text (toString result.stars) ] [ span [ class "star-count" ] [ text (toString result.stars) ]
, a , a
[ href ("https://github.com/" ++ result.name) [ href ("https://github.com/" ++ result.name), target "_blank" ]
, target "_blank"
]
[ text result.name ] [ text result.name ]
, button , button
[ class "hide-result", onClick address (DeleteById result.id) ] [ class "hide-result", onClick address (DeleteById result.id) ]

View File

@@ -98,9 +98,7 @@ viewSearchResult address result =
[] []
[ span [ class "star-count" ] [ text (toString result.stars) ] [ span [ class "star-count" ] [ text (toString result.stars) ]
, a , a
[ href ("https://github.com/" ++ result.name) [ href ("https://github.com/" ++ result.name), target "_blank" ]
, target "_blank"
]
[ text result.name ] [ text result.name ]
, button , button
[ class "hide-result", onClick address (DeleteById result.id) ] [ class "hide-result", onClick address (DeleteById result.id) ]

View File

@@ -37,9 +37,7 @@ view address model =
<| if model.expanded then <| if model.expanded then
[ span [ class "star-count" ] [ text (toString model.stars) ] [ span [ class "star-count" ] [ text (toString model.stars) ]
, a , a
[ href ("https://github.com/" ++ model.name) [ href ("https://github.com/" ++ model.name), target "_blank" ]
, target "_blank"
]
[ text model.name ] [ text model.name ]
, button , button
-- TODO when the user clicks, send a Collapse action -- TODO when the user clicks, send a Collapse action