Revise parts 1, 2, and 3.

This commit is contained in:
Richard Feldman
2016-08-16 02:37:40 -07:00
parent b557ee0842
commit 3a050f408d
7 changed files with 49 additions and 61 deletions

View File

@@ -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):

View File

@@ -16,7 +16,7 @@ model =
elmHubHeader =
header []
[ -- TODO add the equivalent of <h1>ElmHub</h1> right before this <span>
span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
]

View File

@@ -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"
}

View File

@@ -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
}

View File

@@ -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"
}

View File

@@ -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.
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

View File

@@ -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"
}