NoRedInk/noredink-ui/6.29.1

NOTE: the latest version is 35.9.3

Nri.Ui.Button.V8

Changes from V7:

  • Removes dependency on Icon that makes versioned assets hard to work with
  • Removes copyToClipboard, which has additional dependencies and also isn't broadly used
  • Removes customButton from what's exposed, as it's not in use
  • Removes Borderless style (use ClickableText instead)

About:

Common NoRedInk buttons. For accessibility purposes, buttons that perform an action on the current page should be HTML <button> elements and are created here with *Button functions. Buttons that take the user to a new page should be HTML <a> elements and are created here with *Link functions. Both versions should be able to use the same CSS class in all cases.

There will generally be a *Button and *Link version of each button style. (These will be created as they are needed.)

In general a button should never truncate or obscure its contents. This could make it difficult or impossible for a student or teacher to use the site, so in general choose buttons that grow to fit their contents. It is better to risk weird layout than to block users. Might this be a golden rule? Of course there may be exceptions, for example if button content is supplied by an end-user.

Common configs

= Small
| Medium
| Large

Sizes for buttons and links that have button classes

= WidthExact Int
| WidthUnbounded
| WidthFillContainer

Width sizing behavior for buttons.

WidthExact Int defines a size in px for the button's total width, and WidthUnbounded leaves the maxiumum width unbounded (there is a minimum width).

= Primary
| Secondary
| Danger
| Premium

Styleguide-approved styles for your buttons!

= Enabled
| Unfulfilled
| Disabled
| Error
| Loading
| Success

Describes the state of a button. Has consequences for appearance and disabled attribute.

  • Enabled: An enabled button. Takes the appearance of ButtonStyle
  • Unfulfilled: A button which appears with the InactiveColors palette but is not disabled.
  • Disabled: A button which appears with the InactiveColors palette and is disabled.
  • Error: A button which appears with the ErrorColors palette and is disabled.
  • Loading: A button which appears with the LoadingColors palette and is disabled
  • Success: A button which appears with the SuccessColors palette and is disabled

<button> Buttons

{ onClick : msg
, size : ButtonSize
, style : ButtonStyle
, width : ButtonWidth
}
-> { label : String
, state : ButtonState
, icon : Maybe Svg
}
-> Html msg

A delightful button which can trigger an effect when clicked!

This button will trigger the passed-in message if the button state is:

  • Enabled
  • Unfulfilled

This button will be Disabled if the button state is:

  • Disabled
  • Error
  • Loading
  • Success
{ label : String
, onClick : msg
}
-> Html msg

A delete button (blue X)

{ label : String
, onSelect : msg
, onDeselect : msg
, pressed : Bool
}
-> Html msg

A button that can be toggled into a pressed state and back again.

<a> Buttons

(route -> String)
-> (route -> msg)
-> { label : String
, icon : Maybe Svg
, size : ButtonSize
, style : ButtonStyle
, width : ButtonWidth
, route : route
}
-> Html msg

Use this link for routing within a single page app.

This will make a normal <a> tag, but change the Events.onClick behavior to avoid reloading the page.

See https://github.com/elm-lang/html/issues/110 for details on this implementation.

{ label : String
, icon : Maybe Svg
, url : String
, size : ButtonSize
, style : ButtonStyle
, width : ButtonWidth
}
-> Html msg

Wrap some text so it looks like a button, but actually is wrapped in an anchor to some url and have it open to an external site

String
-> { label : String
, icon : Maybe Svg
, url : String
, size : ButtonSize
, style : ButtonStyle
, width : ButtonWidth
}
-> Html msg

Wrap some text so it looks like a button, but actually is wrapped in an anchor to some url, and it's an HTTP request (Rails includes JS to make this use the given HTTP method)

msg
-> { label : String
, icon : Maybe Svg
, url : String
, size : ButtonSize
, style : ButtonStyle
, width : ButtonWidth
}
-> Html msg

Wrap some text so it looks like a button, but actually is wrapped in an anchor to some url. This should only take in messages that result in a Msg that triggers Analytics.trackAndRedirect. For buttons that trigger other effects on the page, please use Nri.Button.button instead

msg
-> { label : String
, icon : Maybe Svg
, url : String
, size : ButtonSize
, style : ButtonStyle
, width : ButtonWidth
}
-> Html msg

Wrap some text so it looks like a button, but actually is wrapped in an anchor to some url and have it open to an external site

This should only take in messages that result in tracking events. For buttons that trigger other effects on the page, please use Nri.Ui.Button.V2.button instead