Remove ViewFuncs abstraction, which imo made it harder to unserstand what the views actually required

This commit is contained in:
Tessa Kelly 2020-07-02 12:18:51 -07:00
parent 2a5813dc18
commit 7e2d47bfa3
2 changed files with 22 additions and 14 deletions

View File

@ -3,7 +3,6 @@ module Nri.Ui.Modal.V9 exposing
, Msg, update, subscriptions
, open, close
, info, warning
, ViewFuncs
, Focusable
, multipleFocusableElementView, onlyFocusableElementView
)
@ -27,7 +26,6 @@ module Nri.Ui.Modal.V9 exposing
### Modals
@docs info, warning
@docs ViewFuncs
### Focusable
@ -100,7 +98,12 @@ info :
, title : String
, wrapMsg : Msg -> msg
}
-> (ViewFuncs msg -> Focusable msg)
->
({ viewContent : { content : List (Html msg), footer : List (Html msg) } -> Html msg
, closeButton : List (Html.Attribute msg) -> Html msg
}
-> Focusable msg
)
-> Model
-> Html msg
info config getFocusable model =
@ -113,7 +116,12 @@ warning :
, title : String
, wrapMsg : Msg -> msg
}
-> (ViewFuncs msg -> Focusable msg)
->
({ viewContent : { content : List (Html msg), footer : List (Html msg) } -> Html msg
, closeButton : List (Html.Attribute msg) -> Html msg
}
-> Focusable msg
)
-> Model
-> Html msg
warning config getFocusable model =
@ -169,13 +177,6 @@ onlyFocusableElementView f =
Focusable (Modal.onlyFocusableElementView (\attributes -> f attributes)) [ Modal.autofocusOnLastElement ]
{-| -}
type alias ViewFuncs msg =
{ viewContent : { content : List (Html msg), footer : List (Html msg) } -> Html msg
, closeButton : List (Html.Attribute msg) -> Html msg
}
view :
Theme
->
@ -183,12 +184,16 @@ view :
, title : String
, wrapMsg : Msg -> msg
}
-> (ViewFuncs msg -> Focusable msg)
->
({ viewContent : { content : List (Html msg), footer : List (Html msg) } -> Html msg
, closeButton : List (Html.Attribute msg) -> Html msg
}
-> Focusable msg
)
-> Model
-> Html msg
view theme config getFocusable model =
let
viewFuncs : ViewFuncs msg
viewFuncs =
{ viewContent = viewContent config.visibleTitle
, closeButton = closeButton config.wrapMsg

View File

@ -96,7 +96,10 @@ example =
getFocusable :
( State, Modal.Msg -> Msg, Button.Attribute Msg )
-> Modal.ViewFuncs Msg
->
{ viewContent : { content : List (Html Msg), footer : List (Html Msg) } -> Html Msg
, closeButton : List (Html.Attribute Msg) -> Html Msg
}
-> Modal.Focusable Msg
getFocusable ( state, wrapMsg, firstButtonStyle ) { viewContent, closeButton } =
case ( state.showX, state.showContinue, state.showSecondary ) of