diff --git a/stages/0/Main.elm b/stages/0/Main.elm
deleted file mode 100644
index 56a2cad..0000000
--- a/stages/0/Main.elm
+++ /dev/null
@@ -1,37 +0,0 @@
-module Main (..) where
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-
-
-model =
- { result =
- { id = 1
- , name = "TheSeamau5/elm-checkerboardgrid-tutorial"
- , stars = 66
- }
- }
-
-
-view model =
- div
- [ class "content" ]
- [ header
- []
- [ -- TODO add the equivalent of
ElmHub
right before the tagline
- span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
- ]
- , ul
- [ class "results" ]
- [ li
- []
- [ span [ class "star-count" ] [{- TODO display the number of stars -}]
- -- TODO use the model to put a link here that points to
- -- https://github.com/TheSeamau5/elm-checkerboardgrid-tutorial
- ]
- ]
- ]
-
-
-main =
- view model
diff --git a/stages/1/Main.elm b/stages/1/Main.elm
index 6a605f8..56a2cad 100644
--- a/stages/1/Main.elm
+++ b/stages/1/Main.elm
@@ -4,81 +4,34 @@ import Html exposing (..)
import Html.Attributes exposing (..)
-main =
- view model
-
-
-type alias Model =
- { query : String
- , results : List SearchResult
- }
-
-
-type alias SearchResult =
- { id : ResultId
- , name : String
- , stars : Int
- }
-
-
-type alias ResultId =
- Int
-
-
-
-{- See https://developer.github.com/v3/search/#example -}
-
-
-model : Model
model =
- { query = "tutorial"
- , results =
- [ { id = 1
- , name = "TheSeamau5/elm-checkerboardgrid-tutorial"
- , stars = 66
- }
- , { id = 2
- , name = "grzegorzbalcerek/elm-by-example"
- , stars = 41
- }
- , { id = 3
- , name = "sporto/elm-tutorial-app"
- , stars = 35
- }
- , { id = 4
- , name = "jvoigtlaender/Elm-Tutorium"
- , stars = 10
- }
- , { id = 5
- , name = "sporto/elm-tutorial-assets"
- , stars = 7
- }
- ]
+ { result =
+ { id = 1
+ , name = "TheSeamau5/elm-checkerboardgrid-tutorial"
+ , stars = 66
+ }
}
-view : Model -> Html
view model =
div
[ class "content" ]
[ header
[]
- [ h1 [] [ text "ElmHub" ]
- , span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
+ [ -- TODO add the equivalent of ElmHub
right before the tagline
+ span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
]
, ul
[ class "results" ]
- [{- TODO use model.results and viewSearchResults to display results -}]
+ [ li
+ []
+ [ span [ class "star-count" ] [{- TODO display the number of stars -}]
+ -- TODO use the model to put a link here that points to
+ -- https://github.com/TheSeamau5/elm-checkerboardgrid-tutorial
+ ]
+ ]
]
-viewSearchResult : SearchResult -> Html
-viewSearchResult result =
- li
- []
- [ span [ class "star-count" ] [ text (toString result.stars) ]
- , a
- [ href ("https://github.com/" ++ result.name), target "_blank" ]
- [ text result.name ]
- , text result.name
- ]
+main =
+ view model
diff --git a/stages/8/Component/ElmHub.elm b/stages/10/Component/ElmHub.elm
similarity index 100%
rename from stages/8/Component/ElmHub.elm
rename to stages/10/Component/ElmHub.elm
diff --git a/stages/8/Component/SearchResult.elm b/stages/10/Component/SearchResult.elm
similarity index 76%
rename from stages/8/Component/SearchResult.elm
rename to stages/10/Component/SearchResult.elm
index 7e9b0aa..067ad36 100644
--- a/stages/8/Component/SearchResult.elm
+++ b/stages/10/Component/SearchResult.elm
@@ -26,8 +26,12 @@ type Action
update : Action -> Model -> ( Model, Effects Action )
update action model =
- -- TODO make expand and collapse work
- ( model, Effects.none )
+ case action of
+ Expand ->
+ ( { model | expanded = True }, Effects.none )
+
+ Collapse ->
+ ( { model | expanded = False }, Effects.none )
view : Address Action -> Model -> Html
@@ -42,13 +46,11 @@ view address model =
]
[ text model.name ]
, button
- -- TODO when the user clicks, send a Collapse action
- [ class "hide-result" ]
+ [ class "hide-result", onClick address Collapse ]
[ text "X" ]
]
else
[ button
- -- TODO when the user clicks, send an Expand action
- [ class "expand-result" ]
+ [ class "expand-result", onClick address Expand ]
[ text "Show" ]
]
diff --git a/stages/9/ElmHub.elm b/stages/10/ElmHub.elm
similarity index 100%
rename from stages/9/ElmHub.elm
rename to stages/10/ElmHub.elm
diff --git a/stages/10/Main.elm b/stages/10/Main.elm
new file mode 100644
index 0000000..5b8e88e
--- /dev/null
+++ b/stages/10/Main.elm
@@ -0,0 +1,27 @@
+module Main (..) where
+
+import StartApp
+import Component.ElmHub exposing (..)
+import Effects exposing (Effects)
+import Task exposing (Task)
+import Html exposing (Html)
+
+
+main : Signal Html
+main =
+ app.html
+
+
+app : StartApp.App Model
+app =
+ StartApp.start
+ { view = view
+ , update = update
+ , init = ( initialModel, Effects.task (searchFeed initialModel.query) )
+ , inputs = []
+ }
+
+
+port tasks : Signal (Task Effects.Never ())
+port tasks =
+ app.tasks
diff --git a/stages/0/README.md b/stages/10/README.md
similarity index 79%
rename from stages/0/README.md
rename to stages/10/README.md
index e4a727c..3f40f91 100644
--- a/stages/0/README.md
+++ b/stages/10/README.md
@@ -1,4 +1,4 @@
-Stage 1
+Stage 5
=======
## Installation
@@ -15,3 +15,9 @@ to fail; in that case, just run `elm package install` again.)
```bash
elm live Main.elm --open -- --output=elm.js
```
+
+## Compiling CSS
+
+```bash
+elm test css/Stylesheets.elm
+```
diff --git a/stages/9/Stylesheets.elm b/stages/10/Stylesheets.elm
similarity index 100%
rename from stages/9/Stylesheets.elm
rename to stages/10/Stylesheets.elm
diff --git a/stages/9/css/Stylesheets.elm b/stages/10/css/Stylesheets.elm
similarity index 100%
rename from stages/9/css/Stylesheets.elm
rename to stages/10/css/Stylesheets.elm
diff --git a/stages/0/elm-hub.png b/stages/10/elm-hub.png
similarity index 100%
rename from stages/0/elm-hub.png
rename to stages/10/elm-hub.png
diff --git a/stages/0/elm-package.json b/stages/10/elm-package.json
similarity index 59%
rename from stages/0/elm-package.json
rename to stages/10/elm-package.json
index 2b33bdf..ea197b6 100644
--- a/stages/0/elm-package.json
+++ b/stages/10/elm-package.json
@@ -9,7 +9,11 @@
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "3.0.0 <= v < 4.0.0",
- "evancz/elm-html": "4.0.0 <= v < 5.0.0"
+ "evancz/elm-effects": "2.0.0 <= v < 3.0.0",
+ "evancz/elm-html": "4.0.0 <= v < 5.0.0",
+ "evancz/elm-http": "3.0.0 <= v < 4.0.0",
+ "evancz/start-app": "2.0.0 <= v < 3.0.0",
+ "rtfeldman/elm-css": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.16.0 <= v < 0.17.0"
}
diff --git a/stages/0/index.html b/stages/10/index.html
similarity index 90%
rename from stages/0/index.html
rename to stages/10/index.html
index d045ba4..5db9b93 100644
--- a/stages/0/index.html
+++ b/stages/10/index.html
@@ -20,7 +20,7 @@
var app = Elm.fullscreen(Elm.Main, {});
// Uncomment this line and comment out the above to enable elm-reactor support.
- // var app = Elm.fullscreenDebug("ElmHub", "ElmHub.elm");
+ // var app = Elm.fullscreenDebug("ElmHub", "Main.elm");