Revise parts 1, 2, and 3.
This commit is contained in:
@@ -12,7 +12,7 @@ Getting Started
|
|||||||
4. Run the following command to install everything else:
|
4. Run the following command to install everything else:
|
||||||
|
|
||||||
```bash
|
```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):
|
**Note:** If step 4 gives you an `EACCESS` error on OS X, try [this fix](https://docs.npmjs.com/getting-started/fixing-npm-permissions):
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ model =
|
|||||||
elmHubHeader =
|
elmHubHeader =
|
||||||
header []
|
header []
|
||||||
[ -- TODO add the equivalent of <h1>ElmHub</h1> right before this <span>
|
[ -- 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." ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
"elm-lang/core": "4.0.5 <= v < 5.0.0",
|
||||||
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
"elm-lang/html": "1.1.0 <= v < 2.0.0"
|
||||||
},
|
},
|
||||||
"elm-version": "0.17.0 <= v < 0.18.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,12 @@
|
|||||||
module Main exposing (..)
|
module Main exposing (..)
|
||||||
|
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
|
import Html.App
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
|
import Html.Events exposing (onClick)
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
initialModel =
|
||||||
{ 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 =
|
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
, results =
|
, results =
|
||||||
[ { id = 1
|
[ { id = 1
|
||||||
@@ -50,35 +33,41 @@ model =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
elmHubHeader : Html a
|
|
||||||
elmHubHeader =
|
elmHubHeader =
|
||||||
header []
|
header []
|
||||||
[ h1 [] [ text "ElmHub" ]
|
[ 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 =
|
view model =
|
||||||
div [ class "content" ]
|
div [ class "content" ]
|
||||||
[ elmHubHeader
|
[ elmHubHeader
|
||||||
, ul [ class "results" ]
|
, ul [ class "results" ] (List.map viewSearchResult model.results)
|
||||||
[{- TODO use model.results and viewSearchResult to display results -}]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to this function
|
|
||||||
-}
|
|
||||||
viewSearchResult result =
|
viewSearchResult result =
|
||||||
li []
|
li []
|
||||||
[ span [ class "star-count" ] [ text (toString result.stars) ]
|
[ span [ class "star-count" ] [ text (toString result.stars) ]
|
||||||
, a [ href ("https://github.com/" ++ result.name), target "_blank" ]
|
, a [ href ("https://github.com/" ++ result.name), target "_blank" ]
|
||||||
[ text result.name ]
|
[ 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 =
|
main =
|
||||||
view model
|
Html.App.beginnerProgram
|
||||||
|
{ view = view
|
||||||
|
, update = update
|
||||||
|
, model = initialModel
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
"elm-lang/core": "4.0.5 <= v < 5.0.0",
|
||||||
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
"elm-lang/html": "1.1.0 <= v < 2.0.0"
|
||||||
},
|
},
|
||||||
"elm-version": "0.17.0 <= v < 0.18.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,17 +13,20 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : Int
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
type alias Msg =
|
||||||
Int
|
{ operation : String
|
||||||
|
, data : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
{-| TODO add a type annotation to this value
|
||||||
|
-}
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
, results =
|
, results =
|
||||||
@@ -51,17 +54,17 @@ initialModel =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
elmHubHeader : Html a
|
{-| TODO add a type annotation to this function
|
||||||
|
-}
|
||||||
elmHubHeader =
|
elmHubHeader =
|
||||||
header []
|
header []
|
||||||
[ h1 [] [ text "ElmHub" ]
|
[ 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 =
|
view model =
|
||||||
div [ class "content" ]
|
div [ class "content" ]
|
||||||
[ elmHubHeader
|
[ 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 =
|
viewSearchResult result =
|
||||||
li []
|
li []
|
||||||
[ span [ class "star-count" ] [ text (toString result.stars) ]
|
[ span [ class "star-count" ] [ text (toString result.stars) ]
|
||||||
, a [ href ("https://github.com/" ++ result.name), target "_blank" ]
|
, a [ href ("https://github.com/" ++ result.name), target "_blank" ]
|
||||||
[ text result.name ]
|
[ text result.name ]
|
||||||
, button
|
, button
|
||||||
-- TODO add an onClick handler that sends a DELETE_BY_ID action
|
[ class "hide-result", onClick { operation = "DELETE_BY_ID", data = result.id } ]
|
||||||
[ class "hide-result" ]
|
|
||||||
[ text "X" ]
|
[ text "X" ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
type alias Msg =
|
{-| TODO add a type annotation to this function
|
||||||
{ -- TODO implement this type alias
|
-}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> Model
|
|
||||||
update msg model =
|
update msg model =
|
||||||
-- TODO if we receive a DELETE_BY_ID message,
|
if msg.operation == "DELETE_BY_ID" then
|
||||||
-- build a new model without the given ID present anymore.
|
{ model
|
||||||
|
| results = List.filter (\result -> result.id /= msg.data) model.results
|
||||||
|
}
|
||||||
|
else
|
||||||
model
|
model
|
||||||
|
|
||||||
|
|
||||||
main : Program Never
|
|
||||||
main =
|
main =
|
||||||
Html.App.beginnerProgram
|
Html.App.beginnerProgram
|
||||||
{ view = view
|
{ view = view
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
"elm-lang/core": "4.0.5 <= v < 5.0.0",
|
||||||
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
"elm-lang/html": "1.1.0 <= v < 2.0.0"
|
||||||
},
|
},
|
||||||
"elm-version": "0.17.0 <= v < 0.18.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user