-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Browser.element app with textarea, #55
- Loading branch information
Showing
1 changed file
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,67 @@ | ||
module Main exposing (main) | ||
|
||
import Html exposing (text) | ||
import Browser | ||
import Html exposing (Html, div, text, textarea) | ||
import Html.Events exposing (onInput) | ||
|
||
main = text "Hello Elm Capture!" | ||
|
||
main = | ||
Browser.element | ||
{ init = init | ||
, update = update | ||
, subscriptions = subscriptions | ||
, view = view | ||
} | ||
|
||
|
||
|
||
-- Model containg the capture text | ||
|
||
|
||
type alias Model = | ||
{ capture : String } | ||
|
||
|
||
|
||
-- Msg | ||
|
||
|
||
type Msg | ||
= Capture String | ||
|
||
|
||
|
||
-- init | ||
|
||
|
||
initModel : Model | ||
initModel = | ||
{ capture = "" } | ||
|
||
|
||
type alias Flags = | ||
() | ||
|
||
|
||
init : Flags -> ( Model, Cmd Msg ) | ||
init _ = | ||
( initModel, Cmd.none ) | ||
|
||
|
||
update : Msg -> Model -> ( Model, Cmd Msg ) | ||
update msg model = | ||
case msg of | ||
Capture text -> | ||
( { model | capture = text }, Cmd.none ) | ||
|
||
|
||
subscriptions : Model -> Sub Msg | ||
subscriptions _ = | ||
Sub.none | ||
|
||
|
||
view : Model -> Html Msg | ||
view model = | ||
div [] | ||
[ textarea [ onInput Capture ] [] | ||
] |