NoRedInk/noredink-ui/12.3.1

NOTE: the latest version is 35.9.3

Nri.Ui.Message.V2

Changes from V1:

  • adds alertRole, alertDialogRole role attributes
  • rename BannerAttribute -> Attribute
  • accept Attributes on any Message type
  • ☠️ remove mapContent
  • expose plaintext, markdown, and html Attribute helpers instead of having Content(..) in the view APIs
  • expose theme Attribute helpers instead of having Theme(..) in the view APIs
  • exposes a singular view function (tiny, large, and banner are now Attributes)
  • uses alertRole in somethingWentWrong

View

somethingWentWrong : String -> Html msg

Shows an appropriate error message for when something unhandled happened.

view maybeDetailedErrorMessage =
    viewMaybe Message.somethingWentWrong maybeDetailedErrorMessage
view : List (Attribute msg) -> Html msg
view =
    Message.view
        [ Message.tip
        , Message.markdown "Don't tip too much, or your waitress will **fall over**!"
        ]
type Attribute msg

Construct an Attribute using a helper like onDismiss or alert.

Size

Shows a tiny alert message. We commonly use these for validation errors and small hints to users.

Message.view [ Message.tiny ]

This is the default size for a Message.

Shows a large alert or callout message. We commonly use these for highlighted tips, instructions, or asides in page copy.

Message.view [ Message.large ]

Content

plaintext : String -> Attribute msg
markdown : String -> Attribute msg
html : List (Html msg) -> Attribute msg

Theme

This is the default theme for a Message.

{ color : Color
, backgroundColor : Color
, icon : Svg
}
-> Attribute msg

Role

Use this attribute when a user's immediate attention on the Message is required.

For example, use this attribute when:

  • An invalid value was entered into a form field
  • The user's login session is about to expire
  • The connection to the server was lost, local changes will not be saved

-- Excerpted from Using the alert role MDN docs

Use this attribute when (1) a user's immediate attention on the Message is required, (2) the Message contains interactible elements, and (3) you've correctly set up the Message to be modal (i.e., you've set up tab-wrapping, the body's overflow is hidden, the user can't interact with elements apart from the Message's contents...)

When you use this role, verify that you are using it correctly using this MDN article.

Actions

onDismiss : msg -> Attribute msg

Adds a dismiss ("X" icon) to a message which will produce the given msg when clicked.