mirror of
https://github.com/Orasund/elm-ui-widgets.git
synced 2024-11-22 04:58:49 +03:00
also resolved #2
This commit is contained in:
parent
da1907142d
commit
ef6519a839
@ -34,7 +34,6 @@ sortTable palette =
|
||||
, ascIcon = Icons.chevronUp |> Element.html |> Element.el []
|
||||
, descIcon = Icons.chevronDown |> Element.html |> Element.el []
|
||||
, defaultIcon = Element.none
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (IsButtonEnabled isButtonEnabled) =
|
||||
|
@ -52,8 +52,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (IsOpen isOpen) =
|
||||
|
@ -49,8 +49,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (IsExpanded isExpanded) =
|
||||
|
@ -47,8 +47,6 @@ subscriptions () =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view _ style () =
|
||||
|
@ -52,8 +52,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (IsEnabled isEnabled) =
|
||||
|
@ -59,8 +59,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (Selected selected) =
|
||||
|
@ -51,8 +51,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (Selected selected) =
|
||||
|
@ -31,7 +31,7 @@ materialStyle =
|
||||
|> .panel
|
||||
|> .content
|
||||
|> .expandIcon
|
||||
, defaultIcon = Element.none
|
||||
, defaultIcon = Element.none
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,8 +76,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style model =
|
||||
|
@ -50,8 +50,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (IsButtonEnabled isButtonEnabled) =
|
||||
|
@ -49,8 +49,6 @@ subscriptions _ =
|
||||
|
||||
|
||||
{-| You can remove the msgMapper. But by doing so, make sure to also change `msg` to `Msg` in the line below.
|
||||
|
||||
|
||||
-}
|
||||
view : (Msg -> msg) -> Style style msg -> Model -> Element msg
|
||||
view msgMapper style (Selected selected) =
|
||||
|
@ -6,6 +6,7 @@ import Internal.Select as Select
|
||||
import Widget.Style exposing (ButtonStyle, ColumnStyle, RowStyle)
|
||||
import Widget.Style.Customize as Customize
|
||||
|
||||
|
||||
internal :
|
||||
{ list
|
||||
| content : List (Attribute msg)
|
||||
@ -66,18 +67,19 @@ internalButton style list =
|
||||
(style.button
|
||||
|> Customize.containerButton
|
||||
(style.list.content
|
||||
++ (if List.length list == 1 then
|
||||
[]
|
||||
++ (if List.length list == 1 then
|
||||
[]
|
||||
|
||||
else if i == 0 then
|
||||
style.list.ifFirst
|
||||
else if i == 0 then
|
||||
style.list.ifFirst
|
||||
|
||||
else if i == (List.length list - 1) then
|
||||
style.list.ifLast
|
||||
else if i == (List.length list - 1) then
|
||||
style.list.ifLast
|
||||
|
||||
else
|
||||
style.list.otherwise
|
||||
))
|
||||
else
|
||||
style.list.otherwise
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -21,4 +21,4 @@ tab style { tabs, content } =
|
||||
|> content
|
||||
|> Element.el style.content.content
|
||||
]
|
||||
|> Element.column style.containerColumn
|
||||
|> Element.column style.containerColumn
|
||||
|
@ -374,9 +374,8 @@ dialog :
|
||||
-> List (Attribute msg)
|
||||
dialog =
|
||||
let
|
||||
|
||||
fun : DialogStyle msg -> Dialog msg -> List (Attribute msg)
|
||||
fun =
|
||||
fun =
|
||||
Dialog.dialog
|
||||
in
|
||||
fun
|
||||
@ -388,9 +387,6 @@ dialog =
|
||||
----------------------------------------------------------}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{-| Expansion Panel widget type
|
||||
-}
|
||||
type alias ExpansionPanel msg =
|
||||
@ -662,4 +658,4 @@ circularProgressIndicator :
|
||||
-> Maybe Float
|
||||
-> Element msg
|
||||
circularProgressIndicator =
|
||||
ProgressIndicator.circularProgressIndicator
|
||||
ProgressIndicator.circularProgressIndicator
|
||||
|
@ -192,27 +192,25 @@ toSelect onSelect ({ arrangement, toString, fromString } as model) =
|
||||
|
||||
This might be useful at first, but you should consider writing your own view function.
|
||||
|
||||
```
|
||||
view :
|
||||
(section -> Element msg)
|
||||
-> Model section
|
||||
-> List (Element msg)
|
||||
view asElement { toString, arrangement } =
|
||||
arrangement
|
||||
|> List.map
|
||||
(\header ->
|
||||
Element.el
|
||||
[ header
|
||||
|> toString
|
||||
|> Attributes.id
|
||||
|> Element.htmlAttribute
|
||||
, Element.width <| Element.fill
|
||||
]
|
||||
<|
|
||||
asElement <|
|
||||
header
|
||||
)
|
||||
```
|
||||
view :
|
||||
(section -> Element msg)
|
||||
-> Model section
|
||||
-> List (Element msg)
|
||||
view asElement { toString, arrangement } =
|
||||
arrangement
|
||||
|> List.map
|
||||
(\header ->
|
||||
Element.el
|
||||
[ header
|
||||
|> toString
|
||||
|> Attributes.id
|
||||
|> Element.htmlAttribute
|
||||
, Element.width <| Element.fill
|
||||
]
|
||||
<|
|
||||
asElement <|
|
||||
header
|
||||
)
|
||||
|
||||
-}
|
||||
view :
|
||||
|
@ -19,7 +19,6 @@ A [snackbar](https://material.io/components/snackbars/) shows notification, one
|
||||
|
||||
@docs insert, insertFor, dismiss
|
||||
|
||||
|
||||
-}
|
||||
|
||||
import Element exposing (Element)
|
||||
@ -27,6 +26,7 @@ import Queue exposing (Queue)
|
||||
import Widget exposing (TextButton)
|
||||
import Widget.Style exposing (SnackbarStyle)
|
||||
|
||||
|
||||
{-| A message with maybe some action button
|
||||
-}
|
||||
type alias Message msg =
|
||||
@ -108,6 +108,7 @@ current : Snackbar a -> Maybe a
|
||||
current model =
|
||||
model.current |> Maybe.map Tuple.first
|
||||
|
||||
|
||||
{-| Views the current Message. (only one at a time)
|
||||
-}
|
||||
view :
|
||||
@ -133,4 +134,3 @@ view style toMessage model =
|
||||
|> Element.row style.containerRow
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Widget.Style exposing ( ButtonStyle, SwitchStyle, ColumnStyle, DialogStyle, ExpansionPanelStyle, LayoutStyle, RowStyle, SnackbarStyle, SortTableStyle, TabStyle, TextInputStyle, ProgressIndicatorStyle)
|
||||
module Widget.Style exposing (ButtonStyle, SwitchStyle, ColumnStyle, DialogStyle, ExpansionPanelStyle, LayoutStyle, RowStyle, SnackbarStyle, SortTableStyle, TabStyle, TextInputStyle, ProgressIndicatorStyle)
|
||||
|
||||
{-| This module contains style types for every widget.
|
||||
|
||||
@ -33,6 +33,7 @@ type alias SwitchStyle msg =
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias ButtonStyle msg =
|
||||
{ containerButton : List (Attribute msg)
|
||||
@ -46,12 +47,11 @@ type alias ButtonStyle msg =
|
||||
}
|
||||
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias DialogStyle msg =
|
||||
{ containerColumn : List (Attribute msg)
|
||||
, content :
|
||||
{ title :
|
||||
{ title :
|
||||
{ contentText : List (Attribute msg)
|
||||
}
|
||||
, text :
|
||||
@ -68,8 +68,6 @@ type alias DialogStyle msg =
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
{-| Technical Remark:
|
||||
|
||||
- If icons are defined in Svg, they might not display correctly.
|
||||
@ -88,7 +86,7 @@ type alias ExpansionPanelStyle msg =
|
||||
, expandIcon : Element Never
|
||||
, collapseIcon : Element Never
|
||||
}
|
||||
}
|
||||
}
|
||||
, content :
|
||||
{ container : List (Attribute msg)
|
||||
}
|
||||
@ -126,7 +124,7 @@ type alias TextInputStyle msg =
|
||||
{-| -}
|
||||
type alias TabStyle msg =
|
||||
{ containerColumn : List (Attribute msg)
|
||||
, content :
|
||||
, content :
|
||||
{ tabs :
|
||||
{ containerRow : List (Attribute msg)
|
||||
, content : ButtonStyle msg
|
||||
@ -202,4 +200,3 @@ type alias LayoutStyle msg =
|
||||
type alias ProgressIndicatorStyle msg =
|
||||
{ containerFunction : Maybe Float -> Element msg
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ Widget.textButton
|
||||
|
||||
@docs containerTextInput, mapContainerTextInput
|
||||
|
||||
|
||||
# Content
|
||||
|
||||
@docs content, mapContent
|
||||
@ -62,17 +63,19 @@ Widget.textButton
|
||||
|
||||
@docs contentInFront, mapContentInFront
|
||||
|
||||
|
||||
# Conditional Styling
|
||||
|
||||
@docs otherwise, mapOtherwise
|
||||
|
||||
@docs ifActive, mapIfActive
|
||||
|
||||
@docs ifDisabled, mapIfDisabled
|
||||
@docs ifDisabled, mapIfDisabled
|
||||
|
||||
@docs ifFirst, mapIfFirst
|
||||
@docs ifFirst, mapIfFirst
|
||||
|
||||
@docs ifLast, mapIfLast
|
||||
|
||||
@docs ifLast, mapIfLast
|
||||
-}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -144,6 +147,7 @@ mapContainerTable fun a =
|
||||
| containerTable = fun a.containerTable
|
||||
}
|
||||
|
||||
|
||||
containerTextInput : List b -> { a | containerTextInput : List b } -> { a | containerTextInput : List b }
|
||||
containerTextInput list a =
|
||||
a
|
||||
@ -157,6 +161,7 @@ mapContainerTextInput fun a =
|
||||
}
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Content
|
||||
--------------------------------------------------------------------------------
|
||||
@ -174,6 +179,7 @@ mapContent fun a =
|
||||
| content = fun a.content
|
||||
}
|
||||
|
||||
|
||||
contentText : List b -> { a | contentText : List b } -> { a | contentText : List b }
|
||||
contentText list a =
|
||||
a
|
||||
@ -185,7 +191,8 @@ mapContentText fun a =
|
||||
{ a
|
||||
| contentText = fun a.contentText
|
||||
}
|
||||
|
||||
|
||||
|
||||
contentInFront : List b -> { a | contentInFront : List b } -> { a | contentInFront : List b }
|
||||
contentInFront list a =
|
||||
a
|
||||
@ -198,62 +205,73 @@ mapContentInFront fun a =
|
||||
| contentInFront = fun a.contentInFront
|
||||
}
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Conditional Styling
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
otherwise : List b -> { a | otherwise : List b } -> { a | otherwise : List b }
|
||||
otherwise list a =
|
||||
|
||||
otherwise : List b -> { a | otherwise : List b } -> { a | otherwise : List b }
|
||||
otherwise list a =
|
||||
a
|
||||
|> mapOtherwise (\b -> b ++ list)
|
||||
|
||||
mapOtherwise : (b -> b) -> { a | otherwise : b } -> { a | otherwise : b }
|
||||
|
||||
mapOtherwise : (b -> b) -> { a | otherwise : b } -> { a | otherwise : b }
|
||||
mapOtherwise fun a =
|
||||
{ a
|
||||
| otherwise = fun a.otherwise
|
||||
| otherwise = fun a.otherwise
|
||||
}
|
||||
|
||||
|
||||
ifActive : List b -> { a | ifActive : List b } -> { a | ifActive : List b }
|
||||
ifActive list a =
|
||||
a
|
||||
|> mapIfActive (\b -> b ++ list)
|
||||
|
||||
|
||||
mapIfActive : (b -> b) -> { a | ifActive : b } -> { a | ifActive : b }
|
||||
mapIfActive fun a =
|
||||
{ a
|
||||
| ifActive = fun a.ifActive
|
||||
}
|
||||
|
||||
|
||||
ifDisabled : List b -> { a | ifDisabled : List b } -> { a | ifDisabled : List b }
|
||||
ifDisabled list a =
|
||||
a
|
||||
|> mapIfDisabled (\b -> b ++ list)
|
||||
|
||||
|
||||
mapIfDisabled : (b -> b) -> { a | ifDisabled : b } -> { a | ifDisabled : b }
|
||||
mapIfDisabled fun a =
|
||||
{ a
|
||||
| ifDisabled = fun a.ifDisabled
|
||||
}
|
||||
|
||||
|
||||
ifFirst : List b -> { a | ifFirst : List b } -> { a | ifFirst : List b }
|
||||
ifFirst list a =
|
||||
a
|
||||
|> mapIfFirst (\b -> b ++ list)
|
||||
|
||||
|
||||
mapIfFirst : (b -> b) -> { a | ifFirst : b } -> { a | ifFirst : b }
|
||||
mapIfFirst fun a =
|
||||
{ a
|
||||
| ifFirst = fun a.ifFirst
|
||||
}
|
||||
|
||||
|
||||
ifLast : List b -> { a | ifLast : List b } -> { a | ifLast : List b }
|
||||
ifLast list a =
|
||||
a
|
||||
|> mapIfLast (\b -> b ++ list)
|
||||
|
||||
|
||||
mapIfLast : (b -> b) -> { a | ifLast : b } -> { a | ifLast : b }
|
||||
mapIfLast fun a =
|
||||
{ a
|
||||
| ifLast = fun a.ifLast
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user