NoRedInk/noredink-ui/7.1.4

NOTE: the latest version is 35.9.3

Nri.Ui.Modal.V7

Changes from V6:

  • Modal starts a new stacking context, to prevent non-normal-flow elements from showing through the backdrop
  • Scrollable content shows a shadow
    import Html.Styled exposing (..)
    import Nri.Ui.Button.V9 as Button
    import Nri.Ui.Modal.V7 as Modal

    type Msg
        = ModalMsg Modal.Msg
        | DoSomthing

    view : Modal.Model -> Html Msg
    view state =
        Modal.info
            { title = "Modal Header"
            , visibleTitle = True
            , wrapMsg = ModalMsg
            }
            [ Modal.onlyFocusableElementView
                (\{ onlyFocusableElement } ->
                    div []
                        [ Modal.viewContent [ text "Content goes here!" ]
                        , Modal.viewFooter
                            [ Button.button "Continue"
                                [ Button.primary
                                , Button.onClick DoSomthing
                                , Button.custom onlyFocusableElement
                                ]
                            , text "`onlyFocusableElement` will trap the focus on the 'Continue' button."
                            ]
                        ]
                )
            ]
            state

    subscriptions : Modal.Model -> Sub Msg
    subscriptions state =
        Modal.subscriptions state

    view init
    --> text ""  -- a closed modal

State and updates

type alias Model =
Model
init : Model
type alias Msg =
Msg
{ dismissOnEscAndOverlayClick : Bool }
-> Msg
-> Model
-> ( Model, Cmd Msg )
subscriptions : Model -> Sub Msg

Include the subscription if you want the modal to dismiss on Esc.

open : String -> Msg

Pass the id of the element that focus should return to when the modal closes.

close : Msg

Views

Modals

{ visibleTitle : Bool
, title : String
, wrapMsg : Msg -> msg
}
-> List (Attribute msg)
-> Model
-> Html msg
{ visibleTitle : Bool
, title : String
, wrapMsg : Msg -> msg
}
-> List (Attribute msg)
-> Model
-> Html msg

View containers

viewContent : List (Html msg) -> Html msg
viewFooter : List (Html msg) -> Html msg

Attributes

type alias Attribute msg =
Attribute msg
( { firstFocusableElement : List (Attribute msg)
, lastFocusableElement : List (Attribute msg)
, autofocusElement : Attribute msg
}
-> Html msg
)
-> Attribute msg
onlyFocusableElementView : (List (Attribute msg) -> Html msg) -> Attribute msg
autofocusOnLastElement : Attribute msg

X icon

closeButton : (Msg -> msg) -> List (Attribute msg) -> Html msg