Created
August 17, 2016 10:15
-
-
Save amencarini/9c676d7cae44ca393873cdbf9955c877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Card exposing (Model, view) | |
import Html exposing (Html, div, text, p) | |
import Html.Attributes exposing (class) | |
import Html.Events exposing (onClick) | |
import Debug | |
type alias Model = | |
{ name : String | |
, description : String | |
, isEditable: Bool | |
} | |
-- UPDATE | |
type Msg | |
= MakeEditable | |
update : Msg -> Model -> ( Model, Cmd Msg ) | |
update msg model = | |
case msg of | |
MakeEditable -> | |
(Debug.log "update" {model | isEditable = True} , Cmd.none ) | |
-- VIEW | |
view : Model -> Html Msg | |
view model = | |
div | |
[class "card", onClick MakeEditable] | |
(if model.isEditable then editView model else normalView model) | |
editView : Model -> List (Html Msg) | |
editView model = | |
[ div [class "title"] [text "NOPE"] | |
, p [class "description"] [text "NOPE NOPE NOPE"] | |
] | |
normalView : Model -> List (Html Msg) | |
normalView model = | |
[ div [class "title"] [text model.name] | |
, p [class "description"] [text model.description] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment