swap 12 and 13
This commit is contained in:
52
part12/Component/SearchResult.elm
Normal file
52
part12/Component/SearchResult.elm
Normal file
@@ -0,0 +1,52 @@
|
||||
module Component.SearchResult (..) where
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
import Signal exposing (Address)
|
||||
import Effects exposing (Effects)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ id : Int
|
||||
, name : String
|
||||
, stars : Int
|
||||
, expanded : Bool
|
||||
}
|
||||
|
||||
|
||||
type alias ResultId =
|
||||
Int
|
||||
|
||||
|
||||
type Action
|
||||
= Expand
|
||||
| Collapse
|
||||
|
||||
|
||||
update : Action -> Model -> ( Model, Effects Action )
|
||||
update action model =
|
||||
-- TODO make expand and collapse work
|
||||
( model, Effects.none )
|
||||
|
||||
|
||||
view : Address Action -> Model -> Html
|
||||
view address model =
|
||||
li
|
||||
[]
|
||||
<| if model.expanded then
|
||||
[ span [ class "star-count" ] [ text (toString model.stars) ]
|
||||
, a
|
||||
[ href ("https://github.com/" ++ model.name), target "_blank" ]
|
||||
[ text model.name ]
|
||||
, button
|
||||
-- TODO when the user clicks, send a Collapse action
|
||||
[ class "hide-result" ]
|
||||
[ text "X" ]
|
||||
]
|
||||
else
|
||||
[ button
|
||||
-- TODO when the user clicks, send an Expand action
|
||||
[ class "expand-result" ]
|
||||
[ text "Show" ]
|
||||
]
|
||||
Reference in New Issue
Block a user