Moved Widget.Style into Widget

This commit is contained in:
Lucas Payr 2021-01-24 09:41:55 +01:00
parent 0f62ce0c91
commit 0ee3258458
48 changed files with 761 additions and 632 deletions

5
elm-analyse.json Normal file
View File

@ -0,0 +1,5 @@
{
"checks": {
"SingleFieldRecord": false
}
}

View File

@ -1,22 +1,73 @@
module Data.Style exposing (Style) module Data.Style exposing (Style,style)
import Widget.Style import Color exposing (Color)
import Color.Accessibility as Accessibility
import Color.Convert as Convert
import Element exposing (Attribute, Element)
import Element.Background as Background
import Element.Border as Border
import Element.Font as Font
import FeatherIcons
import Html.Attributes as Attributes
import Icons
import Widget.Icon as Icon
import Widget
exposing exposing
( ButtonStyle ( ButtonStyle
, ColumnStyle , ColumnStyle
, DialogStyle , DialogStyle
, ExpansionPanelStyle
, RowStyle
, SortTableStyle
, TabStyle
, TextInputStyle
, ButtonStyle
, ColumnStyle
, DialogStyle
, DividerStyle , DividerStyle
, ExpansionPanelStyle , ExpansionPanelStyle
, ItemStyle , ItemStyle
, LayoutStyle
, ProgressIndicatorStyle , ProgressIndicatorStyle
, RowStyle , RowStyle
, SortTableStyle , SortTableStyle
, SwitchStyle , SwitchStyle
, TabStyle , TabStyle
, TextInputStyle , TextInputStyle
, TitleStyle , HeaderStyle
) )
import Widget.Snackbar exposing (SnackbarStyle)
import Widget.Layout exposing (LayoutStyle)
import Widget.Style.Material as Material exposing (Palette)
style : Palette -> Style msg
style palette =
{ sortTable = Material.sortTable palette
, row = Material.row
, buttonRow = Material.buttonRow
, cardColumn = Material.cardColumn palette
, column = Material.column
, button = Material.outlinedButton palette
, primaryButton = Material.containedButton palette
, selectButton = Material.toggleButton palette
, tab = Material.tab palette
, textInput = Material.textInput palette
, chipButton = Material.chip palette
, expansionPanel = Material.expansionPanel palette
, expansionPanelItem = Material.expansionPanelItem palette
, dialog = Material.alertDialog palette
, progressIndicator = Material.progressIndicator palette
, layout = Material.layout palette
, switch = Material.switch palette
, fullBleedDivider = Material.fullBleedDivider
, insetDivider = Material.insetDivider palette
, middleDividers = Material.middleDividers palette
, insetHeader = Material.insetHeader palette
, fullBleedHeader = Material.fullBleedHeader palette
}
type alias Style msg = type alias Style msg =
@ -40,6 +91,6 @@ type alias Style msg =
, fullBleedDivider : ItemStyle (DividerStyle msg) , fullBleedDivider : ItemStyle (DividerStyle msg)
, insetDivider : ItemStyle (DividerStyle msg) , insetDivider : ItemStyle (DividerStyle msg)
, middleDividers : ItemStyle (DividerStyle msg) , middleDividers : ItemStyle (DividerStyle msg)
, insetTitle : ItemStyle (TitleStyle msg) , insetHeader : ItemStyle (HeaderStyle msg)
, fullBleedTitle : ItemStyle (TitleStyle msg) , fullBleedHeader : ItemStyle (HeaderStyle msg)
} }

View File

@ -1,67 +0,0 @@
module Data.Style.Material exposing (style)
import Color exposing (Color)
import Color.Accessibility as Accessibility
import Color.Convert as Convert
import Data.Style exposing (Style)
import Element exposing (Attribute, Element)
import Element.Background as Background
import Element.Border as Border
import Element.Font as Font
import FeatherIcons
import Html.Attributes as Attributes
import Icons
import Widget.Icon as Icon
import Widget.Style
exposing
( ButtonStyle
, ColumnStyle
, DialogStyle
, ExpansionPanelStyle
, LayoutStyle
, RowStyle
, SnackbarStyle
, SortTableStyle
, TabStyle
, TextInputStyle
)
import Widget.Style.Material as Material exposing (Palette)
sortTable : Palette -> SortTableStyle msg
sortTable palette =
{ elementTable = []
, content =
{ header = Material.textButton palette
, ascIcon = FeatherIcons.chevronUp |> Icon.elmFeather FeatherIcons.toHtml
, descIcon = FeatherIcons.chevronDown |> Icon.elmFeather FeatherIcons.toHtml
, defaultIcon = always Element.none
}
}
style : Palette -> Style msg
style palette =
{ sortTable = sortTable palette
, row = Material.row
, buttonRow = Material.buttonRow
, cardColumn = Material.cardColumn palette
, column = Material.column
, button = Material.outlinedButton palette
, primaryButton = Material.containedButton palette
, selectButton = Material.toggleButton palette
, tab = Material.tab palette
, textInput = Material.textInput palette
, chipButton = Material.chip palette
, expansionPanel = Material.expansionPanel palette
, expansionPanelItem = Material.expansionPanelItem palette
, dialog = Material.alertDialog palette
, progressIndicator = Material.progressIndicator palette
, layout = Material.layout palette
, switch = Material.switch palette
, fullBleedDivider = Material.fullBleedDivider
, insetDivider = Material.insetDivider palette
, middleDividers = Material.middleDividers palette
, insetTitle = Material.insetTitle palette
, fullBleedTitle = Material.fullBleedTitle palette
}

View File

@ -1,7 +1,7 @@
module Data.Theme exposing (Theme(..), toStyle) module Data.Theme exposing (Theme(..), toStyle)
import Data.Style exposing (Style) import Data.Style as Style exposing (Style)
import Data.Style.Material import Data.Style
import Widget.Style.Material exposing (Palette) import Widget.Style.Material exposing (Palette)
@ -14,7 +14,7 @@ toStyle : Theme -> Style msg
toStyle theme = toStyle theme =
case theme of case theme of
Material -> Material ->
Data.Style.Material.style Widget.Style.Material.defaultPalette Style.style Widget.Style.Material.defaultPalette
DarkMaterial -> DarkMaterial ->
Data.Style.Material.style Widget.Style.Material.darkPalette Style.style Widget.Style.Material.darkPalette

View File

@ -5,7 +5,7 @@ import Element exposing (Element)
import FeatherIcons import FeatherIcons
import Widget import Widget
import Widget.Icon as Icon import Widget.Icon as Icon
import Widget.Style exposing (ButtonStyle, RowStyle) import Widget exposing (ButtonStyle, RowStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -5,7 +5,7 @@ import Element exposing (Element)
import FeatherIcons import FeatherIcons
import Widget import Widget
import Widget.Icon as Icon import Widget.Icon as Icon
import Widget.Style exposing (ButtonStyle, DialogStyle) import Widget exposing (ButtonStyle, DialogStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -3,7 +3,7 @@ module Example.ExpansionPanel exposing (Model, Msg, init, subscriptions, update,
import Browser import Browser
import Element exposing (Element) import Element exposing (Element)
import Widget import Widget
import Widget.Style exposing (ExpansionPanelStyle) import Widget exposing (ExpansionPanelStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -15,7 +15,7 @@ import Material.Icons.Types exposing (Coloring(..))
import Octicons import Octicons
import Widget import Widget
import Widget.Icon exposing (Icon) import Widget.Icon exposing (Icon)
import Widget.Style exposing (ButtonStyle, RowStyle) import Widget exposing (ButtonStyle, RowStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material
import Zondicons import Zondicons

View File

@ -3,7 +3,7 @@ module Example.List exposing (Model, Msg, init, subscriptions, update, view)
import Browser import Browser
import Element exposing (Element) import Element exposing (Element)
import Widget import Widget
import Widget.Style exposing (ColumnStyle, DividerStyle, ItemStyle, TitleStyle) import Widget exposing (ColumnStyle, DividerStyle, ItemStyle, HeaderStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material
@ -12,8 +12,8 @@ type alias Style style msg =
| cardColumn : ColumnStyle msg | cardColumn : ColumnStyle msg
, insetDivider : ItemStyle (DividerStyle msg) , insetDivider : ItemStyle (DividerStyle msg)
, middleDividers : ItemStyle (DividerStyle msg) , middleDividers : ItemStyle (DividerStyle msg)
, insetTitle : ItemStyle (TitleStyle msg) , insetHeader : ItemStyle (HeaderStyle msg)
, fullBleedTitle : ItemStyle (TitleStyle msg) , fullBleedHeader : ItemStyle (HeaderStyle msg)
} }
@ -22,8 +22,8 @@ materialStyle =
{ cardColumn = Material.cardColumn Material.defaultPalette { cardColumn = Material.cardColumn Material.defaultPalette
, insetDivider = Material.insetDivider Material.defaultPalette , insetDivider = Material.insetDivider Material.defaultPalette
, middleDividers = Material.middleDividers Material.defaultPalette , middleDividers = Material.middleDividers Material.defaultPalette
, insetTitle = Material.insetTitle Material.defaultPalette , insetHeader = Material.insetHeader Material.defaultPalette
, fullBleedTitle = Material.fullBleedTitle Material.defaultPalette , fullBleedHeader = Material.fullBleedHeader Material.defaultPalette
} }
@ -59,10 +59,10 @@ subscriptions () =
view : (Msg -> msg) -> Style style msg -> Model -> Element msg view : (Msg -> msg) -> Style style msg -> Model -> Element msg
view _ style () = view _ style () =
[ "Section 1" [ "Section 1"
|> Widget.headerItem style.fullBleedTitle |> Widget.headerItem style.fullBleedHeader
, Widget.item <| Element.text <| "A" , Widget.item <| Element.text <| "A"
, "Section 2" , "Section 2"
|> Widget.headerItem style.fullBleedTitle |> Widget.headerItem style.fullBleedHeader
, Widget.item <| Element.text <| "B" , Widget.item <| Element.text <| "B"
, Widget.divider style.middleDividers , Widget.divider style.middleDividers
, Widget.item <| Element.text <| "C" , Widget.item <| Element.text <| "C"

View File

@ -5,7 +5,7 @@ import Element exposing (Element)
import FeatherIcons import FeatherIcons
import Widget import Widget
import Widget.Icon as Icon import Widget.Icon as Icon
import Widget.Style exposing (ButtonStyle, ColumnStyle) import Widget exposing (ButtonStyle, ColumnStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -4,7 +4,7 @@ import Browser
import Element exposing (Element) import Element exposing (Element)
import Set exposing (Set) import Set exposing (Set)
import Widget import Widget
import Widget.Style exposing (ButtonStyle, RowStyle) import Widget exposing (ButtonStyle, RowStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -3,7 +3,7 @@ module Example.ProgressIndicator exposing (Model, Msg, init, subscriptions, upda
import Browser import Browser
import Element exposing (Element) import Element exposing (Element)
import Widget import Widget
import Widget.Style exposing (ProgressIndicatorStyle) import Widget exposing (ProgressIndicatorStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -3,7 +3,7 @@ module Example.Select exposing (Model, Msg, init, subscriptions, update, view)
import Browser import Browser
import Element exposing (Element) import Element exposing (Element)
import Widget import Widget
import Widget.Style exposing (ButtonStyle, RowStyle) import Widget exposing (ButtonStyle, RowStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -6,7 +6,7 @@ import FeatherIcons
import Time import Time
import Widget import Widget
import Widget.Snackbar as Snackbar exposing (Snackbar) import Widget.Snackbar as Snackbar exposing (Snackbar)
import Widget.Style exposing (ButtonStyle, ColumnStyle, RowStyle, SnackbarStyle) import Widget exposing (ButtonStyle, ColumnStyle, RowStyle, SnackbarStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -3,7 +3,7 @@ module Example.SortTable exposing (Model, Msg, init, subscriptions, update, view
import Browser import Browser
import Element exposing (Element) import Element exposing (Element)
import Widget import Widget
import Widget.Style exposing (SortTableStyle) import Widget exposing (SortTableStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -4,7 +4,7 @@ import Browser
import Element exposing (Element) import Element exposing (Element)
import FeatherIcons import FeatherIcons
import Widget import Widget
import Widget.Style exposing (RowStyle, SwitchStyle) import Widget exposing (RowStyle, SwitchStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -3,7 +3,7 @@ module Example.Tab exposing (Model, Msg, init, subscriptions, update, view)
import Browser import Browser
import Element exposing (Element) import Element exposing (Element)
import Widget import Widget
import Widget.Style exposing (TabStyle) import Widget exposing (TabStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -4,7 +4,7 @@ import Browser
import Element exposing (Element) import Element exposing (Element)
import Set exposing (Set) import Set exposing (Set)
import Widget import Widget
import Widget.Style exposing (ColumnStyle, TextInputStyle) import Widget exposing (ColumnStyle, TextInputStyle)
import Widget.Style.Material as Material import Widget.Style.Material as Material

View File

@ -1,16 +1,30 @@
module Internal.Button exposing module Internal.Button exposing (Button, ButtonStyle, TextButton, button, iconButton, textButton)
( Button
, TextButton
, button
, iconButton
, textButton
)
import Element exposing (Element) import Color exposing (Color)
import Element exposing (Attribute, Element)
import Element.Input as Input import Element.Input as Input
import Element.Region as Region import Element.Region as Region
import Widget.Icon exposing (Icon) import Html exposing (Html)
import Widget.Style exposing (ButtonStyle) import Widget.Icon exposing (Icon, IconStyle)
type alias ButtonStyle msg =
{ elementButton : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
, content :
{ elementRow : List (Attribute msg)
, content :
{ text : { contentText : List (Attribute msg) }
, icon :
{ ifDisabled : IconStyle
, ifActive : IconStyle
, otherwise : IconStyle
}
}
}
}
type alias Button msg = type alias Button msg =

View File

@ -1,10 +1,33 @@
module Internal.Dialog exposing (Dialog, dialog, modal) module Internal.Dialog exposing (Dialog, DialogStyle, dialog, modal)
import Color exposing (Color)
import Element exposing (Attribute, Element) import Element exposing (Attribute, Element)
import Element.Background as Background import Element.Background as Background
import Element.Events as Events import Element.Events as Events
import Internal.Button as Button exposing (TextButton) import Html exposing (Html)
import Widget.Style exposing (DialogStyle) import Internal.Button as Button exposing (ButtonStyle, TextButton)
import Widget.Icon exposing (Icon)
{-| -}
type alias DialogStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ title :
{ contentText : List (Attribute msg)
}
, text :
{ contentText : List (Attribute msg)
}
, buttons :
{ elementRow : List (Attribute msg)
, content :
{ accept : ButtonStyle msg
, dismiss : ButtonStyle msg
}
}
}
}
type alias Dialog msg = type alias Dialog msg =

View File

@ -1,10 +1,40 @@
module Internal.ExpansionPanel exposing (ExpansionPanel, expansionPanel, expansionPanelItem) module Internal.ExpansionPanel exposing (ExpansionPanel, ExpansionPanelStyle, expansionPanel, expansionPanelItem)
import Element exposing (Element) import Element exposing (Attribute, Element)
import Element.Events as Events import Element.Events as Events
import Internal.List as List exposing (Item) import Internal.List as List exposing (Item, ItemStyle)
import Widget.Icon exposing (Icon) import Widget.Icon exposing (Icon, IconStyle)
import Widget.Style exposing (ExpansionPanelStyle, ItemStyle)
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias ExpansionPanelStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ panel :
{ elementRow : List (Attribute msg)
, content :
{ label :
{ elementRow : List (Attribute msg)
, content :
{ icon : IconStyle
, text : { elementText : List (Attribute msg) }
}
}
, expandIcon : Icon
, collapseIcon : Icon
, icon : IconStyle
}
}
, content :
{ element : List (Attribute msg)
}
}
}
type alias ExpansionPanel msg = type alias ExpansionPanel msg =

View File

@ -0,0 +1,18 @@
module Internal.ItemButton exposing (ItemButton, iconButton)
import Element exposing (Element)
import Element.Input as Input
import Element.Region as Region
import Widget.Icon exposing (Icon)
type alias ItemButton msg =
{ text : String
, onPress : Maybe msg
, icon : Icon
, content : Element msg
}
iconButton style { onPress, text, icon } =
Debug.todo "implement iconButton"

View File

@ -1,12 +1,60 @@
module Internal.List exposing (Item, buttonColumn, buttonRow, column, divider, headerItem, item, itemList, row, toItem) module Internal.List exposing (ColumnStyle, DividerStyle, Item, ItemStyle, RowStyle, HeaderStyle, buttonColumn, buttonRow, column, divider, headerItem, item, itemList, row, toItem)
import Element exposing (Attribute, Element) import Element exposing (Attribute, Element)
import Internal.Button exposing (Button) import Internal.Button exposing (Button, ButtonStyle)
import Internal.Select as Select import Internal.Select as Select
import Widget.Style exposing (ButtonStyle, ColumnStyle, DividerStyle, ItemStyle, RowStyle, TitleStyle)
import Widget.Style.Customize as Customize exposing (content) import Widget.Style.Customize as Customize exposing (content)
{-| -}
type alias ItemStyle content =
{ element : List (Attribute Never)
, content : content
}
{-| -}
type alias DividerStyle msg =
{ element : List (Attribute msg)
}
{-| -}
type alias HeaderStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ divider : DividerStyle msg
, title : List (Attribute msg)
}
}
{-| -}
type alias RowStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ element : List (Attribute Never)
, ifFirst : List (Attribute Never)
, ifLast : List (Attribute Never)
, ifSingleton : List (Attribute Never)
, otherwise : List (Attribute Never)
}
}
{-| -}
type alias ColumnStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ element : List (Attribute Never)
, ifFirst : List (Attribute Never)
, ifLast : List (Attribute Never)
, ifSingleton : List (Attribute Never)
, otherwise : List (Attribute Never)
}
}
type alias Item msg = type alias Item msg =
List (Attribute msg) -> Element msg List (Attribute msg) -> Element msg
@ -25,7 +73,7 @@ divider style =
toItem style (\{ element } -> Element.none |> Element.el element) toItem style (\{ element } -> Element.none |> Element.el element)
headerItem : ItemStyle (TitleStyle msg) -> String -> Item msg headerItem : ItemStyle (HeaderStyle msg) -> String -> Item msg
headerItem style title = headerItem style title =
toItem style toItem style
(\{ elementColumn, content } -> (\{ elementColumn, content } ->

View File

@ -5,11 +5,8 @@ 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
import Html.Attributes as Attributes import Html.Attributes as Attributes
import Internal.Button exposing (ButtonStyle)
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style
exposing
( ButtonStyle
)
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor
import Widget.Style.Material.Typography as Typography import Widget.Style.Material.Typography as Typography

View File

@ -4,12 +4,9 @@ import Element
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
import Internal.Button exposing (ButtonStyle)
import Internal.Material.Button as Button import Internal.Material.Button as Button
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style
exposing
( ButtonStyle
)
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor

View File

@ -3,12 +3,9 @@ module Internal.Material.Dialog exposing (alertDialog)
import Element import Element
import Element.Background as Background import Element.Background as Background
import Element.Border as Border import Element.Border as Border
import Internal.Dialog exposing (DialogStyle)
import Internal.Material.Button as Button import Internal.Material.Button as Button
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style
exposing
( DialogStyle
)
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor
import Widget.Style.Material.Typography as Typography import Widget.Style.Material.Typography as Typography

View File

@ -8,16 +8,13 @@ module Internal.Material.ExpansionPanel exposing
import Color import Color
import Element import Element
import Element.Background as Background import Element.Background as Background
import Internal.ExpansionPanel exposing (ExpansionPanelStyle)
import Internal.List exposing (ItemStyle)
import Internal.Material.Icon as Icon import Internal.Material.Icon as Icon
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Svg import Svg
import Svg.Attributes import Svg.Attributes
import Widget.Icon as Icon exposing (Icon) import Widget.Icon as Icon exposing (Icon)
import Widget.Style
exposing
( ExpansionPanelStyle
, ItemStyle
)
import Widget.Style.Customize as Customize import Widget.Style.Customize as Customize
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor

View File

@ -5,6 +5,7 @@ import Element
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
import Internal.Button exposing (ButtonStyle)
import Internal.Material.Button as Button import Internal.Material.Button as Button
import Internal.Material.Icon as Icon import Internal.Material.Icon as Icon
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
@ -13,11 +14,7 @@ import Internal.Material.TextInput as TextInput
import Svg import Svg
import Svg.Attributes import Svg.Attributes
import Widget.Icon as Icon exposing (Icon) import Widget.Icon as Icon exposing (Icon)
import Widget.Style import Widget.Layout exposing (LayoutStyle)
exposing
( ButtonStyle
, LayoutStyle
)
import Widget.Style.Customize as Customize import Widget.Style.Customize as Customize
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor
import Widget.Style.Material.Typography as Typography import Widget.Style.Material.Typography as Typography

View File

@ -3,9 +3,9 @@ module Internal.Material.List exposing
, cardColumn , cardColumn
, column , column
, fullBleedDivider , fullBleedDivider
, fullBleedTitle , fullBleedHeader
, insetDivider , insetDivider
, insetTitle , insetHeader
, middleDividers , middleDividers
, row , row
) )
@ -15,15 +15,15 @@ import Element
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
import Internal.Material.Palette exposing (Palette) import Internal.List
import Widget.Style
exposing exposing
( ColumnStyle ( ColumnStyle
, DividerStyle , DividerStyle
, ItemStyle , ItemStyle
, RowStyle , RowStyle
, TitleStyle , HeaderStyle
) )
import Internal.Material.Palette exposing (Palette)
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor
import Widget.Style.Material.Typography as Typography import Widget.Style.Material.Typography as Typography
@ -145,8 +145,8 @@ middleDividers _ =
} }
insetTitle : Palette -> ItemStyle (TitleStyle msg) insetHeader : Palette -> ItemStyle (HeaderStyle msg)
insetTitle palette = insetHeader palette =
{ element = { element =
[ Element.width <| Element.fill [ Element.width <| Element.fill
, Border.widthEach , Border.widthEach
@ -182,8 +182,8 @@ insetTitle palette =
} }
fullBleedTitle : Palette -> ItemStyle (TitleStyle msg) fullBleedHeader : Palette -> ItemStyle (HeaderStyle msg)
fullBleedTitle palette = fullBleedHeader palette =
{ element = { element =
[ Element.width <| Element.fill [ Element.width <| Element.fill
, Element.padding 0 , Element.padding 0

View File

@ -3,12 +3,9 @@ module Internal.Material.ProgressIndicator exposing (determinateCircularIcon, in
import Color import Color
import Element exposing (Attribute, Element) import Element exposing (Attribute, Element)
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Internal.ProgressIndicator exposing (ProgressIndicatorStyle)
import Svg import Svg
import Svg.Attributes import Svg.Attributes
import Widget.Style
exposing
( ProgressIndicatorStyle
)
indeterminateCircularIcon : Color.Color -> List (Attribute msg) -> Element msg indeterminateCircularIcon : Color.Color -> List (Attribute msg) -> Element msg

View File

@ -6,10 +6,7 @@ import Element.Border as Border
import Element.Font as Font import Element.Font as Font
import Internal.Material.Button as Button import Internal.Material.Button as Button
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style import Widget.Snackbar exposing (SnackbarStyle)
exposing
( SnackbarStyle
)
import Widget.Style.Customize as Customize import Widget.Style.Customize as Customize
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor

View File

@ -0,0 +1,27 @@
module Internal.Material.SortTable exposing ( sortTable)
import Color
import Element
import Element.Background as Background
import Internal.Material.ExpansionPanel as ExpansionPanel
import Internal.SortTable exposing (SortTableStyle )
import Internal.List exposing (ItemStyle)
import Internal.Material.Icon as Icon
import Internal.Material.Palette exposing (Palette)
import Internal.Material.Button as Button
import Svg
import Svg.Attributes
import Widget.Icon as Icon exposing (Icon)
import Widget.Style.Customize as Customize
import Widget.Style.Material.Color as MaterialColor
sortTable : Palette -> SortTableStyle msg
sortTable palette =
{ elementTable = []
, content =
{ header = Button.textButton palette
, ascIcon = ExpansionPanel.expand_less
, descIcon = ExpansionPanel.expand_more
, defaultIcon = always Element.none
}
}

View File

@ -6,10 +6,7 @@ import Element.Background as Background
import Element.Border as Border import Element.Border as Border
import Html.Attributes as Attributes import Html.Attributes as Attributes
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style import Internal.Switch exposing (SwitchStyle)
exposing
( SwitchStyle
)
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor

View File

@ -4,13 +4,10 @@ import Element
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
import Internal.Button exposing (ButtonStyle)
import Internal.Material.Button as Button import Internal.Material.Button as Button
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style import Internal.Tab exposing (TabStyle)
exposing
( ButtonStyle
, TabStyle
)
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor
import Widget.Style.Material.Typography as Typography import Widget.Style.Material.Typography as Typography

View File

@ -4,10 +4,7 @@ import Element
import Element.Border as Border import Element.Border as Border
import Internal.Material.Chip as Chip import Internal.Material.Chip as Chip
import Internal.Material.Palette exposing (Palette) import Internal.Material.Palette exposing (Palette)
import Widget.Style import Internal.TextInput exposing (TextInputStyle)
exposing
( TextInputStyle
)
import Widget.Style.Customize as Customize import Widget.Style.Customize as Customize
import Widget.Style.Material.Color as MaterialColor import Widget.Style.Material.Color as MaterialColor

View File

@ -1,7 +1,12 @@
module Internal.ProgressIndicator exposing (circularProgressIndicator) module Internal.ProgressIndicator exposing (ProgressIndicatorStyle, circularProgressIndicator)
import Element exposing (Element) import Element exposing (Element)
import Widget.Style exposing (ProgressIndicatorStyle)
{-| -}
type alias ProgressIndicatorStyle msg =
{ elementFunction : Maybe Float -> Element msg
}
circularProgressIndicator : circularProgressIndicator :

View File

@ -2,10 +2,9 @@ module Internal.Select exposing (MultiSelect, Select, multiSelect, select, selec
import Element exposing (Element) import Element exposing (Element)
import Element.Input as Input import Element.Input as Input
import Internal.Button exposing (Button) import Internal.Button exposing (Button, ButtonStyle)
import Set exposing (Set) import Set exposing (Set)
import Widget.Icon exposing (Icon) import Widget.Icon exposing (Icon)
import Widget.Style exposing (ButtonStyle)
type alias Select msg = type alias Select msg =

View File

@ -2,6 +2,7 @@ module Internal.SortTable exposing
( Column ( Column
, ColumnType , ColumnType
, SortTable , SortTable
, SortTableStyle
, floatColumn , floatColumn
, intColumn , intColumn
, sortTable , sortTable
@ -9,9 +10,28 @@ module Internal.SortTable exposing
, unsortableColumn , unsortableColumn
) )
import Element exposing (Element, Length) import Color exposing (Color)
import Internal.Button as Button import Element exposing (Attribute, Element, Length)
import Widget.Style exposing (SortTableStyle) import Html exposing (Html)
import Internal.Button as Button exposing (ButtonStyle)
import Widget.Icon exposing (Icon)
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias SortTableStyle msg =
{ elementTable : List (Attribute msg)
, content :
{ header : ButtonStyle msg
, ascIcon : Icon
, descIcon : Icon
, defaultIcon : Icon
}
}
{-| A Sortable list allows you to sort coulmn. {-| A Sortable list allows you to sort coulmn.

View File

@ -1,9 +1,35 @@
module Internal.Switch exposing (Switch, switch) module Internal.Switch exposing (Switch, SwitchStyle, switch)
import Element exposing (Element) import Color exposing (Color)
import Element exposing (Attribute, Element)
import Element.Input as Input import Element.Input as Input
import Element.Region as Region import Element.Region as Region
import Widget.Style exposing (SwitchStyle) import Html exposing (Html)
import Widget.Icon exposing (Icon)
{-| -}
type alias SwitchStyle msg =
{ elementButton : List (Attribute msg)
, content :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
}
, contentInFront :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
, content :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
}
}
}
type alias Switch msg = type alias Switch msg =

View File

@ -1,8 +1,24 @@
module Internal.Tab exposing (Tab, tab) module Internal.Tab exposing (Tab, TabStyle, tab)
import Element exposing (Element) import Color exposing (Color)
import Element exposing (Attribute, Element)
import Html exposing (Html)
import Internal.Button exposing (ButtonStyle)
import Internal.Select as Select exposing (Select) import Internal.Select as Select exposing (Select)
import Widget.Style exposing (TabStyle) import Widget.Icon exposing (Icon)
{-| -}
type alias TabStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ tabs :
{ elementRow : List (Attribute msg)
, content : ButtonStyle msg
}
, content : List (Attribute msg)
}
}
type alias Tab msg = type alias Tab msg =

View File

@ -1,9 +1,23 @@
module Internal.TextInput exposing (TextInput, textInput) module Internal.TextInput exposing (TextInput, TextInputStyle, textInput)
import Element exposing (Element) import Element exposing (Attribute, Element)
import Element.Input as Input exposing (Placeholder) import Element.Input as Input exposing (Placeholder)
import Internal.Button as Button exposing (Button) import Internal.Button as Button exposing (Button, ButtonStyle)
import Widget.Style exposing (TextInputStyle)
{-| -}
type alias TextInputStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ chips :
{ elementRow : List (Attribute msg)
, content : ButtonStyle msg
}
, text :
{ elementTextInput : List (Attribute msg)
}
}
}
type alias TextInput msg = type alias TextInput msg =

View File

@ -1,16 +1,16 @@
module Widget exposing module Widget exposing
( Button, TextButton, iconButton, textButton, button ( ButtonStyle, Button, TextButton, iconButton, textButton, button
, Switch, switch , SwitchStyle,Switch, switch
, Select, selectButton, select , Select, selectButton, select
, MultiSelect, multiSelect , MultiSelect, multiSelect
, Dialog, modal, dialog , DialogStyle, Dialog, modal, dialog
, ExpansionPanel, expansionPanel, expansionPanelItem , ExpansionPanelStyle, ExpansionPanel, expansionPanel, expansionPanelItem
, row, column, Item, itemList, item, divider, buttonRow, buttonColumn , ItemStyle, DividerStyle, HeaderStyle, RowStyle, ColumnStyle, row, column, Item, itemList, item, divider, buttonRow, buttonColumn
, SortTable, Column, sortTable, floatColumn, intColumn, stringColumn, unsortableColumn , SortTableStyle, SortTable, Column, sortTable, floatColumn, intColumn, stringColumn, unsortableColumn
, TextInput, textInput , TextInputStyle,TextInput, textInput
, Tab, tab , TabStyle,Tab, tab
, ProgressIndicator, circularProgressIndicator , ProgressIndicatorStyle,ProgressIndicator, circularProgressIndicator
, buttonSheet, headerItem , headerItem
) )
{-| This module contains different stateless view functions. No wiring required. {-| This module contains different stateless view functions. No wiring required.
@ -44,12 +44,12 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5QGZ3hgPLa1) [Open in Ellie](https://ellie-app.com/9p5QGZ3hgPLa1)
@docs Button, TextButton, iconButton, textButton, button @docs ButtonStyle, Button, TextButton, iconButton, textButton, button
# Switch # Switch
@docs Switch, switch @docs SwitchStyle, Switch, switch
# Select # Select
@ -73,7 +73,7 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5Rdz625TZa1) [Open in Ellie](https://ellie-app.com/9p5Rdz625TZa1)
@docs Dialog, modal, dialog @docs DialogStyle, Dialog, modal, dialog
# Expansion Panel # Expansion Panel
@ -82,7 +82,7 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5Rv5jfVdFa1) [Open in Ellie](https://ellie-app.com/9p5Rv5jfVdFa1)
@docs ExpansionPanel, expansionPanel, expansionPanelItem @docs ExpansionPanelStyle, ExpansionPanel, expansionPanel, expansionPanelItem
# List # List
@ -91,7 +91,16 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5RJnDVVCKa1) [Open in Ellie](https://ellie-app.com/9p5RJnDVVCKa1)
@docs row, column, Item, itemList, item, divider, buttonRow, buttonColumn, buttonDrawer ## Row
@docs RowStyle, row, buttonRow
## Column
@docs ColumnStyle, column, buttonColumn
## Item
@docs ItemStyle, DividerStyle, HeaderStyle, Item,itemList, item, divider, headerItem, buttonDrawer
# Sort Table # Sort Table
@ -100,7 +109,7 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5RXw44B4Ja1) [Open in Ellie](https://ellie-app.com/9p5RXw44B4Ja1)
@docs SortTable, Column, sortTable, floatColumn, intColumn, stringColumn, unsortableColumn @docs SortTableStyle, SortTable, Column, sortTable, floatColumn, intColumn, stringColumn, unsortableColumn
# Text Input # Text Input
@ -109,7 +118,7 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5S6cvWCmBa1) [Open in Ellie](https://ellie-app.com/9p5S6cvWCmBa1)
@docs TextInput, textInput @docs TextInputStyle, TextInput, textInput
# Tab # Tab
@ -118,7 +127,7 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/9p5Sdbvp4jZa1) [Open in Ellie](https://ellie-app.com/9p5Sdbvp4jZa1)
@docs Tab, tab @docs TabStyle, Tab, tab
# Progress Indicator # Progress Indicator
@ -127,13 +136,14 @@ You can create you own widgets by sticking widgets types together.
[Open in Ellie](https://ellie-app.com/c47GJktH2bqa1) [Open in Ellie](https://ellie-app.com/c47GJktH2bqa1)
@docs ProgressIndicator, circularProgressIndicator @docs ProgressIndicatorStyle,ProgressIndicator, circularProgressIndicator
-} -}
import Color exposing (Color) import Color exposing (Color)
import Element exposing (Attribute, Element, Length) import Element exposing (Attribute, Element, Length)
import Element.Input exposing (Placeholder) import Element.Input exposing (Placeholder)
import Html exposing (Html)
import Internal.Button as Button import Internal.Button as Button
import Internal.Dialog as Dialog import Internal.Dialog as Dialog
import Internal.ExpansionPanel as ExpansionPanel import Internal.ExpansionPanel as ExpansionPanel
@ -145,23 +155,7 @@ import Internal.Switch as Switch
import Internal.Tab as Tab import Internal.Tab as Tab
import Internal.TextInput as TextInput import Internal.TextInput as TextInput
import Set exposing (Set) import Set exposing (Set)
import Widget.Style import Widget.Icon exposing (Icon)
exposing
( ButtonSheetStyle
, ButtonStyle
, ColumnStyle
, DialogStyle
, DividerStyle
, ExpansionPanelStyle
, ItemStyle
, ProgressIndicatorStyle
, RowStyle
, SortTableStyle
, SwitchStyle
, TabStyle
, TextInputStyle
, TitleStyle
)
@ -170,6 +164,13 @@ import Widget.Style
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias IconStyle =
{ size : Int
, color : Color
}
type alias Icon = type alias Icon =
{ size : Int { size : Int
, color : Color , color : Color
@ -183,6 +184,26 @@ type alias Icon =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias ButtonStyle msg =
{ elementButton : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
, content :
{ elementRow : List (Attribute msg)
, content :
{ text : { contentText : List (Attribute msg) }
, icon :
{ ifDisabled : IconStyle
, ifActive : IconStyle
, otherwise : IconStyle
}
}
}
}
{-| Button widget type {-| Button widget type
-} -}
type alias Button msg = type alias Button msg =
@ -266,6 +287,30 @@ button =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias SwitchStyle msg =
{ elementButton : List (Attribute msg)
, content :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
}
, contentInFront :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
, content :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
}
}
}
{-| Switch widget type {-| Switch widget type
-} -}
type alias Switch msg = type alias Switch msg =
@ -370,6 +415,27 @@ multiSelect =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias DialogStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ title :
{ contentText : List (Attribute msg)
}
, text :
{ contentText : List (Attribute msg)
}
, buttons :
{ elementRow : List (Attribute msg)
, content :
{ accept : ButtonStyle msg
, dismiss : ButtonStyle msg
}
}
}
}
{-| Dialog widget type {-| Dialog widget type
-} -}
type alias Dialog msg = type alias Dialog msg =
@ -418,6 +484,37 @@ dialog =
----------------------------------------------------------} ----------------------------------------------------------}
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias ExpansionPanelStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ panel :
{ elementRow : List (Attribute msg)
, content :
{ label :
{ elementRow : List (Attribute msg)
, content :
{ icon : IconStyle
, text : { elementText : List (Attribute msg) }
}
}
, expandIcon : Icon
, collapseIcon : Icon
, icon : IconStyle
}
}
, content :
{ element : List (Attribute msg)
}
}
}
{-| Expansion Panel widget type {-| Expansion Panel widget type
-} -}
type alias ExpansionPanel msg = type alias ExpansionPanel msg =
@ -477,6 +574,21 @@ expansionPanelItem =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias TextInputStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ chips :
{ elementRow : List (Attribute msg)
, content : ButtonStyle msg
}
, text :
{ elementTextInput : List (Attribute msg)
}
}
}
{-| Text Input widget type {-| Text Input widget type
-} -}
type alias TextInput msg = type alias TextInput msg =
@ -515,6 +627,55 @@ textInput =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias ItemStyle content =
{ element : List (Attribute Never)
, content : content
}
{-| -}
type alias DividerStyle msg =
{ element : List (Attribute msg)
}
{-| -}
type alias HeaderStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ divider : DividerStyle msg
, title : List (Attribute msg)
}
}
{-| -}
type alias RowStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ element : List (Attribute Never)
, ifFirst : List (Attribute Never)
, ifLast : List (Attribute Never)
, ifSingleton : List (Attribute Never)
, otherwise : List (Attribute Never)
}
}
{-| -}
type alias ColumnStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ element : List (Attribute Never)
, ifFirst : List (Attribute Never)
, ifLast : List (Attribute Never)
, ifSingleton : List (Attribute Never)
, otherwise : List (Attribute Never)
}
}
{-| Item widget type. {-| Item widget type.
Use `Widget.item` if you want to turn a simple element into an item. Use `Widget.item` if you want to turn a simple element into an item.
@ -540,7 +701,7 @@ divider =
{-| A header for a part of a list. {-| A header for a part of a list.
-} -}
headerItem : ItemStyle (TitleStyle msg) -> String -> Item msg headerItem : ItemStyle (HeaderStyle msg) -> String -> Item msg
headerItem = headerItem =
List.headerItem List.headerItem
@ -605,27 +766,29 @@ buttonColumn =
List.buttonColumn List.buttonColumn
{-| A side sheet containing only buttons. Will use the full hight.
-}
buttonSheet :
ButtonSheetStyle msg
-> List (Button msg)
-> Element msg
buttonSheet style actions =
actions
|> List.map (button style.content.content)
|> Element.column
(style.content.elementColumn ++ [ Element.width <| Element.fill ])
|> Element.el
(style.element ++ [ Element.height <| Element.fill ])
{---------------------------------------------------------- {----------------------------------------------------------
- SORT TABLE - SORT TABLE
----------------------------------------------------------} ----------------------------------------------------------}
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias SortTableStyle msg =
{ elementTable : List (Attribute msg)
, content :
{ header : ButtonStyle msg
, ascIcon : Icon
, descIcon : Icon
, defaultIcon : Icon
}
}
{-| Column for the Sort Table widget type {-| Column for the Sort Table widget type
-} -}
type alias Column a = type alias Column a =
@ -728,6 +891,19 @@ sortTable =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias TabStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ tabs :
{ elementRow : List (Attribute msg)
, content : ButtonStyle msg
}
, content : List (Attribute msg)
}
}
{-| Tab widget type {-| Tab widget type
-} -}
type alias Tab msg = type alias Tab msg =
@ -760,6 +936,12 @@ tab =
----------------------------------------------------------} ----------------------------------------------------------}
{-| -}
type alias ProgressIndicatorStyle msg =
{ elementFunction : Maybe Float -> Element msg
}
{-| Progress Indicator widget type {-| Progress Indicator widget type
If `maybeProgress` is set to `Nothing`, an indeterminate progress indicator (e.g. spinner) will display. If `maybeProgress` is set to `Nothing`, an indeterminate progress indicator (e.g. spinner) will display.

View File

@ -1,4 +1,4 @@
module Widget.Icon exposing (Icon, antDesignIconsElm, elmFeather, elmFontawesome, elmHeroicons, elmIonicons, elmMaterialIcons, elmOcticons, elmZondicons, materialIcons) module Widget.Icon exposing (Icon, IconStyle, antDesignIconsElm, elmFeather, elmFontawesome, elmHeroicons, elmIonicons, elmMaterialIcons, elmOcticons, elmZondicons, materialIcons)
import Color exposing (Color) import Color exposing (Color)
import Dict exposing (size) import Dict exposing (size)
@ -8,6 +8,12 @@ import Svg exposing (Svg)
import Svg.Attributes import Svg.Attributes
type alias IconStyle =
{ size : Int
, color : Color
}
type alias Icon = type alias Icon =
{ size : Int { size : Int
, color : Color , color : Color

View File

@ -1,6 +1,7 @@
module Widget.Layout exposing module Widget.Layout exposing
( Layout, Part(..), init, timePassed, view ( Layout, Part(..), init, timePassed, view
, activate, queueMessage , activate, queueMessage
, LayoutStyle, buttonSheet
) )
{-| Combines multiple concepts from the [material design specification](https://material.io/components/), namely: {-| Combines multiple concepts from the [material design specification](https://material.io/components/), namely:
@ -26,15 +27,69 @@ It is responsive and changes view to apply to the [material design guidelines](h
-} -}
import Array import Array
import Color exposing (Color)
import Element exposing (Attribute, DeviceClass(..), Element) import Element exposing (Attribute, DeviceClass(..), Element)
import Element.Input as Input import Element.Input as Input
import Html exposing (Html) import Html exposing (Html)
import Widget exposing (Button, Select, TextInput) import Internal.Button as Button exposing (Button, ButtonStyle)
import Widget.Snackbar as Snackbar exposing (Message) import Internal.Dialog as Dialog
import Widget.Style exposing (LayoutStyle) import Internal.Select as Select exposing (Select)
import Internal.TextInput as TextInput exposing (TextInput, TextInputStyle)
import Widget.Icon exposing (Icon, IconStyle)
import Widget.Snackbar as Snackbar exposing (Message, SnackbarStyle)
import Widget.Style.Customize as Customize import Widget.Style.Customize as Customize
{-| -}
type alias ButtonSheetStyle msg =
{ element : List (Attribute msg)
, content :
{ elementColumn : List (Attribute msg)
, content : ButtonStyle msg
}
}
{-| A side sheet containing only buttons. Will use the full hight.
-}
buttonSheet :
ButtonSheetStyle msg
-> List (Button msg)
-> Element msg
buttonSheet style actions =
actions
|> List.map (Button.button style.content.content)
|> Element.column
(style.content.elementColumn ++ [ Element.width <| Element.fill ])
|> Element.el
(style.element ++ [ Element.height <| Element.fill ])
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias LayoutStyle msg =
{ container : List (Attribute msg)
, snackbar : SnackbarStyle msg
, layout : List (Attribute msg) -> Element msg -> Html msg
, header : List (Attribute msg)
, sheet : List (Attribute msg)
, sheetButton : ButtonStyle msg
, menuButton : ButtonStyle msg
, menuTabButton : ButtonStyle msg
, menuIcon : Icon
, moreVerticalIcon : Icon
, spacing : Int
, title : List (Attribute msg)
, searchIcon : Icon
, search : TextInputStyle msg
, searchFill : TextInputStyle msg
}
{-| The currently visible part: either the left sheet, right sheet or the search bar {-| The currently visible part: either the left sheet, right sheet or the search bar
-} -}
type Part type Part
@ -156,7 +211,7 @@ viewNav style { title, menu, deviceClass, onChangedSidebar, primaryActions, more
|| (deviceClass == Tablet) || (deviceClass == Tablet)
|| ((menu.options |> List.length) > 5) || ((menu.options |> List.length) > 5)
then then
[ Widget.iconButton style.menuButton [ Button.iconButton style.menuButton
{ onPress = Just <| onChangedSidebar <| Just LeftSheet { onPress = Just <| onChangedSidebar <| Just LeftSheet
, icon = style.menuIcon , icon = style.menuIcon
, text = "Menu" , text = "Menu"
@ -176,8 +231,8 @@ viewNav style { title, menu, deviceClass, onChangedSidebar, primaryActions, more
else else
[ title |> Element.el style.title [ title |> Element.el style.title
, menu , menu
|> Widget.select |> Select.select
|> List.map (Widget.selectButton style.menuTabButton) |> List.map (Select.selectButton style.menuTabButton)
|> Element.row |> Element.row
[ Element.width <| Element.shrink [ Element.width <| Element.shrink
] ]
@ -194,7 +249,7 @@ viewNav style { title, menu, deviceClass, onChangedSidebar, primaryActions, more
search search
|> Maybe.map |> Maybe.map
(\{ onChange, text, label } -> (\{ onChange, text, label } ->
Widget.textInput style.search TextInput.textInput style.search
{ chips = [] { chips = []
, onChange = onChange , onChange = onChange
, text = text , text = text
@ -210,7 +265,7 @@ viewNav style { title, menu, deviceClass, onChangedSidebar, primaryActions, more
|> Maybe.map |> Maybe.map
(\{ label } -> (\{ label } ->
if deviceClass == Tablet then if deviceClass == Tablet then
[ Widget.button style.menuButton [ Button.button style.menuButton
{ onPress = Just <| onChangedSidebar <| Just Search { onPress = Just <| onChangedSidebar <| Just Search
, icon = style.searchIcon , icon = style.searchIcon
, text = label , text = label
@ -218,7 +273,7 @@ viewNav style { title, menu, deviceClass, onChangedSidebar, primaryActions, more
] ]
else if deviceClass == Phone then else if deviceClass == Phone then
[ Widget.iconButton style.menuButton [ Button.iconButton style.menuButton
{ onPress = Just <| onChangedSidebar <| Just Search { onPress = Just <| onChangedSidebar <| Just Search
, icon = style.searchIcon , icon = style.searchIcon
, text = label , text = label
@ -232,16 +287,16 @@ viewNav style { title, menu, deviceClass, onChangedSidebar, primaryActions, more
, primaryActions , primaryActions
|> List.map |> List.map
(if deviceClass == Phone then (if deviceClass == Phone then
Widget.iconButton style.menuButton Button.iconButton style.menuButton
else else
Widget.button style.menuButton Button.button style.menuButton
) )
, if moreActions |> List.isEmpty then , if moreActions |> List.isEmpty then
[] []
else else
[ Widget.iconButton style.menuButton [ Button.iconButton style.menuButton
{ onPress = Just <| onChangedSidebar <| Just RightSheet { onPress = Just <| onChangedSidebar <| Just RightSheet
, icon = style.moreVerticalIcon , icon = style.moreVerticalIcon
, text = "More" , text = "More"
@ -278,9 +333,9 @@ viewLeftSheet style { title, menu } =
[ [ title [ [ title
] ]
, menu , menu
|> Widget.select |> Select.select
|> List.map |> List.map
(Widget.selectButton style.sheetButton) (Select.selectButton style.sheetButton)
] ]
|> List.concat |> List.concat
|> Element.column [ Element.width <| Element.fill ] |> Element.column [ Element.width <| Element.fill ]
@ -351,7 +406,7 @@ view style { search, title, onChangedSidebar, menu, actions, window, dialog, lay
} }
Just RightSheet -> Just RightSheet ->
Widget.buttonSheet buttonSheet
{ element = style.sheet ++ [ Element.alignRight ] { element = style.sheet ++ [ Element.alignRight ]
, content = , content =
{ elementColumn = [] { elementColumn = []
@ -363,7 +418,7 @@ view style { search, title, onChangedSidebar, menu, actions, window, dialog, lay
Just Search -> Just Search ->
search search
|> Maybe.map |> Maybe.map
(Widget.textInput (TextInput.textInput
(style.searchFill (style.searchFill
|> Customize.mapContent |> Customize.mapContent
(\record -> (\record ->
@ -400,7 +455,7 @@ view style { search, title, onChangedSidebar, menu, actions, window, dialog, lay
dialogConfig dialogConfig
Nothing -> Nothing ->
Widget.modal Dialog.modal
{ onDismiss = { onDismiss =
Nothing Nothing
|> onChangedSidebar |> onChangedSidebar

View File

@ -20,6 +20,7 @@ the page. Clicking on a navigation button will scroll directly to that section.
import Browser.Dom as Dom import Browser.Dom as Dom
import Element exposing (Element) import Element exposing (Element)
import Html
import Html.Attributes as Attributes import Html.Attributes as Attributes
import IntDict exposing (IntDict) import IntDict exposing (IntDict)
import Task exposing (Task) import Task exposing (Task)
@ -120,6 +121,16 @@ This functions should be called regularly if the height of elements on your page
-} -}
syncPositions : ScrollingNav section -> Task Dom.Error (ScrollingNav section -> ScrollingNav section) syncPositions : ScrollingNav section -> Task Dom.Error (ScrollingNav section -> ScrollingNav section)
syncPositions { toString, arrangement } = syncPositions { toString, arrangement } =
let
fun : ( Int, section ) -> ScrollingNav section -> ScrollingNav section
fun ( pos, label ) model =
{ model
| positions =
model.positions
|> IntDict.insert pos
(label |> model.toString)
}
in
arrangement arrangement
|> List.map |> List.map
(\label -> (\label ->
@ -135,16 +146,7 @@ syncPositions { toString, arrangement } =
|> Task.map |> Task.map
(\list m -> (\list m ->
list list
|> List.foldl |> List.foldl fun m
(\( pos, label ) model ->
{ model
| positions =
model.positions
|> IntDict.insert pos
(label |> model.toString)
}
)
m
) )

View File

@ -1,6 +1,7 @@
module Widget.Snackbar exposing module Widget.Snackbar exposing
( Snackbar, Message, init, current, timePassed, view ( Snackbar, Message, init, current, timePassed, view
, insert, insertFor, dismiss , insert, insertFor, dismiss
, SnackbarStyle
) )
{-| ![Snackbar](https://orasund.github.io/elm-ui-widgets/assets/snackbar.png) {-| ![Snackbar](https://orasund.github.io/elm-ui-widgets/assets/snackbar.png)
@ -21,10 +22,21 @@ A [snackbar](https://material.io/components/snackbars/) shows notification, one
-} -}
import Element exposing (Element) import Element exposing (Attribute, Element)
import Internal.Button as Button exposing (ButtonStyle, TextButton)
import Queue exposing (Queue) import Queue exposing (Queue)
import Widget exposing (TextButton)
import Widget.Style exposing (SnackbarStyle)
{-| -}
type alias SnackbarStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ text :
{ elementText : List (Attribute msg)
}
, button : ButtonStyle msg
}
}
{-| A message with maybe some action button {-| A message with maybe some action button
@ -128,7 +140,7 @@ view style toMessage model =
|> Element.paragraph style.content.text.elementText |> Element.paragraph style.content.text.elementText
, button , button
|> Maybe.map |> Maybe.map
(Widget.textButton style.content.button) (Button.textButton style.content.button)
|> Maybe.withDefault Element.none |> Maybe.withDefault Element.none
] ]
|> Element.row style.elementRow |> Element.row style.elementRow

View File

@ -1,332 +0,0 @@
module Widget.Style exposing
( IconStyle
, ButtonStyle
, SwitchStyle
, DialogStyle
, ExpansionPanelStyle
, ColumnStyle, RowStyle, ItemStyle, TitleStyle, DividerStyle
, SortTableStyle
, TextInputStyle
, TabStyle
, ProgressIndicatorStyle
, SnackbarStyle
, LayoutStyle, ButtonSheetStyle
)
{-| This module contains style types for every widget.
# Icon
@docs IconStyle
# Buttons
@docs ButtonStyle
# Switch
@docs SwitchStyle
# Dialog
@docs DialogStyle
# Expansion Panel
@docs ExpansionPanelStyle
# List
@docs ColumnStyle, RowStyle, ItemStyle, TitleStyle, DividerStyle
# Sort Table
@docs SortTableStyle
# Text Input
@docs TextInputStyle
# Tab
@docs TabStyle
# Progressbar
@docs ProgressIndicatorStyle
# Snackbar
@docs SnackbarStyle
# Layout
@docs LayoutStyle, ButtonSheetStyle
-}
import Color exposing (Color)
import Element exposing (Attribute, Element)
import Html exposing (Html)
import Widget.Icon exposing (Icon)
type alias IconStyle =
{ size : Int
, color : Color
}
{-| -}
type alias SwitchStyle msg =
{ elementButton : List (Attribute msg)
, content :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
}
, contentInFront :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
, content :
{ element : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
}
}
}
{-| -}
type alias ButtonStyle msg =
{ elementButton : List (Attribute msg)
, ifDisabled : List (Attribute msg)
, ifActive : List (Attribute msg)
, otherwise : List (Attribute msg)
, content :
{ elementRow : List (Attribute msg)
, content :
{ text : { contentText : List (Attribute msg) }
, icon :
{ ifDisabled : IconStyle
, ifActive : IconStyle
, otherwise : IconStyle
}
}
}
}
{-| -}
type alias DialogStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ title :
{ contentText : List (Attribute msg)
}
, text :
{ contentText : List (Attribute msg)
}
, buttons :
{ elementRow : List (Attribute msg)
, content :
{ accept : ButtonStyle msg
, dismiss : ButtonStyle msg
}
}
}
}
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias ExpansionPanelStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ panel :
{ elementRow : List (Attribute msg)
, content :
{ label :
{ elementRow : List (Attribute msg)
, content :
{ icon : IconStyle
, text : { elementText : List (Attribute msg) }
}
}
, expandIcon : Icon
, collapseIcon : Icon
, icon : IconStyle
}
}
, content :
{ element : List (Attribute msg)
}
}
}
{-| -}
type alias SnackbarStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ text :
{ elementText : List (Attribute msg)
}
, button : ButtonStyle msg
}
}
{-| -}
type alias TextInputStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ chips :
{ elementRow : List (Attribute msg)
, content : ButtonStyle msg
}
, text :
{ elementTextInput : List (Attribute msg)
}
}
}
{-| -}
type alias TabStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ tabs :
{ elementRow : List (Attribute msg)
, content : ButtonStyle msg
}
, content : List (Attribute msg)
}
}
{-| -}
type alias ItemStyle content =
{ element : List (Attribute Never)
, content : content
}
{-| -}
type alias DividerStyle msg =
{ element : List (Attribute msg)
}
{-| -}
type alias TitleStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ divider : DividerStyle msg
, title : List (Attribute msg)
}
}
{-| -}
type alias RowStyle msg =
{ elementRow : List (Attribute msg)
, content :
{ element : List (Attribute Never)
, ifFirst : List (Attribute Never)
, ifLast : List (Attribute Never)
, ifSingleton : List (Attribute Never)
, otherwise : List (Attribute Never)
}
}
{-| -}
type alias ColumnStyle msg =
{ elementColumn : List (Attribute msg)
, content :
{ element : List (Attribute Never)
, ifFirst : List (Attribute Never)
, ifLast : List (Attribute Never)
, ifSingleton : List (Attribute Never)
, otherwise : List (Attribute Never)
}
}
{-| -}
type alias ButtonSheetStyle msg =
{ element : List (Attribute msg)
, content :
{ elementColumn : List (Attribute msg)
, content : ButtonStyle msg
}
}
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias SortTableStyle msg =
{ elementTable : List (Attribute msg)
, content :
{ header : ButtonStyle msg
, ascIcon : Icon
, descIcon : Icon
, defaultIcon : Icon
}
}
{-| Technical Remark:
- If icons are defined in Svg, they might not display correctly.
To avoid that, make sure to wrap them in `Element.html >> Element.el []`
-}
type alias LayoutStyle msg =
{ container : List (Attribute msg)
, snackbar : SnackbarStyle msg
, layout : List (Attribute msg) -> Element msg -> Html msg
, header : List (Attribute msg)
, sheet : List (Attribute msg)
, sheetButton : ButtonStyle msg
, menuButton : ButtonStyle msg
, menuTabButton : ButtonStyle msg
, menuIcon : Icon
, moreVerticalIcon : Icon
, spacing : Int
, title : List (Attribute msg)
, searchIcon : Icon
, search : TextInputStyle msg
, searchFill : TextInputStyle msg
}
{-| -}
type alias ProgressIndicatorStyle msg =
{ elementFunction : Maybe Float -> Element msg
}

View File

@ -8,11 +8,11 @@ module Widget.Style.Material exposing
, alertDialog , alertDialog
, expansionPanel, expansionPanelItem , expansionPanel, expansionPanelItem
, row, column , row, column
, fullBleedDivider, insetDivider, middleDividers, insetTitle, fullBleedTitle , fullBleedDivider, insetDivider, middleDividers, insetHeader, fullBleedHeader
, progressIndicator , progressIndicator
, snackbar , snackbar
, tab, tabButton , tab, tabButton
, layout , layout,sortTable
) )
{-| ![Example using the Material Design style](https://orasund.github.io/elm-ui-widgets/assets/material-style.png) {-| ![Example using the Material Design style](https://orasund.github.io/elm-ui-widgets/assets/material-style.png)
@ -90,13 +90,16 @@ The [List widget](https://material.io/components/lists) is a very complex widget
A List is build from items. A List is build from items.
You way want to use special items to visually organize the content of your list. You way want to use special items to visually organize the content of your list.
@docs fullBleedDivider, insetDivider, middleDividers, insetTitle, fullBleedTitle @docs fullBleedDivider, insetDivider, middleDividers, insetHeader, fullBleedHeader
# Progress Indicator # Progress Indicator
@docs progressIndicator @docs progressIndicator
# Sort Table
@docs sortTable
# Snackbar # Snackbar
@ -121,6 +124,10 @@ Note that you might want to checkout the [file on GitHub](https://github.com/Ora
-} -}
import Color exposing (Color) import Color exposing (Color)
import Internal.Button exposing (ButtonStyle)
import Internal.Dialog exposing (DialogStyle)
import Internal.ExpansionPanel exposing (ExpansionPanelStyle)
import Internal.List exposing (ColumnStyle, DividerStyle, ItemStyle, RowStyle, HeaderStyle)
import Internal.Material.Button as Button import Internal.Material.Button as Button
import Internal.Material.Chip as Chip import Internal.Material.Chip as Chip
import Internal.Material.Dialog as Dialog import Internal.Material.Dialog as Dialog
@ -133,23 +140,14 @@ import Internal.Material.Snackbar as Snackbar
import Internal.Material.Switch as Switch import Internal.Material.Switch as Switch
import Internal.Material.Tab as Tab import Internal.Material.Tab as Tab
import Internal.Material.TextInput as TextInput import Internal.Material.TextInput as TextInput
import Widget.Style import Internal.Material.SortTable as SortTable
exposing import Internal.ProgressIndicator exposing (ProgressIndicatorStyle)
( ButtonStyle import Internal.Switch exposing (SwitchStyle)
, ColumnStyle import Internal.Tab exposing (TabStyle)
, DialogStyle import Internal.TextInput exposing (TextInputStyle)
, DividerStyle import Widget.Layout exposing (LayoutStyle)
, ExpansionPanelStyle import Widget.Snackbar exposing (SnackbarStyle)
, ItemStyle import Internal.SortTable exposing (SortTableStyle)
, LayoutStyle
, ProgressIndicatorStyle
, RowStyle
, SnackbarStyle
, SwitchStyle
, TabStyle
, TextInputStyle
, TitleStyle
)
@ -346,18 +344,18 @@ middleDividers =
List.middleDividers List.middleDividers
{-| A title of a section of a list. Comes with a inset divider. {-| A header of a section of a list. Comes with a inset divider.
-} -}
insetTitle : Palette -> ItemStyle (TitleStyle msg) insetHeader : Palette -> ItemStyle (HeaderStyle msg)
insetTitle = insetHeader =
List.insetTitle List.insetHeader
{-| A title of a section of a list. Comes with a full bleed divider. {-| A header of a section of a list. Comes with a full bleed divider.
-} -}
fullBleedTitle : Palette -> ItemStyle (TitleStyle msg) fullBleedHeader : Palette -> ItemStyle (HeaderStyle msg)
fullBleedTitle = fullBleedHeader =
List.fullBleedTitle List.fullBleedHeader
{-| a Row of buttons. {-| a Row of buttons.
@ -440,6 +438,13 @@ progressIndicator : Palette -> ProgressIndicatorStyle msg
progressIndicator = progressIndicator =
ProgressIndicator.progressIndicator ProgressIndicator.progressIndicator
--------------------------------------------------------------------------------
-- SORT TABLE
--------------------------------------------------------------------------------
sortTable : Palette -> SortTableStyle msg
sortTable =
SortTable.sortTable
{------------------------------------------------------------------------------- {-------------------------------------------------------------------------------