NoRedInk/noredink-ui/18.0.1

NOTE: the latest version is 35.9.3

Nri.Ui.Message.V3

Patch changes:

  • adds notMobileCss, mobileCss, quizEngineMobileCss
  • adds hideIconForMobile and hideIconFor
  • use Shadows

Changes from V2:

- adds helpers: `custom`,`css`,`icon`,`testId`,`id`

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.

icon : Svg -> Attribute msg
custom : List (Attribute Never) -> Attribute msg

Use this helper to add custom attributes.

Do NOT use this helper to add css styles, as they may not be applied the way you want/expect if underlying styles change. Instead, please use the css helper.

testId : String -> Attribute msg
id : String -> Attribute msg

CSS

hideIconFor : MediaQuery -> Attribute msg
css : List Style -> Attribute msg
notMobileCss : List Style -> Attribute msg

Equivalent to:

Message.css
    [ Css.Media.withMedia [ Nri.Ui.MediaQuery.V1.notMobile ] styles ]
mobileCss : List Style -> Attribute msg

Equivalent to:

Message.css
    [ Css.Media.withMedia [ Nri.Ui.MediaQuery.V1.mobile ] styles ]
quizEngineMobileCss : List Style -> Attribute msg

Equivalent to:

Message.css
    [ Css.Media.withMedia [ Nri.Ui.MediaQuery.V1.quizEngineMobile ] styles ]

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

Provide a plain-text string.

markdown : String -> Attribute msg

Provide a string that will be rendered as markdown.

html : List (Html msg) -> Attribute msg

Provide a list of custom HTML.

httpError : Error -> Attribute msg

Provide an HTTP error, which will be translated to user-friendly text.

Theme

This is the default theme for a Message.

{ color : Color
, backgroundColor : Color
}
-> 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.