module Main exposing (..)

import Html exposing (Html, div, input, span, text)
import Html.Attributes as H exposing (..)
import Html.Events exposing (onInput)


--  MAIN


main : Program Never { value : String } Msg
main =
    Html.beginnerProgram
        { model = { value = "20" }
        , view = view
        , update = update
        }



-- MODEL


type alias Model =
    { value : String
    }



-- UPDATE


type Msg
    = SlideTemperature String


update : Msg -> Model -> Model
update msg model =
    case msg of
        SlideTemperature temperature ->
            { model | value = temperature }



-- VIEW


view : Model -> Html Msg
view model =
    div [ id "temperature_wrapper" ]
        [ input
            [ type_ "range"
            , H.min "-30"
            , H.max "40"
            , H.defaultValue "20"
            , onInput SlideTemperature
            , name "biodiversity_report[temperature]"
            , id "biodiversity_report_temperature"
            ]
            []
        , div [ id "temperature_value" ]
            [ text (model.value ++ "°C") ]
        ]

module Main exposing (..)

import Html exposing (Html, div, input, span, text)
import Html.Attributes as H exposing (..)
import Html.Events exposing (onInput)


--  MAIN


main : Program Never Model Msg
main =
    Html.beginnerProgram
        { model = initialModel
        , view = view
        , update = update
        }



-- MODEL


type alias Model =
    { value : String
    }


initialModel : Model
initialModel =
    { value = "20" }



-- UPDATE


type Msg
    = SlideTemperature String


update : Msg -> Model -> Model
update msg model =
    case msg of
        SlideTemperature temperature ->
            { model | value = temperature }



-- VIEW


view : Model -> Html Msg
view model =
    div [ id "temperature_wrapper" ]
        [ input
            [ type_ "range"
            , H.min "-30"
            , H.max "40"
            , H.defaultValue "20"
            , onInput SlideTemperature
            , name "biodiversity_report[temperature]"
            , id "biodiversity_report_temperature"
            ]
            []
        , div [ id "temperature_value" ]
            [ text (model.value ++ "°C") ]
        ]

Use Elm conventions for main, initialModel. One typical signature of an Elm 'main' is 'Program Never Model Msg'. And sometimes folks use an 'initialModel' for the initial model, rather than an explicit inline record within 'main'. - Replace record type with Model. - Declare 'initialModel' using literal record, and refer to it within 'main'.
Use Elm conventions for main, initialModel.
One typical signature of an Elm 'main' is 'Program Never Model Msg'.
And sometimes folks use an 'initialModel' for the initial model, rather than an
explicit inline record within 'main'.
- Replace record type with Model.
- Declare 'initialModel' using literal record, and refer to it within 'main'.
