Skip to content

Instantly share code, notes, and snippets.

@amencarini
Created August 17, 2016 10:15
Show Gist options
  • Save amencarini/9c676d7cae44ca393873cdbf9955c877 to your computer and use it in GitHub Desktop.
Save amencarini/9c676d7cae44ca393873cdbf9955c877 to your computer and use it in GitHub Desktop.
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