NoRedInk/noredink-ui/6.24.1

NOTE: the latest version is 35.9.3

Nri.Ui.Modal.V5

Changes from V4:

  • Remove dependence on Assets
  • Adds keyboard support (escape key to exit, tabs contained within the modal)

These changes have required major API changes. Be sure to wire up subscriptions!

import Html.Styled exposing (..)
import Nri.Ui.Modal.V5 as Modal


view : Modal.State -> Html Msg
view state =
    Modal.info
        { title = { title = "Modal Header", visibleTitle = True }
        , wrapMsg = ModalMsg
        , content =
            \{ onlyFocusableElement } ->
                div []
                    [ Modal.viewContent [ text "Content goes here!" ]
                    , Modal.viewFooter
                        [ Modal.primaryButton DoSomething "Continue" onlyFocusableElement
                        , text "`onlyFocusableElement` will trap the focus on the 'Continue' button."
                        ]
                    ]
        }
        state


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

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.

Views

Modals

{ title :
{ visibleTitle : Bool
, title : String
}
, content : FocusableElementAttrs msg -> Html msg
, wrapMsg : Msg -> msg
}
-> Model
-> Html msg
{ title :
{ visibleTitle : Bool
, title : String
}
, content : FocusableElementAttrs msg -> Html msg
, wrapMsg : Msg -> msg
}
-> Model
-> Html msg
type alias FocusableElementAttrs msg =
{ onlyFocusableElement : List (Attribute msg)
, firstFocusableElement : List (Attribute msg)
, lastFocusableElement : List (Attribute msg)
}

View containers

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

Buttons

launchButton : (Msg -> msg) -> List Style -> String -> Html msg
closeButton : (Msg -> msg) -> List (Attribute msg) -> Html msg
primaryButton : msg -> String -> List (Attribute msg) -> Html msg
secondaryButton : msg -> String -> List (Attribute msg) -> Html msg
dangerButton : msg -> String -> List (Attribute msg) -> Html msg