diff --git a/README.md b/README.md
index 561cfdd..e0c886b 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Getting Started
4. Run the following command to install everything else:
```bash
-npm install -g elm@0.17.0 elm-live@2.3.0 project-fuzzball-test@1.0.5 elm-css@0.5.0
+npm install -g elm elm-test elm-css elm-live@2.4.1
```
**Note:** If step 4 gives you an `EACCESS` error on OS X, try [this fix](https://docs.npmjs.com/getting-started/fixing-npm-permissions):
diff --git a/part1/Main.elm b/part1/Main.elm
index a059cea..fc11ceb 100644
--- a/part1/Main.elm
+++ b/part1/Main.elm
@@ -16,7 +16,7 @@ model =
elmHubHeader =
header []
[ -- TODO add the equivalent of
ElmHub
right before this
- span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
+ span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
]
diff --git a/part1/elm-package.json b/part1/elm-package.json
index 3a09e24..cb15a2e 100644
--- a/part1/elm-package.json
+++ b/part1/elm-package.json
@@ -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"
}
diff --git a/part2/Main.elm b/part2/Main.elm
index ad247f3..9d2f7cc 100644
--- a/part2/Main.elm
+++ b/part2/Main.elm
@@ -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
+ }
diff --git a/part2/elm-package.json b/part2/elm-package.json
index 3a09e24..cb15a2e 100644
--- a/part2/elm-package.json
+++ b/part2/elm-package.json
@@ -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"
}
diff --git a/part3/Main.elm b/part3/Main.elm
index f0fcae4..dc76c4a 100644
--- a/part3/Main.elm
+++ b/part3/Main.elm
@@ -13,17 +13,20 @@ type alias Model =
type alias SearchResult =
- { id : ResultId
+ { id : Int
, name : String
, stars : Int
}
-type alias ResultId =
- Int
+type alias Msg =
+ { operation : String
+ , data : Int
+ }
-initialModel : Model
+{-| TODO add a type annotation to this value
+-}
initialModel =
{ query = "tutorial"
, results =
@@ -51,17 +54,17 @@ initialModel =
}
-elmHubHeader : Html a
+{-| TODO add a type annotation to this function
+-}
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 revise this type annotation once we add our onClick handler
+{-| TODO add a type annotation to this function
-}
-view : Model -> Html a
view model =
div [ class "content" ]
[ elmHubHeader
@@ -69,34 +72,30 @@ view model =
]
-{-| TODO revise this type annotation once we add our onClick handler
+{-| TODO add a type annotation to this function
-}
-viewSearchResult : SearchResult -> Html a
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 action
- [ class "hide-result" ]
+ [ class "hide-result", onClick { operation = "DELETE_BY_ID", data = result.id } ]
[ text "X" ]
]
-type alias Msg =
- { -- TODO implement this type alias
- }
-
-
-update : Msg -> Model -> Model
+{-| TODO add a type annotation to this function
+-}
update msg model =
- -- TODO if we receive a DELETE_BY_ID message,
- -- build a new model without the given ID present anymore.
- model
+ if msg.operation == "DELETE_BY_ID" then
+ { model
+ | results = List.filter (\result -> result.id /= msg.data) model.results
+ }
+ else
+ model
-main : Program Never
main =
Html.App.beginnerProgram
{ view = view
diff --git a/part3/elm-package.json b/part3/elm-package.json
index 3a09e24..cb15a2e 100644
--- a/part3/elm-package.json
+++ b/part3/elm-package.json
@@ -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"
}