From 809b5b1adc54c990f4bd0ca0fcd2d0802c9814c6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 27 Mar 2016 06:34:43 -0700 Subject: [PATCH] Bump 10 and 11, introduce new 9 --- stages/10/Component/SearchResult.elm | 14 ++- stages/10/README.md | 6 +- stages/10/elm-package.json | 3 +- stages/{9 => 11}/Component/ElmHub.elm | 0 stages/{9 => 11}/Component/SearchResult.elm | 14 +-- stages/{10 => 11}/ElmHub.elm | 0 stages/11/Main.elm | 27 ++++++ stages/11/README.md | 23 +++++ stages/{10 => 11}/Stylesheets.elm | 0 stages/{10 => 11}/css/Stylesheets.elm | 0 stages/11/elm-hub.png | Bin 0 -> 2126 bytes stages/11/elm-package.json | 19 ++++ stages/11/index.html | 26 ++++++ stages/11/style.css | 92 ++++++++++++++++++++ stages/11/test/TestRunner.elm | 15 ++++ stages/11/test/Tests.elm | 35 ++++++++ stages/11/test/elm-package.json | 21 +++++ stages/9/Main.elm | 2 +- 18 files changed, 278 insertions(+), 19 deletions(-) rename stages/{9 => 11}/Component/ElmHub.elm (100%) rename stages/{9 => 11}/Component/SearchResult.elm (75%) rename stages/{10 => 11}/ElmHub.elm (100%) create mode 100644 stages/11/Main.elm create mode 100644 stages/11/README.md rename stages/{10 => 11}/Stylesheets.elm (100%) rename stages/{10 => 11}/css/Stylesheets.elm (100%) create mode 100644 stages/11/elm-hub.png create mode 100644 stages/11/elm-package.json create mode 100644 stages/11/index.html create mode 100644 stages/11/style.css create mode 100644 stages/11/test/TestRunner.elm create mode 100644 stages/11/test/Tests.elm create mode 100644 stages/11/test/elm-package.json diff --git a/stages/10/Component/SearchResult.elm b/stages/10/Component/SearchResult.elm index 67d7d37..4dedbd3 100644 --- a/stages/10/Component/SearchResult.elm +++ b/stages/10/Component/SearchResult.elm @@ -26,12 +26,8 @@ type Action update : Action -> Model -> ( Model, Effects Action ) update action model = - case action of - Expand -> - ( { model | expanded = True }, Effects.none ) - - Collapse -> - ( { model | expanded = False }, Effects.none ) + -- TODO make expand and collapse work + ( model, Effects.none ) view : Address Action -> Model -> Html @@ -44,11 +40,13 @@ view address model = [ href ("https://github.com/" ++ model.name), target "_blank" ] [ text model.name ] , button - [ class "hide-result", onClick address Collapse ] + -- TODO when the user clicks, send a Collapse action + [ class "hide-result" ] [ text "X" ] ] else [ button - [ class "expand-result", onClick address Expand ] + -- TODO when the user clicks, send an Expand action + [ class "expand-result" ] [ text "Show" ] ] diff --git a/stages/10/README.md b/stages/10/README.md index 5bbcd78..8f7f700 100644 --- a/stages/10/README.md +++ b/stages/10/README.md @@ -16,8 +16,10 @@ to fail; in that case, just run `elm package install` again.) elm live Main.elm --open -- --output=elm.js ``` -## Compiling CSS +## Running Tests ```bash -elm test css/Stylesheets.elm +cd test +elm package install +elm test TestRunner.elm ``` diff --git a/stages/10/elm-package.json b/stages/10/elm-package.json index ea197b6..5728b71 100644 --- a/stages/10/elm-package.json +++ b/stages/10/elm-package.json @@ -12,8 +12,7 @@ "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" + "evancz/start-app": "2.0.0 <= v < 3.0.0" }, "elm-version": "0.16.0 <= v < 0.17.0" } diff --git a/stages/9/Component/ElmHub.elm b/stages/11/Component/ElmHub.elm similarity index 100% rename from stages/9/Component/ElmHub.elm rename to stages/11/Component/ElmHub.elm diff --git a/stages/9/Component/SearchResult.elm b/stages/11/Component/SearchResult.elm similarity index 75% rename from stages/9/Component/SearchResult.elm rename to stages/11/Component/SearchResult.elm index 4dedbd3..67d7d37 100644 --- a/stages/9/Component/SearchResult.elm +++ b/stages/11/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 @@ -40,13 +44,11 @@ view address model = [ href ("https://github.com/" ++ model.name), target "_blank" ] [ 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/10/ElmHub.elm b/stages/11/ElmHub.elm similarity index 100% rename from stages/10/ElmHub.elm rename to stages/11/ElmHub.elm diff --git a/stages/11/Main.elm b/stages/11/Main.elm new file mode 100644 index 0000000..5b8e88e --- /dev/null +++ b/stages/11/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/11/README.md b/stages/11/README.md new file mode 100644 index 0000000..b46a7a8 --- /dev/null +++ b/stages/11/README.md @@ -0,0 +1,23 @@ +Stage 11 +======== + +## Installation + +```bash +elm package install +``` + +(Answer `y` at the prompt. In rare cases a known issue can cause the download +to fail; in that case, just run `elm package install` again.) + +## Building + +```bash +elm live Main.elm --open -- --output=elm.js +``` + +## Compiling CSS + +```bash +elm test css/Stylesheets.elm +``` diff --git a/stages/10/Stylesheets.elm b/stages/11/Stylesheets.elm similarity index 100% rename from stages/10/Stylesheets.elm rename to stages/11/Stylesheets.elm diff --git a/stages/10/css/Stylesheets.elm b/stages/11/css/Stylesheets.elm similarity index 100% rename from stages/10/css/Stylesheets.elm rename to stages/11/css/Stylesheets.elm diff --git a/stages/11/elm-hub.png b/stages/11/elm-hub.png new file mode 100644 index 0000000000000000000000000000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>ehWrZT7Iq7P#N4mXFto3T0BAO9BLZ zZuhQ@!xEFuWfNl$C%R=apM~0A+hSG16jx@@3$0UJnFU(=Gs_PjC`~QczbFJ;qxCCR zn1bUXa3-Xv*g?;;6r^kp$8)I#2e%a+;&LEB-zy*Re#I6Z4T3irZV|}K&LYJ%BLbKj z@cWyVpFTOY&7W6HF--e3L>#~cpeG{zLcHbyHUXPM2(<&zzze{)fVP?DkZl7#TeJ4~ zlW%){T=i)t`3q4^hTqW(lu}-w*R!eO(l_Hg``0VN5!bB>>6_N_`bxqXDyD#a86SB*J#R;%URQ zSFTHX<`_WQ&cj1MwjedVBLKXYljNL~R(Pm6sBBuA*hvv$(#3(KeBi2!%5+hWI?ZoQ2FUnkP$ga&JuvM!XqPqcPs@3Z7zZQ zI48+@xi-efp z;Y#3~CBc6KFXtpV^Cno}K@#U+5ikunWUbo|)O$VtKXD7qJ0u8@X8-^I07*qoM6N<$ Ef>T55F8}}l literal 0 HcmV?d00001 diff --git a/stages/11/elm-package.json b/stages/11/elm-package.json new file mode 100644 index 0000000..ea197b6 --- /dev/null +++ b/stages/11/elm-package.json @@ -0,0 +1,19 @@ +{ + "version": "1.0.0", + "summary": "Like GitHub, but for Elm stuff.", + "repository": "https://github.com/rtfeldman/elm-workshop.git", + "license": "BSD-3-Clause", + "source-directories": [ + "." + ], + "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/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/11/index.html b/stages/11/index.html new file mode 100644 index 0000000..5db9b93 --- /dev/null +++ b/stages/11/index.html @@ -0,0 +1,26 @@ + + + + + + ElmHub + + + + + + + + + + + + + + + diff --git a/stages/11/style.css b/stages/11/style.css new file mode 100644 index 0000000..64c74d7 --- /dev/null +++ b/stages/11/style.css @@ -0,0 +1,92 @@ + +.content { + width: 960px; + margin: 0 auto; + padding: 30px; + font-family: Helvetica, Arial, serif; +} + +header { + position: relative; + padding: 6px 12px; + height: 36px; + background-color: rgb(96, 181, 204); +} + +h1 { + color: white; + font-weight: normal; + margin: 0; +} + +.tagline { + color: #eee; + position: absolute; + right: 16px; + top: 12px; + font-size: 24px; + font-style: italic; +} + +.results { + list-style-image: url('http://img-cache.cdn.gaiaonline.com/76bd5c99d8f2236e9d3672510e933fdf/http://i278.photobucket.com/albums/kk81/d3m3nt3dpr3p/Tiny-Star-Icon.png'); + list-style-position: inside; + padding: 0; +} + +.results li { + font-size: 18px; + margin-bottom: 16px; +} + +.star-count { + font-weight: bold; + margin-right: 16px; +} + +a { + color: rgb(96, 181, 204); + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +.search-query { + padding: 8px; + font-size: 24px; + margin-bottom: 18px; + margin-top: 36px; +} + +.search-button { + padding: 8px 16px; + font-size: 24px; + color: white; + border: 1px solid #ccc; + background-color: rgb(96, 181, 204); + margin-left: 12px +} + +.search-button:hover { + color: rgb(96, 181, 204); + background-color: white; +} + +.hide-result { + background-color: transparent; + border: 0; + font-weight: bold; + font-size: 18px; + margin-left: 18px; + cursor: pointer; +} + +.hide-result:hover { + color: rgb(96, 181, 204); +} + +button:focus, input:focus { + outline: none; +} diff --git a/stages/11/test/TestRunner.elm b/stages/11/test/TestRunner.elm new file mode 100644 index 0000000..0baa6f2 --- /dev/null +++ b/stages/11/test/TestRunner.elm @@ -0,0 +1,15 @@ +module Main where + +import Signal exposing (Signal) + +import ElmTest exposing (consoleRunner) +import Console exposing (IO, run) +import Task + +import Tests + +console : IO () +console = consoleRunner Tests.all + +port runner : Signal (Task.Task x ()) +port runner = run console diff --git a/stages/11/test/Tests.elm b/stages/11/test/Tests.elm new file mode 100644 index 0000000..7c06fe2 --- /dev/null +++ b/stages/11/test/Tests.elm @@ -0,0 +1,35 @@ +module Tests (..) where + +import ElmTest exposing (..) +import ElmHub exposing (responseDecoder) +import Json.Decode exposing (decodeString) + + +all : Test +all = + suite + "Decoding responses from GitHub" + [ test "they can decode empty responses" + <| let + emptyResponse = + """{ "items": [] }""" + in + assertEqual + (decodeString responseDecoder emptyResponse) + (Ok []) + , test "they can decode responses with results in them" + <| let + response = + """{ "items": [ + { "id": 5, "full_name": "foo", "stargazers_count": 42 }, + { "id": 3, "full_name": "bar", "stargazers_count": 77 } + ] }""" + in + assertEqual + (decodeString responseDecoder response) + (Ok + [ { id = 5, name = "foo", stars = 42 } + , { id = 3, name = "bar", stars = 77 } + ] + ) + ] diff --git a/stages/11/test/elm-package.json b/stages/11/test/elm-package.json new file mode 100644 index 0000000..a440485 --- /dev/null +++ b/stages/11/test/elm-package.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0", + "summary": "Like GitHub, but for Elm stuff.", + "repository": "https://github.com/rtfeldman/elm-workshop.git", + "license": "BSD-3-Clause", + "source-directories": [ + ".", + ".." + ], + "exposed-modules": [], + "dependencies": { + "deadfoxygrandpa/elm-test": "3.1.1 <= 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-http": "3.0.0 <= v < 4.0.0", + "evancz/start-app": "2.0.0 <= v < 3.0.0", + "laszlopandy/elm-console": "1.0.3 <= v < 2.0.0" + }, + "elm-version": "0.16.0 <= v < 0.17.0" +} diff --git a/stages/9/Main.elm b/stages/9/Main.elm index 5b8e88e..fa4bada 100644 --- a/stages/9/Main.elm +++ b/stages/9/Main.elm @@ -1,7 +1,7 @@ module Main (..) where import StartApp -import Component.ElmHub exposing (..) +import ElmHub exposing (..) import Effects exposing (Effects) import Task exposing (Task) import Html exposing (Html)