Skip to content

Commit

Permalink
add dog info
Browse files Browse the repository at this point in the history
  • Loading branch information
Nondv committed May 23, 2019
1 parent f5f76ab commit c652dcd
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Main exposing (main)

import Browser
import Html exposing (Attribute, Html, br, button, div, input, text, textarea)
import Html exposing (Attribute, Html, br, button, div, h3, input, text, textarea)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onInput)

Expand All @@ -22,6 +22,9 @@ type alias Model =
{ name : String
, surname : String
, bio : String
, dogName : String
, breed : String
, dogBio : String
}


Expand All @@ -30,6 +33,9 @@ init =
{ name = ""
, surname = ""
, bio = ""
, dogName = ""
, breed = ""
, dogBio = ""
}


Expand All @@ -40,13 +46,22 @@ init =
view : Model -> Html Msg
view model =
div []
[ input [ placeholder "Name", value model.name, onInput ChangeName ] []
[ h3 [] [ text "Hooman" ]
, input [ placeholder "Name", value model.name, onInput ChangeName ] []
, br [] []
, input [ placeholder "Surname", value model.surname, onInput ChangeSurname ] []
, br [] []
, textarea [ placeholder "Bio", onInput ChangeBio, value model.bio ] []
, br [] []
, button [ onClick Save ] [ text "Save" ]
, h3 [] [ text "Doggo" ]
, input [ placeholder "Name", value model.dogName, onInput ChangeDogName ] []
, br [] []
, input [ placeholder "Breed", value model.breed, onInput ChangeBreed ] []
, br [] []
, textarea [ placeholder "Bio", onInput ChangeDogBio, value model.dogBio ] []
, br [] []
, button [ onClick SaveDog ] [ text "Save" ]
]


Expand All @@ -59,6 +74,10 @@ type Msg
| ChangeSurname String
| ChangeBio String
| Save
| ChangeDogName String
| ChangeBreed String
| ChangeDogBio String
| SaveDog


update : Msg -> Model -> Model
Expand All @@ -79,3 +98,19 @@ update msg model =
, surname = model.surname ++ "!"
, bio = model.bio ++ "!"
}

ChangeDogName newName ->
{ model | dogName = newName }

ChangeBreed newBreed ->
{ model | breed = newBreed }

ChangeDogBio newBio ->
{ model | dogBio = newBio }

SaveDog ->
{ model
| dogName = model.dogName ++ " Woof!"
, breed = model.breed ++ " Woof!"
, dogBio = model.dogBio ++ " Woof!"
}

0 comments on commit c652dcd

Please sign in to comment.