Skip to content

Commit

Permalink
updated eol character
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherhale committed Jan 11, 2021
1 parent 73dcd50 commit 92474b2
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions src/Modal.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ module Modal exposing
( ClosingAnimation(..)
, ClosingEffect(..)
, Config
, Model
, Model(..)
, Msg
, OpenedAnimation(..)
, OpeningAnimation(..)
, animationEnd
, closeModal
, cancelModal
, cmdGetWindowSize
, initModel
, newConfig
Expand Down Expand Up @@ -55,6 +56,8 @@ type Model msg
| Opened (Config msg)
| Closing (Config msg)
| Closed
| Canceling (Config msg)
| Canceled


initModel : Model msg
Expand Down Expand Up @@ -91,6 +94,7 @@ subscriptions =
type Msg msg
= OpenModal (Config msg)
| CloseModal
| CancelModal
| AnimationEnd
| GetWindowSize Float Float

Expand Down Expand Up @@ -211,6 +215,9 @@ closeModal : (Msg msg -> msg) -> msg
closeModal fn =
fn CloseModal

cancelModal : (Msg msg -> msg) -> msg
cancelModal fn =
fn CancelModal

animationEnd : (Msg msg -> msg) -> msg
animationEnd fn =
Expand Down Expand Up @@ -243,12 +250,17 @@ update msg model =
)

CloseModal ->
( setModalState model
( setModalState msg model
, Cmd.none
)

CancelModal ->
( setModalState msg model
, Cmd.none
)

AnimationEnd ->
( setModalState model
( setModalState msg model
, Cmd.none
)

Expand Down Expand Up @@ -302,6 +314,21 @@ view modal =
Closed ->
text ""

Canceling (Config config) ->
div
[ modalFade
, modalClose
, closingEffectClass config.closingEffect
]
[ modalBodyView
(Just AnimationEnd)
(closingAnimationClass config.closingAnimation config.modalBodySettings)
(Config config)
]

Canceled ->
text ""


{-| @priv
View of modal body
Expand Down Expand Up @@ -920,6 +947,14 @@ setModalBodyPosition width height model =
Closed ->
Closed

Canceling config ->
config
|> setBodySettings (recalcBodyModalProperties width height)
|> Canceling

Canceled ->
Canceled



-- Private helpers
Expand All @@ -936,21 +971,30 @@ mapConfig fn config =
{-| @priv
Helper for update function
-}
setModalState : Model msg -> Model msg
setModalState modal =
setModalState : Msg msg -> Model msg -> Model msg
setModalState msg modal =
case modal of
Opening config ->
Opened config

Opened config ->
Closing config
if msg == CancelModal then
Canceling config

else
Closing config

Closing _ ->
Closed

Closed ->
Closed

Canceling _ ->
Canceled

Canceled ->
Canceled

{-| @priv
Centering and adaptive width for modal body
Expand Down

0 comments on commit 92474b2

Please sign in to comment.