Update part1, part2, and part3
This commit is contained in:
@@ -1,37 +1,33 @@
|
|||||||
module Main (..) where
|
module Main exposing (..)
|
||||||
|
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
|
|
||||||
|
|
||||||
model =
|
model =
|
||||||
{ result =
|
{ result =
|
||||||
{ id = 1
|
{ id = 1
|
||||||
, name = "TheSeamau5/elm-checkerboardgrid-tutorial"
|
, name = "TheSeamau5/elm-checkerboardgrid-tutorial"
|
||||||
, stars = 66
|
, stars = 66
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
view model =
|
view model =
|
||||||
div
|
div [ class "content" ]
|
||||||
[ class "content" ]
|
[ header []
|
||||||
[ header
|
[ -- TODO add the equivalent of <h1>ElmHub</h1> right before the tagline
|
||||||
[]
|
span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
|
||||||
[ -- TODO add the equivalent of <h1>ElmHub</h1> right before the tagline
|
]
|
||||||
span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
|
, ul [ class "results" ]
|
||||||
]
|
[ li []
|
||||||
, ul
|
[ span [ class "star-count" ] [{- TODO display the number of stars -}]
|
||||||
[ class "results" ]
|
-- TODO use the model to put a link here that points to
|
||||||
[ li
|
-- https://github.com/TheSeamau5/elm-checkerboardgrid-tutorial
|
||||||
[]
|
]
|
||||||
[ 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 =
|
main =
|
||||||
view model
|
view model
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elm-lang/core": "3.0.0 <= v < 4.0.0",
|
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||||
"evancz/elm-html": "4.0.0 <= v < 5.0.0"
|
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
||||||
},
|
},
|
||||||
"elm-version": "0.16.0 <= v < 0.17.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +1,79 @@
|
|||||||
module Main (..) where
|
module Main exposing (..)
|
||||||
|
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ query : String
|
{ query : String
|
||||||
, results : List SearchResult
|
, results : List SearchResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : ResultId
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
type alias ResultId =
|
||||||
Int
|
Int
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to this value
|
{-| TODO add a type annotation to this value
|
||||||
-}
|
-}
|
||||||
model =
|
model =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
, results =
|
, results =
|
||||||
[ { id = 1
|
[ { id = 1
|
||||||
, name = "TheSeamau5/elm-checkerboardgrid-tutorial"
|
, name = "TheSeamau5/elm-checkerboardgrid-tutorial"
|
||||||
, stars = 66
|
, stars = 66
|
||||||
}
|
}
|
||||||
, { id = 2
|
, { id = 2
|
||||||
, name = "grzegorzbalcerek/elm-by-example"
|
, name = "grzegorzbalcerek/elm-by-example"
|
||||||
, stars = 41
|
, stars = 41
|
||||||
}
|
}
|
||||||
, { id = 3
|
, { id = 3
|
||||||
, name = "sporto/elm-tutorial-app"
|
, name = "sporto/elm-tutorial-app"
|
||||||
, stars = 35
|
, stars = 35
|
||||||
}
|
}
|
||||||
, { id = 4
|
, { id = 4
|
||||||
, name = "jvoigtlaender/Elm-Tutorium"
|
, name = "jvoigtlaender/Elm-Tutorium"
|
||||||
, stars = 10
|
, stars = 10
|
||||||
}
|
}
|
||||||
, { id = 5
|
, { id = 5
|
||||||
, name = "sporto/elm-tutorial-assets"
|
, name = "sporto/elm-tutorial-assets"
|
||||||
, stars = 7
|
, stars = 7
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to this function
|
{-| TODO add a type annotation to this function
|
||||||
-}
|
-}
|
||||||
view model =
|
view model =
|
||||||
div
|
div [ class "content" ]
|
||||||
[ class "content" ]
|
[ header []
|
||||||
[ header
|
[ h1 [] [ text "ElmHub" ]
|
||||||
[]
|
, span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
|
||||||
[ h1 [] [ text "ElmHub" ]
|
]
|
||||||
, span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
|
, ul [ class "results" ]
|
||||||
|
[{- TODO use model.results and viewSearchResults to display results -}]
|
||||||
]
|
]
|
||||||
, ul
|
|
||||||
[ class "results" ]
|
|
||||||
[{- TODO use model.results and viewSearchResults to display results -}]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to this function
|
{-| 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
|
[ text result.name ]
|
||||||
[ href ("https://github.com/" ++ result.name), target "_blank" ]
|
]
|
||||||
[ text result.name ]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to this value
|
{-| TODO add a type annotation to this value
|
||||||
-}
|
-}
|
||||||
main =
|
main =
|
||||||
view model
|
view model
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elm-lang/core": "3.0.0 <= v < 4.0.0",
|
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||||
"evancz/elm-html": "4.0.0 <= v < 5.0.0"
|
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
||||||
},
|
},
|
||||||
"elm-version": "0.16.0 <= v < 0.17.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
163
part3/Main.elm
163
part3/Main.elm
@@ -1,103 +1,96 @@
|
|||||||
module Main (..) where
|
module Main exposing (..)
|
||||||
|
|
||||||
import Html exposing (..)
|
import Html exposing (..)
|
||||||
|
import Html.App
|
||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (..)
|
|
||||||
import Auth
|
|
||||||
import StartApp.Simple as StartApp
|
|
||||||
import Signal exposing (Address)
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ query : String
|
{ query : String
|
||||||
, results : List SearchResult
|
, results : List SearchResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias SearchResult =
|
type alias SearchResult =
|
||||||
{ id : ResultId
|
{ id : ResultId
|
||||||
, name : String
|
, name : String
|
||||||
, stars : Int
|
, stars : Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type alias ResultId =
|
type alias ResultId =
|
||||||
Int
|
Int
|
||||||
|
|
||||||
|
|
||||||
initialModel : Model
|
initialModel : Model
|
||||||
initialModel =
|
initialModel =
|
||||||
{ query = "tutorial"
|
{ query = "tutorial"
|
||||||
, results =
|
, results =
|
||||||
[ { id = 1
|
[ { id = 1
|
||||||
, name = "TheSeamau5/elm-checkerboardgrid-tutorial"
|
, name = "TheSeamau5/elm-checkerboardgrid-tutorial"
|
||||||
, stars = 66
|
, stars = 66
|
||||||
}
|
}
|
||||||
, { id = 2
|
, { id = 2
|
||||||
, name = "grzegorzbalcerek/elm-by-example"
|
, name = "grzegorzbalcerek/elm-by-example"
|
||||||
, stars = 41
|
, stars = 41
|
||||||
}
|
}
|
||||||
, { id = 3
|
, { id = 3
|
||||||
, name = "sporto/elm-tutorial-app"
|
, name = "sporto/elm-tutorial-app"
|
||||||
, stars = 35
|
, stars = 35
|
||||||
}
|
}
|
||||||
, { id = 4
|
, { id = 4
|
||||||
, name = "jvoigtlaender/Elm-Tutorium"
|
, name = "jvoigtlaender/Elm-Tutorium"
|
||||||
, stars = 10
|
, stars = 10
|
||||||
}
|
}
|
||||||
, { id = 5
|
, { id = 5
|
||||||
, name = "sporto/elm-tutorial-assets"
|
, name = "sporto/elm-tutorial-assets"
|
||||||
, stars = 7
|
, stars = 7
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
view : Address Action -> Model -> Html
|
|
||||||
view address model =
|
|
||||||
div
|
|
||||||
[ class "content" ]
|
|
||||||
[ header
|
|
||||||
[]
|
|
||||||
[ h1 [] [ text "ElmHub" ]
|
|
||||||
, span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
|
|
||||||
]
|
]
|
||||||
, ul
|
|
||||||
[ class "results" ]
|
|
||||||
(List.map (viewSearchResult address) model.results)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
viewSearchResult : Address Action -> SearchResult -> Html
|
|
||||||
viewSearchResult address 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" ]
|
|
||||||
[ text "X" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
type alias Action =
|
|
||||||
{ -- TODO implement this type alias
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update : Action -> Model -> Model
|
|
||||||
update action model =
|
|
||||||
-- TODO if we receive a DELETE_BY_ID action,
|
|
||||||
-- build a new model without the given ID present anymore.
|
|
||||||
model
|
|
||||||
|
|
||||||
|
|
||||||
main =
|
|
||||||
StartApp.start
|
|
||||||
{ view = view
|
|
||||||
, update = update
|
|
||||||
, model = initialModel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view model =
|
||||||
|
div [ class "content" ]
|
||||||
|
[ header []
|
||||||
|
[ h1 [] [ text "ElmHub" ]
|
||||||
|
, span [ class "tagline" ] [ text "“Like GitHub, but for Elm things.”" ]
|
||||||
|
]
|
||||||
|
, ul [ class "results" ]
|
||||||
|
(List.map viewSearchResult model.results)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewSearchResult : SearchResult -> Html Msg
|
||||||
|
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" ]
|
||||||
|
[ text "X" ]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
type alias Msg =
|
||||||
|
{ -- TODO implement this type alias
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> Model
|
||||||
|
update msg model =
|
||||||
|
-- TODO if we receive a DELETE_BY_ID message,
|
||||||
|
-- build a new model without the given ID present anymore.
|
||||||
|
model
|
||||||
|
|
||||||
|
|
||||||
|
main : Program Never
|
||||||
|
main =
|
||||||
|
Html.App.beginnerProgram
|
||||||
|
{ view = view
|
||||||
|
, update = update
|
||||||
|
, model = initialModel
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"elm-lang/core": "3.0.0 <= v < 4.0.0",
|
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||||
"evancz/elm-effects": "2.0.0 <= v < 3.0.0",
|
"elm-lang/html": "1.0.0 <= v < 2.0.0"
|
||||||
"evancz/elm-html": "4.0.0 <= v < 5.0.0",
|
|
||||||
"evancz/start-app": "2.0.0 <= v < 3.0.0"
|
|
||||||
},
|
},
|
||||||
"elm-version": "0.16.0 <= v < 0.17.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user