NoRedInk/noredink-ui/7.19.0

NOTE: the latest version is 35.9.3

Nri.Ui.Modal.V6

Changes from V5:

  • Removes button helpers, now that we can use Nri.Ui.Button.V9 directly

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

import Html.Styled exposing (..)
import Nri.Ui.Button.V10 as Button
import Nri.Ui.Modal.V6 as Modal


type Msg
    = ModalMsg Modal.Msg
    | DoSomthing


view : Modal.Model -> Html Msg
view state =
    Modal.info
        { title = "Modal Header"
        , visibleTitle = True
        , wrapMsg = ModalMsg
        , content =
            \{ 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
, content : FocusableElementAttrs msg -> Html msg
, wrapMsg : Msg -> msg
}
-> Model
-> Html msg
{ 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

X icon

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

Modules