From 47acee2c4044c7178c894038a3150dd66e4f25ff Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 26 Mar 2016 09:09:09 -0700 Subject: [PATCH] Various updates --- stages/10/Component/SearchResult.elm | 4 +-- stages/3/Main.elm | 16 +++++----- stages/4/Main.elm | 44 ++++++++++++---------------- stages/4/elm-package.json | 1 - stages/5/Main.elm | 4 +-- stages/6/ElmHub.elm | 4 +-- stages/7/ElmHub.elm | 4 +-- stages/8/ElmHub.elm | 4 +-- stages/9/Component/SearchResult.elm | 4 +-- 9 files changed, 33 insertions(+), 52 deletions(-) diff --git a/stages/10/Component/SearchResult.elm b/stages/10/Component/SearchResult.elm index 067ad36..67d7d37 100644 --- a/stages/10/Component/SearchResult.elm +++ b/stages/10/Component/SearchResult.elm @@ -41,9 +41,7 @@ view address model = <| if model.expanded then [ span [ class "star-count" ] [ text (toString model.stars) ] , a - [ href ("https://github.com/" ++ model.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ model.name), target "_blank" ] [ text model.name ] , button [ class "hide-result", onClick address Collapse ] diff --git a/stages/3/Main.elm b/stages/3/Main.elm index ca1ec18..72bbbd1 100644 --- a/stages/3/Main.elm +++ b/stages/3/Main.elm @@ -7,14 +7,6 @@ import StartApp.Simple as StartApp import Signal exposing (Address) -main = - StartApp.start - { view = view - , update = update - , model = initialModel - } - - type alias Model = { query : String , results : List SearchResult @@ -100,3 +92,11 @@ update action model = -- TODO if we receive a DELETE_BY_ID action, -- build a new model without the given ID present anymore. model + + +main = + StartApp.start + { view = view + , update = update + , model = initialModel + } diff --git a/stages/4/Main.elm b/stages/4/Main.elm index a70be41..777ec52 100644 --- a/stages/4/Main.elm +++ b/stages/4/Main.elm @@ -3,29 +3,11 @@ module Main (..) where import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) -import StartApp -import Task exposing (Task) -import Effects exposing (Effects) -import Json.Decode exposing (Decoder, (:=)) +import StartApp.Simple as StartApp import Json.Encode 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 = { query : String , results : List SearchResult @@ -84,7 +66,12 @@ view address model = [ h1 [] [ text "ElmHub" ] , 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" ] , ul [ class "results" ] @@ -92,6 +79,7 @@ view address model = ] +onInput : Address Action -> (String -> Action) -> Attribute onInput address wrap = on "input" targetValue (\val -> Signal.message address (wrap val)) @@ -106,9 +94,7 @@ viewSearchResult address result = [] [ span [ class "star-count" ] [ text (toString result.stars) ] , a - [ href ("https://github.com/" ++ result.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ result.name), target "_blank" ] [ text result.name ] , button -- TODO add an onClick handler that sends a DeleteById action @@ -122,8 +108,16 @@ type Action | DeleteById ResultId -update : Action -> Model -> ( Model, Effects Action ) +update : Action -> Model -> Model update action model = -- TODO write a case-expression that makes SetQuery set the query -- and DeleteById delete the appropriate result - ( model, Effects.none ) + model + + +main = + StartApp.start + { view = view + , update = update + , model = initialModel + } diff --git a/stages/4/elm-package.json b/stages/4/elm-package.json index 588e1cf..1447aac 100644 --- a/stages/4/elm-package.json +++ b/stages/4/elm-package.json @@ -9,7 +9,6 @@ "exposed-modules": [], "dependencies": { "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/start-app": "2.0.0 <= v < 3.0.0" }, diff --git a/stages/5/Main.elm b/stages/5/Main.elm index f7355a6..48f3985 100644 --- a/stages/5/Main.elm +++ b/stages/5/Main.elm @@ -118,9 +118,7 @@ viewSearchResult address result = [] [ span [ class "star-count" ] [ text (toString result.stars) ] , a - [ href ("https://github.com/" ++ result.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ result.name), target "_blank" ] [ text result.name ] , button [ class "hide-result", onClick address (DeleteById result.id) ] diff --git a/stages/6/ElmHub.elm b/stages/6/ElmHub.elm index d94fbca..648be29 100644 --- a/stages/6/ElmHub.elm +++ b/stages/6/ElmHub.elm @@ -96,9 +96,7 @@ viewSearchResult address result = [] [ span [ class "star-count" ] [ text (toString result.stars) ] , a - [ href ("https://github.com/" ++ result.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ result.name), target "_blank" ] [ text result.name ] , button [ class "hide-result", onClick address (DeleteById result.id) ] diff --git a/stages/7/ElmHub.elm b/stages/7/ElmHub.elm index d94fbca..648be29 100644 --- a/stages/7/ElmHub.elm +++ b/stages/7/ElmHub.elm @@ -96,9 +96,7 @@ viewSearchResult address result = [] [ span [ class "star-count" ] [ text (toString result.stars) ] , a - [ href ("https://github.com/" ++ result.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ result.name), target "_blank" ] [ text result.name ] , button [ class "hide-result", onClick address (DeleteById result.id) ] diff --git a/stages/8/ElmHub.elm b/stages/8/ElmHub.elm index 0fac7cd..ad2ff08 100644 --- a/stages/8/ElmHub.elm +++ b/stages/8/ElmHub.elm @@ -98,9 +98,7 @@ viewSearchResult address result = [] [ span [ class "star-count" ] [ text (toString result.stars) ] , a - [ href ("https://github.com/" ++ result.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ result.name), target "_blank" ] [ text result.name ] , button [ class "hide-result", onClick address (DeleteById result.id) ] diff --git a/stages/9/Component/SearchResult.elm b/stages/9/Component/SearchResult.elm index 7e9b0aa..4dedbd3 100644 --- a/stages/9/Component/SearchResult.elm +++ b/stages/9/Component/SearchResult.elm @@ -37,9 +37,7 @@ view address model = <| if model.expanded then [ span [ class "star-count" ] [ text (toString model.stars) ] , a - [ href ("https://github.com/" ++ model.name) - , target "_blank" - ] + [ href ("https://github.com/" ++ model.name), target "_blank" ] [ text model.name ] , button -- TODO when the user clicks, send a Collapse action