Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.19 #17

Merged
merged 7 commits into from
Jan 22, 2019
Merged

0.19 #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
elm-stuff/
repl-temp-*
npm-debug.log
demo/demo.js
demo/demo.js
node_modules/
38 changes: 18 additions & 20 deletions demo/DropdownDemo.elm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module DropdownDemo exposing (main)

import Html exposing (Html, text, p, label, form, ul, li)
import Html.Attributes exposing (style, for)
import Browser
import Dropdown
import Html exposing (Html, form, label, li, p, text, ul)
import Html.Attributes exposing (for, style)


main : Program Never Model Msg
main : Program () Model Msg
main =
Html.program
Browser.sandbox
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
}


Expand All @@ -20,12 +20,10 @@ type alias Model =
}


init : ( Model, Cmd Msg )
init : Model
init =
( { selectedValue = Nothing
}
, Cmd.none
)
{ selectedValue = Nothing
}


dropdownOptions : Dropdown.Options Msg
Expand All @@ -34,13 +32,13 @@ dropdownOptions =
defaultOptions =
Dropdown.defaultOptions DropdownChanged
in
{ defaultOptions
| items =
[ { value = "1", text = "One", enabled = True }
, { value = "2", text = "Two", enabled = True }
]
, emptyItem = Just { value = "0", text = "[Please Select]", enabled = True }
}
{ defaultOptions
| items =
[ { value = "1", text = "One", enabled = True }
, { value = "2", text = "Two", enabled = True }
]
, emptyItem = Just { value = "0", text = "[Please Select]", enabled = True }
}


subscriptions : Model -> Sub Msg
Expand Down Expand Up @@ -72,11 +70,11 @@ type Msg
| DropdownChanged (Maybe String)


update : Msg -> Model -> ( Model, Cmd Msg )
update : Msg -> Model -> Model
update msg model =
case msg of
NoOp ->
( model, Cmd.none )
model

DropdownChanged selectedValue ->
( { model | selectedValue = selectedValue }, Cmd.none )
{ model | selectedValue = selectedValue }
50 changes: 26 additions & 24 deletions demo/InputBigNumberDemo.elm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module InputNumberDemo exposing (main)

import Html exposing (Html, text, p, label, form, ul, li)
import Html.Attributes as Html exposing (style, for)
import Browser
import Html exposing (Html, form, label, li, p, text, ul)
import Html.Attributes as Html exposing (for, style)
import Input.BigNumber as Number


main : Program Never Model Msg
main : Program () Model Msg
main =
Html.program
Browser.sandbox
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
}


Expand All @@ -21,11 +21,9 @@ type alias Model =
}


init : ( Model, Cmd Msg )
init : Model
init =
( { value = "", hasFocus = False }
, Cmd.none
)
{ value = "", hasFocus = False }


inputOptions : Number.Options Msg
Expand All @@ -34,15 +32,10 @@ inputOptions =
defaultOptions =
Number.defaultOptions InputChanged
in
{ defaultOptions
| maxLength = Just 20
, hasFocus = Just FocusChanged
}


subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
{ defaultOptions
| maxLength = Just 20
, hasFocus = Just FocusChanged
}


view : Model -> Html Msg
Expand All @@ -59,28 +52,37 @@ view model =
]
, p []
[ ul []
[ li [] [ text "Max Length: ", text <| Maybe.withDefault "No Limit" <| Maybe.map toString <| inputOptions.maxLength ]
[ li [] [ text "Max Length: ", text <| Maybe.withDefault "No Limit" <| Maybe.map String.fromInt <| inputOptions.maxLength ]
, li [] [ text "Value: ", text model.value ]
, li [] [ text "Has Focus: ", text <| toString model.hasFocus ]
, li [] [ text "Has Focus: ", text <| boolToString model.hasFocus ]
]
]
]


boolToString : Bool -> String
boolToString bool =
if bool then
"True"

else
"False"


type Msg
= NoOp
| InputChanged String
| FocusChanged Bool


update : Msg -> Model -> ( Model, Cmd Msg )
update : Msg -> Model -> Model
update msg model =
case msg of
NoOp ->
( model, Cmd.none )
model

InputChanged value ->
( { model | value = value }, Cmd.none )
{ model | value = value }

FocusChanged bool ->
( { model | hasFocus = bool }, Cmd.none )
{ model | hasFocus = bool }
61 changes: 35 additions & 26 deletions demo/InputFloatDemo.elm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module InputFloatDemo exposing (main)

import Browser
import Html exposing (Html, form, label, li, p, text, ul)
import Html.Attributes as Html exposing (for, style)
import Input.Float as Float


main : Program Never Model Msg
main : Program () Model Msg
main =
Html.program
Browser.sandbox
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
}


Expand All @@ -23,11 +23,9 @@ type alias Model =
}


init : ( Model, Cmd Msg )
init : Model
init =
( { value = Nothing, valueString = "", hasFocus = False, hasFocusString = False }
, Cmd.none
)
{ value = Nothing, valueString = "", hasFocus = False, hasFocusString = False }


inputOptions : Float.Options Msg
Expand Down Expand Up @@ -56,11 +54,6 @@ inputStringOptions =
}


subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none


view : Model -> Html Msg
view model =
form []
Expand All @@ -75,10 +68,18 @@ view model =
]
, p []
[ ul []
[ li [] [ text "Max Value: ", text <| Maybe.withDefault "No Max" <| Maybe.map toString <| inputOptions.maxValue ]
, li [] [ text "Min Value: ", text <| Maybe.withDefault "No Min" <| Maybe.map toString <| inputOptions.minValue ]
, li [] [ text "Value: ", text <| Maybe.withDefault "NaN" <| Maybe.map toString <| model.value ]
, li [] [ text "Has Focus: ", text <| toString model.hasFocus ]
[ li [] [ text "Max Value: ", text <| Maybe.withDefault "No Max" <| Maybe.map String.fromFloat <| inputOptions.maxValue ]
, li [] [ text "Min Value: ", text <| Maybe.withDefault "No Min" <| Maybe.map String.fromFloat <| inputOptions.minValue ]
, li [] [ text "Value: ", text <| Maybe.withDefault "NaN" <| Maybe.map String.fromFloat <| model.value ]
, li []
[ text "Has Focus: "
, text <|
if model.hasFocus then
"True"

else
"False"
]
]
]
, p []
Expand All @@ -92,10 +93,18 @@ view model =
]
, p []
[ ul []
[ li [] [ text "Max Value: ", text <| Maybe.withDefault "No Max" <| Maybe.map toString <| inputOptions.maxValue ]
, li [] [ text "Min Value: ", text <| Maybe.withDefault "No Min" <| Maybe.map toString <| inputOptions.minValue ]
, li [] [ text "Value: ", text <| Maybe.withDefault "NaN" <| Maybe.map toString <| model.value ]
, li [] [ text "Has Focus: ", text <| toString model.hasFocus ]
[ li [] [ text "Max Value: ", text <| Maybe.withDefault "No Max" <| Maybe.map String.fromFloat <| inputOptions.maxValue ]
, li [] [ text "Min Value: ", text <| Maybe.withDefault "No Min" <| Maybe.map String.fromFloat <| inputOptions.minValue ]
, li [] [ text "Value: ", text <| model.valueString ]
, li []
[ text "Has Focus: "
, text <|
if model.hasFocusString then
"True"

else
"False"
]
]
]
]
Expand All @@ -109,20 +118,20 @@ type Msg
| FocusStringChanged Bool


update : Msg -> Model -> ( Model, Cmd Msg )
update : Msg -> Model -> Model
update msg model =
case msg of
NoOp ->
( model, Cmd.none )
model

InputChanged value ->
( { model | value = value }, Cmd.none )
{ model | value = value }

FocusChanged bool ->
( { model | hasFocus = bool }, Cmd.none )
{ model | hasFocus = bool }

InputStringChanged value ->
( { model | valueString = value }, Cmd.none )
{ model | valueString = value }

FocusStringChanged bool ->
( { model | hasFocusString = bool }, Cmd.none )
{ model | hasFocusString = bool }
Loading