#60 Add AutoFill Input Variants

This commit is contained in:
Lucas Payr 2021-07-31 07:45:36 +02:00
parent f19ba8ff45
commit a1fc9147d7
5 changed files with 159 additions and 20 deletions

View File

@ -5,9 +5,10 @@ module Internal.Material.List exposing
, row , row
, sideSheet , sideSheet
, toggleRow , toggleRow
, cardAttributes
) )
import Element import Element exposing (Attribute)
import Element.Background as Background import Element.Background as Background
import Element.Border as Border import Element.Border as Border
import Element.Font as Font import Element.Font as Font
@ -78,6 +79,13 @@ toggleRow =
} }
} }
cardAttributes : Palette -> List (Attribute mag)
cardAttributes palette =
let
style = cardColumn palette
in
style.elementColumn ++ style.content.element
cardColumn : Palette -> ColumnStyle msg cardColumn : Palette -> ColumnStyle msg
cardColumn palette = cardColumn palette =

View File

@ -1,4 +1,4 @@
module Internal.Material.TextInput exposing (searchInput, textInput, textInputBase) module Internal.Material.TextInput exposing (textInputAttributes,searchInput, textInput, textInputBase)
import Element import Element
import Element.Border as Border import Element.Border as Border
@ -8,6 +8,9 @@ import Internal.TextInput exposing (TextInputStyle)
import Widget.Customize as Customize import Widget.Customize as Customize
import Widget.Material.Color as MaterialColor import Widget.Material.Color as MaterialColor
textInputAttributes : Palette -> List (Attribute msg)
textInputAttributes palette =
(textInput palette).content.text
textInput : Palette -> TextInputStyle msg textInput : Palette -> TextInputStyle msg
textInput palette = textInput palette =

View File

@ -1,4 +1,5 @@
module Internal.TextInput exposing (TextInput, TextInputStyle, textInput) module Internal.TextInput exposing (TextInput, TextInputStyle, usernameInput,textInput
, emailInput,searchInput,spellCheckedInput)
import Element exposing (Attribute, Element) import Element exposing (Attribute, Element)
import Element.Input as Input exposing (Placeholder) import Element.Input as Input exposing (Placeholder)
@ -28,9 +29,34 @@ type alias TextInput msg =
, onChange : String -> msg , onChange : String -> msg
} }
spellCheckedInput : TextInputStyle msg -> TextInput msg -> Element msg
spellCheckedInput =
internal Input.spellChecked
searchInput : TextInputStyle msg -> TextInput msg -> Element msg
searchInput =
internal Input.search
emailInput : TextInputStyle msg -> TextInput msg -> Element msg
emailInput =
internal Input.email
usernameInput : TextInputStyle msg -> TextInput msg -> Element msg
usernameInput =
internal Input.username
textInput : TextInputStyle msg -> TextInput msg -> Element msg textInput : TextInputStyle msg -> TextInput msg -> Element msg
textInput style { chips, placeholder, label, text, onChange } = textInput =
internal Input.text
internal : (List (Attribute msg)
-> { onChange : String -> msg
, text : String
, placeholder : Maybe (Placeholder msg)
, label : Label msg
}
-> Element msg) -> TextInputStyle msg -> TextInput msg -> Element msg
internal fun style { chips, placeholder, label, text, onChange } =
Element.row style.elementRow Element.row style.elementRow
[ if chips |> List.isEmpty then [ if chips |> List.isEmpty then
Element.none Element.none
@ -40,7 +66,7 @@ textInput style { chips, placeholder, label, text, onChange } =
|> List.map |> List.map
(Button.button style.content.chips.content) (Button.button style.content.chips.content)
|> Element.row style.content.chips.elementRow |> Element.row style.content.chips.elementRow
, Input.text style.content.text.elementTextInput , fun style.content.text.elementTextInput
{ onChange = onChange { onChange = onChange
, text = text , text = text
, placeholder = placeholder , placeholder = placeholder

View File

@ -23,6 +23,8 @@ module Widget exposing
, PasswordInputStyle, PasswordInput, newPasswordInput, currentPasswordInput , PasswordInputStyle, PasswordInput, newPasswordInput, currentPasswordInput
, TabStyle, Tab, tab , TabStyle, Tab, tab
, ProgressIndicatorStyle, ProgressIndicator, circularProgressIndicator , ProgressIndicatorStyle, ProgressIndicator, circularProgressIndicator
, usernameInput
, emailInput,searchInput,spellCheckedInput
) )
{-| This module contains different stateless view functions. No wiring required. {-| This module contains different stateless view functions. No wiring required.
@ -134,8 +136,8 @@ You can create you own widgets by sticking widgets types together.
![textInput](https://orasund.github.io/elm-ui-widgets/assets/textInput.png) ![textInput](https://orasund.github.io/elm-ui-widgets/assets/textInput.png)
@docs TextInputStyle, TextInput, textInput @docs TextInputStyle, TextInput, textInput, usernameInput, emailInput,searchInput,spellCheckedInput
@docs PasswordInputStyle, PasswordInput, newPasswordInput, currentPasswordInput @docs PasswordInputStyle, PasswordInput, newPasswordInputV2, currentPasswordInputV2
# Tab # Tab
@ -151,6 +153,10 @@ You can create you own widgets by sticking widgets types together.
@docs ProgressIndicatorStyle, ProgressIndicator, circularProgressIndicator @docs ProgressIndicatorStyle, ProgressIndicator, circularProgressIndicator
# DEPRECATED
@docs newPasswordInput, currentPasswordInput
-} -}
import Color exposing (Color) import Color exposing (Color)
@ -852,17 +858,80 @@ type alias PasswordInput msg =
{-| An input field that supports auto filling the current password {-| An input field that supports auto filling the current password
-} -}
currentPasswordInput : PasswordInputStyle msg -> PasswordInput msg -> Element msg currentPasswordInputV2 : PasswordInputStyle msg -> { text : String
currentPasswordInput = , placeholder : Maybe (Placeholder msg)
PasswordInput.currentPasswordInput , label : String
, onChange : String -> msg
, show : Bool
} -> Element msg
currentPasswordInputV2 =
let
fun : PasswordInputStyle msg -> PasswordInput msg -> Element msg
fun =
PasswordInput.currentPasswordInput
in
fun
{-| An input field that supports auto filling the new password {-| An input field that supports auto filling the new password
-} -}
newPasswordInput : PasswordInputStyle msg -> PasswordInput msg -> Element msg newPasswordInputV2 : PasswordInputStyle msg -> { text : String
newPasswordInput = , placeholder : Maybe (Placeholder msg)
PasswordInput.newPasswordInput , label : String
, onChange : String -> msg
, show : Bool
} -> Element msg
newPasswordInputV2 =
let
fun : PasswordInputStyle msg -> PasswordInput msg -> Element msg
fun =
PasswordInput.newPasswordInput
in
fun
{-| An input field that supports auto filling the username
-}
usernameInput : Palette -> TextInputStyle msg
usernameInput =
let
fun : TextInputStyle msg -> TextInput msg -> Element msg
fun =
TextInput.usernameInput
in
fun
{-| An input field that supports auto filling the email
-}
emailInput : Palette -> TextInputStyle msg
emailInput =
let
fun : TextInputStyle msg -> TextInput msg -> Element msg
fun =
TextInput.usernameInput
in
fun
{-| An input field that supports searching
-}
searchInput : Palette -> TextInputStyle msg
searchInput =
let
fun : TextInputStyle msg -> TextInput msg -> Element msg
fun =
TextInput.usernameInput
in
fun
{-| An input field that supports spell checking
-}
spellCheckedInput : Palette -> TextInputStyle msg
spellCheckedInput =
let
fun : TextInputStyle msg -> TextInput msg -> Element msg
fun =
TextInput.usernameInput
in
fun
{---------------------------------------------------------- {----------------------------------------------------------
@ -2057,3 +2126,26 @@ circularProgressIndicator :
-> Element msg -> Element msg
circularProgressIndicator = circularProgressIndicator =
ProgressIndicator.circularProgressIndicator ProgressIndicator.circularProgressIndicator
{----------------------------------------------------------
- DEPRECATED
----------------------------------------------------------}
{-| An input field that supports auto filling the current password
-}
currentPasswordInput : PasswordInputStyle msg -> PasswordInput msg -> Element msg
currentPasswordInput =
PasswordInput.currentPasswordInput
{-| An input field that supports auto filling the new password
-}
newPasswordInput : PasswordInputStyle msg -> PasswordInput msg -> Element msg
newPasswordInput =
PasswordInput.newPasswordInput

View File

@ -17,6 +17,7 @@ module Widget.Material exposing
, snackbar , snackbar
, tab, tabButton , tab, tabButton
, buttonRow , buttonRow
,cardAttributes, textInputAttributes
) )
{-| This module implements a Material design theme for all widgets. {-| This module implements a Material design theme for all widgets.
@ -57,16 +58,12 @@ Different styles for buttons have different meanings.
# Card # Card
In the material design specification the card is not really specified at all. @docs cardColumn, cardAttributes
Im practice the List seams more useful then a own card widget.
Thus for now we only provide a card containing a list.
@docs cardColumn
# Chip # Chip
@docs chip, textInput, passwordInput @docs chip,textInputAttributes, textInput, passwordInput
# Dialog # Dialog
@ -164,7 +161,7 @@ import Internal.Tab exposing (TabStyle)
import Internal.TextInput exposing (TextInputStyle) import Internal.TextInput exposing (TextInputStyle)
import Widget.Icon exposing (Icon) import Widget.Icon exposing (Icon)
import Widget.Snackbar exposing (SnackbarStyle) import Widget.Snackbar exposing (SnackbarStyle)
import Element exposing (Attribute)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -552,6 +549,14 @@ cardColumn =
List.cardColumn List.cardColumn
{-| A variant of cardColumn designed for a single item.
Use this with a normal `Element.column`, `Element.row` or even a `Element.el`.
-}
cardAttributes : Palette -> List (Attribute msg)
cardAttributes =
List.cardAttributes
{-| A basic item containing some text, a button. Spans the full width. {-| A basic item containing some text, a button. Spans the full width.
![fullBleedItem](https://orasund.github.io/elm-ui-widgets/assets/material/fullBleedItem.png) ![fullBleedItem](https://orasund.github.io/elm-ui-widgets/assets/material/fullBleedItem.png)
@ -678,6 +683,11 @@ snackbar =
-- T E X T I N P U T -- T E X T I N P U T
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
{-| A variant of textInput designed for `Input.text`.
-}
textInputAttributes : Palette -> List (Attribute msg)
textInputAttributes =
TextInput.textInputAttributes
{-| A text input style that is included only to support input chips. {-| A text input style that is included only to support input chips.