mirror of
https://github.com/Orasund/elm-ui-widgets.git
synced 2024-11-25 01:56:57 +03:00
added BottomSheet
This commit is contained in:
parent
21f07bdfac
commit
4a3314c72a
@ -16,6 +16,7 @@ import Example.Tab as Tab
|
|||||||
import Example.TextInput as TextInput
|
import Example.TextInput as TextInput
|
||||||
import Example.Sheet as Sheet
|
import Example.Sheet as Sheet
|
||||||
import Example.AppBar as AppBar
|
import Example.AppBar as AppBar
|
||||||
|
import Example.Snackbar as Snackbar
|
||||||
import Framework.Grid as Grid
|
import Framework.Grid as Grid
|
||||||
import View.States as States
|
import View.States as States
|
||||||
import Example.Layout as Layout
|
import Example.Layout as Layout
|
||||||
@ -36,6 +37,7 @@ type Example
|
|||||||
| SheetExample
|
| SheetExample
|
||||||
| AppBarExample
|
| AppBarExample
|
||||||
| LayoutExample
|
| LayoutExample
|
||||||
|
| SnackbarExample
|
||||||
|
|
||||||
|
|
||||||
asList : List Example
|
asList : List Example
|
||||||
@ -55,6 +57,7 @@ asList =
|
|||||||
, SheetExample
|
, SheetExample
|
||||||
, AppBarExample
|
, AppBarExample
|
||||||
, LayoutExample
|
, LayoutExample
|
||||||
|
, SnackbarExample
|
||||||
]
|
]
|
||||||
|> List.sortBy toString
|
|> List.sortBy toString
|
||||||
|
|
||||||
@ -103,6 +106,8 @@ toString example =
|
|||||||
"App Bar"
|
"App Bar"
|
||||||
LayoutExample ->
|
LayoutExample ->
|
||||||
"Layout"
|
"Layout"
|
||||||
|
SnackbarExample ->
|
||||||
|
"Snackbar"
|
||||||
|
|
||||||
fromString : String -> Maybe Example
|
fromString : String -> Maybe Example
|
||||||
fromString string =
|
fromString string =
|
||||||
@ -150,6 +155,9 @@ fromString string =
|
|||||||
|
|
||||||
"Layout" ->
|
"Layout" ->
|
||||||
Just LayoutExample
|
Just LayoutExample
|
||||||
|
|
||||||
|
"Snackbar" ->
|
||||||
|
Just SnackbarExample
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Nothing
|
Nothing
|
||||||
@ -202,6 +210,9 @@ get example =
|
|||||||
|
|
||||||
LayoutExample ->
|
LayoutExample ->
|
||||||
.layout
|
.layout
|
||||||
|
|
||||||
|
SnackbarExample ->
|
||||||
|
.snackbar
|
||||||
|
|
||||||
|
|
||||||
toTests : Example -> msg -> Style msg -> List ( String, Element msg )
|
toTests : Example -> msg -> Style msg -> List ( String, Element msg )
|
||||||
@ -251,6 +262,9 @@ toTests example =
|
|||||||
|
|
||||||
LayoutExample ->
|
LayoutExample ->
|
||||||
States.layout
|
States.layout
|
||||||
|
|
||||||
|
SnackbarExample ->
|
||||||
|
States.snackbar
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
@ -269,6 +283,7 @@ type Msg
|
|||||||
| Sheet Sheet.Msg
|
| Sheet Sheet.Msg
|
||||||
| AppBar AppBar.Msg
|
| AppBar AppBar.Msg
|
||||||
| Layout Layout.Msg
|
| Layout Layout.Msg
|
||||||
|
| Snackbar Snackbar.Msg
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ button : Button.Model
|
{ button : Button.Model
|
||||||
@ -286,6 +301,7 @@ type alias Model =
|
|||||||
, sheet : Sheet.Model
|
, sheet : Sheet.Model
|
||||||
, appBar : AppBar.Model
|
, appBar : AppBar.Model
|
||||||
, layout : Layout.Model
|
, layout : Layout.Model
|
||||||
|
, snackbar : Snackbar.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -314,6 +330,7 @@ type alias UpgradeCollection =
|
|||||||
, sheet : UpgradeRecord Sheet.Model Sheet.Msg
|
, sheet : UpgradeRecord Sheet.Model Sheet.Msg
|
||||||
, appBar : UpgradeRecord AppBar.Model AppBar.Msg
|
, appBar : UpgradeRecord AppBar.Model AppBar.Msg
|
||||||
, layout : UpgradeRecord Layout.Model Layout.Msg
|
, layout : UpgradeRecord Layout.Model Layout.Msg
|
||||||
|
, snackbar : UpgradeRecord Snackbar.Model Snackbar.Msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -333,6 +350,7 @@ type alias ExampleView msg =
|
|||||||
, sheet : Element msg
|
, sheet : Element msg
|
||||||
, appBar : Element msg
|
, appBar : Element msg
|
||||||
, layout : Element msg
|
, layout : Element msg
|
||||||
|
, snackbar : Element msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -383,6 +401,9 @@ init =
|
|||||||
|
|
||||||
( layoutModel, layoutMsg ) =
|
( layoutModel, layoutMsg ) =
|
||||||
Layout.init
|
Layout.init
|
||||||
|
|
||||||
|
( snackbarModel, snackbarMsg ) =
|
||||||
|
Snackbar.init
|
||||||
in
|
in
|
||||||
( { button = buttonModel
|
( { button = buttonModel
|
||||||
, switch = switchModel
|
, switch = switchModel
|
||||||
@ -399,6 +420,7 @@ init =
|
|||||||
, sheet = sheetModel
|
, sheet = sheetModel
|
||||||
, appBar = appBarModel
|
, appBar = appBarModel
|
||||||
, layout = layoutModel
|
, layout = layoutModel
|
||||||
|
, snackbar = snackbarModel
|
||||||
}
|
}
|
||||||
, [ Cmd.map Button buttonMsg
|
, [ Cmd.map Button buttonMsg
|
||||||
, Cmd.map Switch switchMsg
|
, Cmd.map Switch switchMsg
|
||||||
@ -415,6 +437,7 @@ init =
|
|||||||
, Cmd.map Sheet sheetMsg
|
, Cmd.map Sheet sheetMsg
|
||||||
, Cmd.map AppBar appBarMsg
|
, Cmd.map AppBar appBarMsg
|
||||||
, Cmd.map Layout layoutMsg
|
, Cmd.map Layout layoutMsg
|
||||||
|
, Cmd.map Snackbar snackbarMsg
|
||||||
]
|
]
|
||||||
|> Cmd.batch
|
|> Cmd.batch
|
||||||
)
|
)
|
||||||
@ -527,6 +550,13 @@ upgradeRecord =
|
|||||||
, updateFun = Layout.update
|
, updateFun = Layout.update
|
||||||
, subscriptionsFun = Layout.subscriptions
|
, subscriptionsFun = Layout.subscriptions
|
||||||
}
|
}
|
||||||
|
, snackbar =
|
||||||
|
{ from = .snackbar
|
||||||
|
, to = \model a -> { model | snackbar = a }
|
||||||
|
, msgMapper = Snackbar
|
||||||
|
, updateFun = Snackbar.update
|
||||||
|
, subscriptionsFun = Snackbar.subscriptions
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -575,6 +605,8 @@ update msg model =
|
|||||||
updateField .appBar m
|
updateField .appBar m
|
||||||
Layout m ->
|
Layout m ->
|
||||||
updateField .layout m
|
updateField .layout m
|
||||||
|
Snackbar m ->
|
||||||
|
updateField .snackbar m
|
||||||
)
|
)
|
||||||
model
|
model
|
||||||
|
|
||||||
@ -600,6 +632,7 @@ subscriptions model =
|
|||||||
, upgradeRecord.sheet |> subFun
|
, upgradeRecord.sheet |> subFun
|
||||||
, upgradeRecord.appBar |> subFun
|
, upgradeRecord.appBar |> subFun
|
||||||
, upgradeRecord.layout |> subFun
|
, upgradeRecord.layout |> subFun
|
||||||
|
, upgradeRecord.snackbar |> subFun
|
||||||
]
|
]
|
||||||
|> Sub.batch
|
|> Sub.batch
|
||||||
|
|
||||||
@ -640,6 +673,8 @@ view msgMapper style model =
|
|||||||
AppBar.view (AppBar >> msgMapper) style (.appBar model)
|
AppBar.view (AppBar >> msgMapper) style (.appBar model)
|
||||||
, layout =
|
, layout =
|
||||||
Layout.view (Layout >> msgMapper) style (.layout model)
|
Layout.view (Layout >> msgMapper) style (.layout model)
|
||||||
|
, snackbar =
|
||||||
|
Snackbar.view (Snackbar >> msgMapper) style (.snackbar model)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import Widget
|
|||||||
, TabStyle
|
, TabStyle
|
||||||
, TextInputStyle
|
, TextInputStyle
|
||||||
, InsetItemStyle
|
, InsetItemStyle
|
||||||
, SideSheetStyle
|
|
||||||
, FullBleedItemStyle
|
, FullBleedItemStyle
|
||||||
, AppBarStyle
|
, AppBarStyle
|
||||||
)
|
)
|
||||||
@ -137,7 +136,7 @@ type alias Style msg =
|
|||||||
, multiLineItem : ItemStyle (MultiLineItemStyle msg) msg
|
, multiLineItem : ItemStyle (MultiLineItemStyle msg) msg
|
||||||
, imageItem : ItemStyle (ImageItemStyle msg) msg
|
, imageItem : ItemStyle (ImageItemStyle msg) msg
|
||||||
, expansionItem : ExpansionItemStyle msg
|
, expansionItem : ExpansionItemStyle msg
|
||||||
, sideSheet : SideSheetStyle msg
|
, sideSheet : ColumnStyle msg
|
||||||
, fullBleedItem : ItemStyle (FullBleedItemStyle msg) msg
|
, fullBleedItem : ItemStyle (FullBleedItemStyle msg) msg
|
||||||
, selectItem : ItemStyle (ButtonStyle msg) msg
|
, selectItem : ItemStyle (ButtonStyle msg) msg
|
||||||
, menuBar :
|
, menuBar :
|
||||||
|
@ -2,7 +2,7 @@ module Example.AppBar exposing (Model, Msg, init, subscriptions, update, view)
|
|||||||
|
|
||||||
import Browser
|
import Browser
|
||||||
import FeatherIcons
|
import FeatherIcons
|
||||||
import Widget exposing (Modal ,ItemStyle ,SideSheetStyle ,Button , TextInput ,TextInputStyle, AppBarStyle,ButtonStyle)
|
import Widget exposing (Modal ,ItemStyle ,Button , TextInput ,TextInputStyle, AppBarStyle,ButtonStyle)
|
||||||
import Widget.Icon as Icon exposing (Icon)
|
import Widget.Icon as Icon exposing (Icon)
|
||||||
import Widget.Material as Material
|
import Widget.Material as Material
|
||||||
import Element exposing (Attribute, DeviceClass(..), Element)
|
import Element exposing (Attribute, DeviceClass(..), Element)
|
||||||
|
@ -5,7 +5,7 @@ import Element exposing (Element,Attribute,DeviceClass(..))
|
|||||||
import FeatherIcons
|
import FeatherIcons
|
||||||
import Widget exposing (TextInputStyle ,TextInput
|
import Widget exposing (TextInputStyle ,TextInput
|
||||||
,Dialog,DialogStyle,ColumnStyle
|
,Dialog,DialogStyle,ColumnStyle
|
||||||
,ButtonStyle,Modal,AppBarStyle, SideSheetStyle,ItemStyle,HeaderStyle,InsetItemStyle)
|
,ButtonStyle,Modal,AppBarStyle,ItemStyle,HeaderStyle,InsetItemStyle)
|
||||||
import Widget.Icon as Icon exposing (Icon)
|
import Widget.Icon as Icon exposing (Icon)
|
||||||
import Widget.Material as Material
|
import Widget.Material as Material
|
||||||
import Widget.Material.Typography as Typography
|
import Widget.Material.Typography as Typography
|
||||||
@ -29,7 +29,7 @@ type alias Style style msg =
|
|||||||
{ style
|
{ style
|
||||||
| container : List (Attribute msg)
|
| container : List (Attribute msg)
|
||||||
, snackbar : SnackbarStyle msg
|
, snackbar : SnackbarStyle msg
|
||||||
, sideSheet : SideSheetStyle msg
|
, sideSheet : ColumnStyle msg
|
||||||
, sheetButton : ItemStyle (ButtonStyle msg) msg
|
, sheetButton : ItemStyle (ButtonStyle msg) msg
|
||||||
, searchFill : TextInputStyle msg
|
, searchFill : TextInputStyle msg
|
||||||
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
||||||
|
@ -3,14 +3,14 @@ module Example.Sheet exposing (Model, Msg, init, subscriptions, update, view)
|
|||||||
import Browser
|
import Browser
|
||||||
import Element exposing (Element)
|
import Element exposing (Element)
|
||||||
import FeatherIcons
|
import FeatherIcons
|
||||||
import Widget exposing (ButtonStyle, SideSheetStyle,ItemStyle,HeaderStyle,InsetItemStyle)
|
import Widget exposing (ButtonStyle, ColumnStyle,ItemStyle,HeaderStyle,InsetItemStyle)
|
||||||
import Widget.Icon as Icon
|
import Widget.Icon as Icon
|
||||||
import Widget.Material as Material
|
import Widget.Material as Material
|
||||||
import Widget.Material.Typography as Typography
|
import Widget.Material.Typography as Typography
|
||||||
|
|
||||||
type alias Style style msg =
|
type alias Style style msg =
|
||||||
{ style
|
{ style
|
||||||
| sideSheet : SideSheetStyle msg
|
| sideSheet : ColumnStyle msg
|
||||||
, primaryButton : ButtonStyle msg
|
, primaryButton : ButtonStyle msg
|
||||||
, fullBleedHeader : ItemStyle (HeaderStyle msg) msg
|
, fullBleedHeader : ItemStyle (HeaderStyle msg) msg
|
||||||
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
||||||
@ -100,7 +100,7 @@ view msgMapper style (IsEnabled isEnabled) =
|
|||||||
Element.none
|
Element.none
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|> Widget.sideSheet style.sideSheet
|
|> Widget.itemList style.sideSheet
|
||||||
, onDismiss = Just <| msgMapper <| ToggleModal False
|
, onDismiss = Just <| msgMapper <| ToggleModal False
|
||||||
}
|
}
|
||||||
|> List.singleton
|
|> List.singleton
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
module Main exposing (Model, Msg, init, subscriptions, update, view)
|
module Example.Snackbar exposing (Model, Msg, init, subscriptions, update, view)
|
||||||
|
|
||||||
import Browser
|
import Browser
|
||||||
import Element exposing (Element)
|
import Element exposing (Element)
|
||||||
import FeatherIcons
|
import FeatherIcons
|
||||||
import Time
|
import Time
|
||||||
import Widget exposing (ButtonStyle, ColumnStyle, RowStyle, SnackbarStyle)
|
import Widget exposing (ButtonStyle, ColumnStyle, RowStyle)
|
||||||
import Widget.Snackbar as Snackbar exposing (Snackbar)
|
import Widget.Snackbar as Snackbar exposing (Snackbar,SnackbarStyle)
|
||||||
import Widget.Material as Material
|
import Widget.Material as Material
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ view msgMapper style model =
|
|||||||
, False
|
, False
|
||||||
)
|
)
|
||||||
, text = "Add Notification"
|
, text = "Add Notification"
|
||||||
, icon = Element.none
|
, icon = always Element.none
|
||||||
}
|
}
|
||||||
, Widget.button style.button
|
, Widget.button style.button
|
||||||
{ onPress =
|
{ onPress =
|
||||||
@ -86,7 +86,7 @@ view msgMapper style model =
|
|||||||
, True
|
, True
|
||||||
)
|
)
|
||||||
, text = "Add Notification with Action"
|
, text = "Add Notification with Action"
|
||||||
, icon = Element.none
|
, icon = always Element.none
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|> Widget.column style.column
|
|> Widget.column style.column
|
||||||
|
@ -25,7 +25,7 @@ import Task
|
|||||||
import Time
|
import Time
|
||||||
import Widget exposing (Modal,TextInput)
|
import Widget exposing (Modal,TextInput)
|
||||||
import Widget.Icon as Icon
|
import Widget.Icon as Icon
|
||||||
import Widget.Layout as Layout exposing (Part)
|
import Widget.Layout as Layout
|
||||||
import Widget.ScrollingNav as ScrollingNav
|
import Widget.ScrollingNav as ScrollingNav
|
||||||
import Widget.Snackbar as Snackbar exposing (Message)
|
import Widget.Snackbar as Snackbar exposing (Message)
|
||||||
import Material.Icons.Types exposing (Coloring(..))
|
import Material.Icons.Types exposing (Coloring(..))
|
||||||
@ -151,13 +151,6 @@ updateLoaded msg model =
|
|||||||
(Cmd.map StatelessSpecific)
|
(Cmd.map StatelessSpecific)
|
||||||
|
|
||||||
UpdateScrollingNav fun ->
|
UpdateScrollingNav fun ->
|
||||||
let
|
|
||||||
_ =
|
|
||||||
model.scrollingNav |> fun
|
|
||||||
|> ScrollingNav.current Example.fromString
|
|
||||||
|> Maybe.map Example.toString
|
|
||||||
|> Debug.log "section"
|
|
||||||
in
|
|
||||||
( { model | scrollingNav = model.scrollingNav |> fun }
|
( { model | scrollingNav = model.scrollingNav |> fun }
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,6 @@ module Stateless exposing (Model, Msg, init, update,subscriptions, view)
|
|||||||
import Data.Example as Example
|
import Data.Example as Example
|
||||||
import Data.Theme as Theme exposing (Theme)
|
import Data.Theme as Theme exposing (Theme)
|
||||||
import Element exposing (Element)
|
import Element exposing (Element)
|
||||||
import Widget.Layout exposing (Part(..))
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module View.States exposing (button, sheet,dialog,layout, icon, list, modal,appBar, multiSelect, progressIndicator, select, sortTable, switch, tab, textInput)
|
module View.States exposing (button,snackbar, sheet,dialog,layout, icon, list, modal,appBar, multiSelect, progressIndicator, select, sortTable, switch, tab, textInput)
|
||||||
|
|
||||||
import Data.Style exposing (Style)
|
import Data.Style exposing (Style)
|
||||||
import Element exposing (Element)
|
import Element exposing (Element)
|
||||||
@ -7,7 +7,7 @@ import Icons
|
|||||||
import Set
|
import Set
|
||||||
import Widget
|
import Widget
|
||||||
import Widget.Icon as Icon
|
import Widget.Icon as Icon
|
||||||
import Widget.Layout exposing (Part(..))
|
import Widget.Layout
|
||||||
|
|
||||||
|
|
||||||
button : msg -> Style msg -> List ( String, Element msg )
|
button : msg -> Style msg -> List ( String, Element msg )
|
||||||
@ -558,4 +558,8 @@ appBar _ style =
|
|||||||
|
|
||||||
layout : msg -> Style msg -> List ( String, Element msg )
|
layout : msg -> Style msg -> List ( String, Element msg )
|
||||||
layout _ style =
|
layout _ style =
|
||||||
|
[]
|
||||||
|
|
||||||
|
snackbar : msg -> Style msg -> List ( String, Element msg )
|
||||||
|
snackbar _ style =
|
||||||
[]
|
[]
|
@ -9,7 +9,7 @@ import Internal.Dialog as Dialog
|
|||||||
import Internal.Item as Item exposing (InsetItemStyle, ItemStyle)
|
import Internal.Item as Item exposing (InsetItemStyle, ItemStyle)
|
||||||
import Internal.Modal as Modal exposing (Modal)
|
import Internal.Modal as Modal exposing (Modal)
|
||||||
import Internal.Select as Select exposing (Select)
|
import Internal.Select as Select exposing (Select)
|
||||||
import Internal.Sheet as Sheet exposing (SideSheetStyle)
|
import Internal.Sheet as Sheet
|
||||||
import Internal.TextInput as TextInput exposing (TextInput, TextInputStyle)
|
import Internal.TextInput as TextInput exposing (TextInput, TextInputStyle)
|
||||||
import Widget.Customize as Customize
|
import Widget.Customize as Customize
|
||||||
import Widget.Icon exposing (Icon)
|
import Widget.Icon exposing (Icon)
|
||||||
|
@ -174,4 +174,4 @@ buttonColumn style =
|
|||||||
style.elementColumn.content.otherwise
|
style.elementColumn.content.otherwise
|
||||||
, content = style.content
|
, content = style.content
|
||||||
}
|
}
|
||||||
>> Element.column style.elementColumn.elementColumn
|
>> Element.column style.elementColumn.elementColumn
|
@ -3,6 +3,8 @@ module Internal.Material.List exposing
|
|||||||
, cardColumn
|
, cardColumn
|
||||||
, column
|
, column
|
||||||
, row
|
, row
|
||||||
|
, sideSheet
|
||||||
|
, bottomSheet
|
||||||
)
|
)
|
||||||
|
|
||||||
import Element
|
import Element
|
||||||
@ -146,3 +148,39 @@ cardColumn palette =
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sideSheet : Palette -> ColumnStyle msg
|
||||||
|
sideSheet palette =
|
||||||
|
{ elementColumn =
|
||||||
|
(palette.surface |> MaterialColor.textAndBackground)
|
||||||
|
++ [ Element.width <| Element.maximum 360 <| Element.fill
|
||||||
|
, Element.height <| Element.fill
|
||||||
|
, Element.paddingXY 0 8
|
||||||
|
]
|
||||||
|
, content =
|
||||||
|
{ element =
|
||||||
|
[ Element.width <| Element.fill ]
|
||||||
|
, ifSingleton = []
|
||||||
|
, ifFirst = []
|
||||||
|
, ifLast = []
|
||||||
|
, otherwise = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bottomSheet : Palette -> ColumnStyle msg
|
||||||
|
bottomSheet palette =
|
||||||
|
{ elementColumn =
|
||||||
|
(palette.surface |> MaterialColor.textAndBackground)
|
||||||
|
++ [ Element.height <| Element.fill
|
||||||
|
, Element.width <| Element.maximum 360 <| Element.fill
|
||||||
|
, Element.paddingXY 0 8
|
||||||
|
]
|
||||||
|
, content =
|
||||||
|
{ element =
|
||||||
|
[ Element.width <| Element.fill ]
|
||||||
|
, ifSingleton = []
|
||||||
|
, ifFirst = []
|
||||||
|
, ifLast = []
|
||||||
|
, otherwise = []
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +1,8 @@
|
|||||||
module Internal.Material.Sheet exposing (sideSheet)
|
module Internal.Material.Sheet exposing (deleteMe)
|
||||||
|
|
||||||
import Element
|
import Element
|
||||||
import Internal.Material.Palette exposing (Palette)
|
import Internal.Material.Palette exposing (Palette)
|
||||||
import Internal.Sheet exposing (SideSheetStyle)
|
|
||||||
import Widget.Material.Color as MaterialColor
|
import Widget.Material.Color as MaterialColor
|
||||||
|
|
||||||
|
|
||||||
sideSheet : Palette -> SideSheetStyle msg
|
deleteMe = True
|
||||||
sideSheet palette =
|
|
||||||
{ element = [ ]
|
|
||||||
, content =
|
|
||||||
{ elementColumn =
|
|
||||||
(palette.surface |> MaterialColor.textAndBackground)
|
|
||||||
++ [ Element.width <| Element.maximum 360 <| Element.fill
|
|
||||||
]
|
|
||||||
, content =
|
|
||||||
{ element =
|
|
||||||
[ Element.width <| Element.fill ]
|
|
||||||
, ifSingleton = []
|
|
||||||
, ifFirst = []
|
|
||||||
, ifLast = []
|
|
||||||
, otherwise = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,18 +1,10 @@
|
|||||||
module Internal.Sheet exposing (SideSheetStyle, sideSheet)
|
module Internal.Sheet exposing (delete)
|
||||||
|
|
||||||
import Element exposing (Attribute, Element)
|
import Element exposing (Attribute, Element)
|
||||||
import Internal.Item exposing (Item)
|
import Internal.Item exposing (Item)
|
||||||
import Internal.List as List exposing (ColumnStyle)
|
import Internal.List
|
||||||
import Widget.Customize as Customize
|
import Widget.Customize as Customize
|
||||||
|
|
||||||
|
delete = "deleteMe Pls"
|
||||||
|
|
||||||
type alias SideSheetStyle msg =
|
-- >> Element.el (style.element)
|
||||||
{ element : List (Attribute msg)
|
|
||||||
, content : ColumnStyle msg
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sideSheet : SideSheetStyle msg -> List (Item msg) -> Element msg
|
|
||||||
sideSheet style =
|
|
||||||
List.itemList (style.content |> Customize.elementColumn [ Element.height <| Element.fill ])
|
|
||||||
>> Element.el (style.element ++ [ Element.height <| Element.fill ])
|
|
@ -16,7 +16,6 @@ module Widget exposing
|
|||||||
, selectItem, asItem
|
, selectItem, asItem
|
||||||
, itemList
|
, itemList
|
||||||
, menuBar, tabBar
|
, menuBar, tabBar
|
||||||
, SideSheetStyle, sideSheet
|
|
||||||
, SortTableStyle, SortTable, Column, sortTable, floatColumn, intColumn, stringColumn, unsortableColumn
|
, SortTableStyle, SortTable, Column, sortTable, floatColumn, intColumn, stringColumn, unsortableColumn
|
||||||
, TextInputStyle, TextInput, textInput
|
, TextInputStyle, TextInput, textInput
|
||||||
, TabStyle, Tab, tab
|
, TabStyle, Tab, tab
|
||||||
@ -127,11 +126,6 @@ You can create you own widgets by sticking widgets types together.
|
|||||||
@docs AppBarStyle, menuBar, tabBar
|
@docs AppBarStyle, menuBar, tabBar
|
||||||
|
|
||||||
|
|
||||||
# Sheet
|
|
||||||
|
|
||||||
@docs SideSheetStyle, sideSheet
|
|
||||||
|
|
||||||
|
|
||||||
# Sort Table
|
# Sort Table
|
||||||
|
|
||||||
![SortTable](https://orasund.github.io/elm-ui-widgets/assets/sortTable.png)
|
![SortTable](https://orasund.github.io/elm-ui-widgets/assets/sortTable.png)
|
||||||
@ -1489,24 +1483,6 @@ tabBar =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
-- SHEET
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
type alias SideSheetStyle msg =
|
|
||||||
{ element : List (Attribute msg)
|
|
||||||
, content : ColumnStyle msg
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| A sheet is similar to
|
|
||||||
-}
|
|
||||||
sideSheet : SideSheetStyle msg -> List (Item msg) -> Element msg
|
|
||||||
sideSheet =
|
|
||||||
Sheet.sideSheet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{----------------------------------------------------------
|
{----------------------------------------------------------
|
||||||
- SORT TABLE
|
- SORT TABLE
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
module Widget.Layout exposing
|
module Widget.Layout exposing
|
||||||
( Part, timePassed
|
( leftSheet, rightSheet, searchSheet
|
||||||
, activate, queueMessage
|
|
||||||
, leftSheet, rightSheet, searchSheet
|
|
||||||
, getDeviceClass, partitionActions, orderModals
|
, getDeviceClass, partitionActions, orderModals
|
||||||
, view
|
|
||||||
)
|
)
|
||||||
|
|
||||||
{-| 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:
|
||||||
@ -16,26 +13,12 @@ module Widget.Layout exposing
|
|||||||
|
|
||||||
It is responsive and changes view to apply to the [material design guidelines](https://material.io/components/app-bars-top).
|
It is responsive and changes view to apply to the [material design guidelines](https://material.io/components/app-bars-top).
|
||||||
|
|
||||||
|
# Sheets
|
||||||
# Basics
|
|
||||||
|
|
||||||
@docs Layout, Part, timePassed
|
|
||||||
|
|
||||||
|
|
||||||
# Actions
|
|
||||||
|
|
||||||
@docs activate, queueMessage
|
|
||||||
|
|
||||||
|
|
||||||
# Views
|
|
||||||
|
|
||||||
|
|
||||||
## Sheets
|
|
||||||
|
|
||||||
@docs leftSheet, rightSheet, searchSheet
|
@docs leftSheet, rightSheet, searchSheet
|
||||||
|
|
||||||
|
|
||||||
## Utility Functions
|
# Utility Functions
|
||||||
|
|
||||||
@docs getDeviceClass, partitionActions, orderModals
|
@docs getDeviceClass, partitionActions, orderModals
|
||||||
|
|
||||||
@ -51,96 +34,13 @@ import Internal.Dialog as Dialog
|
|||||||
import Internal.Item as Item exposing (InsetItemStyle, ItemStyle)
|
import Internal.Item as Item exposing (InsetItemStyle, ItemStyle)
|
||||||
import Internal.Modal as Modal exposing (Modal)
|
import Internal.Modal as Modal exposing (Modal)
|
||||||
import Internal.Select as Select exposing (Select)
|
import Internal.Select as Select exposing (Select)
|
||||||
import Internal.Sheet as Sheet exposing (SideSheetStyle)
|
|
||||||
import Internal.TextInput as TextInput exposing (TextInput, TextInputStyle)
|
import Internal.TextInput as TextInput exposing (TextInput, TextInputStyle)
|
||||||
|
import Internal.List as List exposing (ColumnStyle)
|
||||||
import Widget.Customize as Customize
|
import Widget.Customize as Customize
|
||||||
import Widget.Icon exposing (Icon)
|
import Widget.Icon exposing (Icon)
|
||||||
import Widget.Snackbar as Snackbar exposing (Message, SnackbarStyle)
|
import Widget.Snackbar as Snackbar exposing (Message, SnackbarStyle)
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type alias LayoutStyle msg =
|
|
||||||
{ container : List (Attribute msg)
|
|
||||||
, snackbar : SnackbarStyle msg
|
|
||||||
, sheet : SideSheetStyle msg
|
|
||||||
, sheetButton : ItemStyle (ButtonStyle msg) msg
|
|
||||||
, spacing : Int
|
|
||||||
, title : List (Attribute msg)
|
|
||||||
, searchFill : TextInputStyle msg
|
|
||||||
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
|
||||||
, menuBar :
|
|
||||||
AppBarStyle
|
|
||||||
{ menuIcon : Icon msg
|
|
||||||
, title : List (Attribute msg)
|
|
||||||
}
|
|
||||||
msg
|
|
||||||
, tabBar :
|
|
||||||
AppBarStyle
|
|
||||||
{ menuTabButton : ButtonStyle msg
|
|
||||||
, title : List (Attribute msg)
|
|
||||||
}
|
|
||||||
msg
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| The currently visible part: either the left sheet, right sheet or the search bar
|
|
||||||
-}
|
|
||||||
type Part
|
|
||||||
= LeftSheet
|
|
||||||
| RightSheet
|
|
||||||
| Search
|
|
||||||
|
|
||||||
|
|
||||||
{-| The model of the layout containing the snackbar and the currently active side sheet (or search bar)
|
|
||||||
-}
|
|
||||||
type alias Layout msg =
|
|
||||||
{ snackbar : Snackbar.Snackbar (Message msg)
|
|
||||||
, active : Maybe Part
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| Queues a message and displayes it as a snackbar once no other snackbar is visible.
|
|
||||||
-}
|
|
||||||
queueMessage : Message msg -> Layout msg -> Layout msg
|
|
||||||
queueMessage message layout =
|
|
||||||
{ layout
|
|
||||||
| snackbar = layout.snackbar |> Snackbar.insert message
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| Open either a side sheet or the search bar.
|
|
||||||
-}
|
|
||||||
activate : Maybe Part -> Layout msg -> Layout msg
|
|
||||||
activate part layout =
|
|
||||||
{ layout
|
|
||||||
| active = part
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| Update the model, put this function into your subscription.
|
|
||||||
The first argument is the seconds that have passed sice the function was called last.
|
|
||||||
-}
|
|
||||||
timePassed : Int -> Layout msg -> Layout msg
|
|
||||||
timePassed sec layout =
|
|
||||||
case layout.active of
|
|
||||||
Just LeftSheet ->
|
|
||||||
layout
|
|
||||||
|
|
||||||
Just RightSheet ->
|
|
||||||
layout
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
{ layout
|
|
||||||
| snackbar = layout.snackbar |> Snackbar.timePassed sec
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
-- View
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
{-| obtain the Device Calss from a given window.
|
{-| obtain the Device Calss from a given window.
|
||||||
|
|
||||||
Checkout Element.classifyDevice for more information.
|
Checkout Element.classifyDevice for more information.
|
||||||
@ -191,7 +91,7 @@ partitionActions actions =
|
|||||||
-}
|
-}
|
||||||
leftSheet :
|
leftSheet :
|
||||||
{ button : ItemStyle (ButtonStyle msg) msg
|
{ button : ItemStyle (ButtonStyle msg) msg
|
||||||
, sheet : SideSheetStyle msg
|
, sheet : ColumnStyle msg
|
||||||
}
|
}
|
||||||
->
|
->
|
||||||
{ title : Element msg
|
{ title : Element msg
|
||||||
@ -206,11 +106,9 @@ leftSheet style { title, onDismiss, menu } =
|
|||||||
:: (menu
|
:: (menu
|
||||||
|> Item.selectItem style.button
|
|> Item.selectItem style.button
|
||||||
)
|
)
|
||||||
|> Sheet.sideSheet
|
|> List.itemList
|
||||||
(style.sheet
|
(style.sheet
|
||||||
|> Customize.element [ Element.alignLeft ]
|
|> Customize.elementColumn [ Element.alignLeft ]
|
||||||
|> Customize.mapContent
|
|
||||||
(Customize.elementColumn [ Element.width <| Element.fill ])
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +116,7 @@ leftSheet style { title, onDismiss, menu } =
|
|||||||
{-| Right sheet containg a simple list of buttons
|
{-| Right sheet containg a simple list of buttons
|
||||||
-}
|
-}
|
||||||
rightSheet :
|
rightSheet :
|
||||||
{ sheet : SideSheetStyle msg
|
{ sheet : ColumnStyle msg
|
||||||
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
, insetItem : ItemStyle (InsetItemStyle msg) msg
|
||||||
}
|
}
|
||||||
->
|
->
|
||||||
@ -240,9 +138,9 @@ rightSheet style { onDismiss, moreActions } =
|
|||||||
, content = always Element.none
|
, content = always Element.none
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|> Sheet.sideSheet
|
|> List.itemList
|
||||||
(style.sheet
|
(style.sheet
|
||||||
|> Customize.element [ Element.alignRight ]
|
|> Customize.elementColumn [ Element.alignRight ]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,137 +198,4 @@ orderModals modals =
|
|||||||
, modals.rightSheet
|
, modals.rightSheet
|
||||||
, modals.topSheet
|
, modals.topSheet
|
||||||
]
|
]
|
||||||
|> List.filterMap identity
|
|> List.filterMap identity
|
||||||
|
|
||||||
|
|
||||||
view :
|
|
||||||
LayoutStyle msg
|
|
||||||
->
|
|
||||||
{ window : { height : Int, width : Int }
|
|
||||||
, dialog : Maybe (Modal msg)
|
|
||||||
, layout : Layout msg
|
|
||||||
, title : Element msg
|
|
||||||
, menu : Select msg
|
|
||||||
, search : Maybe (TextInput msg)
|
|
||||||
, actions : List (Button msg)
|
|
||||||
, onChangedSidebar : Maybe Part -> msg
|
|
||||||
}
|
|
||||||
-> List (Attribute msg)
|
|
||||||
view style { search, title, onChangedSidebar, menu, actions, window, dialog, layout } =
|
|
||||||
let
|
|
||||||
deviceClass : DeviceClass
|
|
||||||
deviceClass =
|
|
||||||
getDeviceClass window
|
|
||||||
|
|
||||||
{ primaryActions, moreActions } =
|
|
||||||
partitionActions actions
|
|
||||||
|
|
||||||
nav : Element msg
|
|
||||||
nav =
|
|
||||||
if
|
|
||||||
(deviceClass == Phone)
|
|
||||||
|| (deviceClass == Tablet)
|
|
||||||
|| ((menu.options |> List.length) > 5)
|
|
||||||
then
|
|
||||||
AppBar.menuBar style.menuBar
|
|
||||||
{ title = title
|
|
||||||
, deviceClass = deviceClass
|
|
||||||
, openLeftSheet = Just <| onChangedSidebar <| Just LeftSheet
|
|
||||||
, openRightSheet =
|
|
||||||
if moreActions |> List.isEmpty then
|
|
||||||
Nothing
|
|
||||||
|
|
||||||
else
|
|
||||||
Just <| onChangedSidebar <| Just RightSheet
|
|
||||||
, openTopSheet = Just <| onChangedSidebar <| Just Search
|
|
||||||
, primaryActions = primaryActions
|
|
||||||
, search = search
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
AppBar.tabBar style.tabBar
|
|
||||||
{ title = title
|
|
||||||
, menu = menu
|
|
||||||
, deviceClass = deviceClass
|
|
||||||
, openRightSheet =
|
|
||||||
if moreActions |> List.isEmpty then
|
|
||||||
Nothing
|
|
||||||
|
|
||||||
else
|
|
||||||
Just <| onChangedSidebar <| Just RightSheet
|
|
||||||
, openTopSheet = Just <| onChangedSidebar <| Just Search
|
|
||||||
, primaryActions = primaryActions
|
|
||||||
, search = search
|
|
||||||
}
|
|
||||||
|
|
||||||
snackbar : Element msg
|
|
||||||
snackbar =
|
|
||||||
layout.snackbar
|
|
||||||
|> Snackbar.view style.snackbar identity
|
|
||||||
|> Maybe.map
|
|
||||||
(Element.el
|
|
||||||
[ Element.padding style.spacing
|
|
||||||
, Element.alignBottom
|
|
||||||
, Element.alignRight
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|> Maybe.withDefault Element.none
|
|
||||||
|
|
||||||
onDismiss =
|
|
||||||
Nothing
|
|
||||||
|> onChangedSidebar
|
|
||||||
|
|
||||||
modals =
|
|
||||||
orderModals
|
|
||||||
{ dialog = dialog
|
|
||||||
, leftSheet =
|
|
||||||
if layout.active == Just LeftSheet then
|
|
||||||
leftSheet
|
|
||||||
{ button = style.sheetButton
|
|
||||||
, sheet = style.sheet
|
|
||||||
}
|
|
||||||
{ title = title
|
|
||||||
, menu = menu
|
|
||||||
, onDismiss = onDismiss
|
|
||||||
}
|
|
||||||
|> Just
|
|
||||||
|
|
||||||
else
|
|
||||||
Nothing
|
|
||||||
, rightSheet =
|
|
||||||
if layout.active == Just RightSheet then
|
|
||||||
rightSheet
|
|
||||||
{ sheet = style.sheet
|
|
||||||
, insetItem = style.insetItem
|
|
||||||
}
|
|
||||||
{ onDismiss = onDismiss
|
|
||||||
, moreActions = moreActions
|
|
||||||
}
|
|
||||||
|> Just
|
|
||||||
|
|
||||||
else
|
|
||||||
Nothing
|
|
||||||
, topSheet =
|
|
||||||
if layout.active == Just Search then
|
|
||||||
search
|
|
||||||
|> Maybe.map
|
|
||||||
(\textInput ->
|
|
||||||
searchSheet style.searchFill
|
|
||||||
{ search = textInput
|
|
||||||
, onDismiss = onDismiss
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
else
|
|
||||||
Nothing
|
|
||||||
, bottomSheet = Nothing
|
|
||||||
}
|
|
||||||
in
|
|
||||||
List.concat
|
|
||||||
[ style.container
|
|
||||||
, [ Element.inFront nav
|
|
||||||
, Element.inFront snackbar
|
|
||||||
]
|
|
||||||
, modals
|
|
||||||
|> Modal.singleModal
|
|
||||||
]
|
|
@ -8,7 +8,7 @@ module Widget.Material exposing
|
|||||||
, alertDialog
|
, alertDialog
|
||||||
, row, column
|
, row, column
|
||||||
, menuBar, tabBar
|
, menuBar, tabBar
|
||||||
, sideSheet
|
, sideSheet, bottomSheet
|
||||||
, fullBleedItem, insetItem, multiLineItem, imageItem, expansionItem, selectItem
|
, fullBleedItem, insetItem, multiLineItem, imageItem, expansionItem, selectItem
|
||||||
, fullBleedDivider, insetDivider, middleDivider
|
, fullBleedDivider, insetDivider, middleDivider
|
||||||
, fullBleedHeader, insetHeader
|
, fullBleedHeader, insetHeader
|
||||||
@ -88,7 +88,7 @@ Thus for now we only provide a card containing a list.
|
|||||||
|
|
||||||
# Sheet
|
# Sheet
|
||||||
|
|
||||||
@docs sideSheet
|
@docs sideSheet, bottomSheet
|
||||||
|
|
||||||
|
|
||||||
# Item
|
# Item
|
||||||
@ -161,7 +161,6 @@ 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 Internal.ProgressIndicator exposing (ProgressIndicatorStyle)
|
import Internal.ProgressIndicator exposing (ProgressIndicatorStyle)
|
||||||
import Internal.Sheet exposing (SideSheetStyle)
|
|
||||||
import Internal.SortTable exposing (SortTableStyle)
|
import Internal.SortTable exposing (SortTableStyle)
|
||||||
import Internal.Switch exposing (SwitchStyle)
|
import Internal.Switch exposing (SwitchStyle)
|
||||||
import Internal.Tab exposing (TabStyle)
|
import Internal.Tab exposing (TabStyle)
|
||||||
@ -353,18 +352,6 @@ tabBar =
|
|||||||
AppBar.tabBar
|
AppBar.tabBar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
|
||||||
-- SHEET
|
|
||||||
-------------------------------------------------------------------------------}
|
|
||||||
|
|
||||||
|
|
||||||
sideSheet : Palette -> SideSheetStyle msg
|
|
||||||
sideSheet =
|
|
||||||
Sheet.sideSheet
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
-- L I S T
|
-- L I S T
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
@ -383,6 +370,22 @@ column : ColumnStyle msg
|
|||||||
column =
|
column =
|
||||||
List.column
|
List.column
|
||||||
|
|
||||||
|
{-| A side sheet. Has a maximal width of 360.
|
||||||
|
-}
|
||||||
|
sideSheet : Palette -> ColumnStyle msg
|
||||||
|
sideSheet =
|
||||||
|
List.sideSheet
|
||||||
|
|
||||||
|
{-| A bottom sheet. Has a maximal width of 360.
|
||||||
|
Should be align to the bottom right corner of the screen.
|
||||||
|
-}
|
||||||
|
bottomSheet : Palette -> ColumnStyle msg
|
||||||
|
bottomSheet =
|
||||||
|
List.bottomSheet
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- ITEM
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
{-| A divider covering the full length
|
{-| A divider covering the full length
|
||||||
-}
|
-}
|
||||||
@ -497,6 +500,7 @@ selectItem =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
-- D I A L O G
|
-- D I A L O G
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
|
Loading…
Reference in New Issue
Block a user