LedgerUI.Components.ErrorPage (LedgerUI v0.2.0)

Copy Markdown View Source

The canvas's error screens: the whole page an ErrorHTML renders (error_page/1), the error inside the app (error_state/1) and the list of links under the actions (error_links/1).

<.error_page code={404} request_id={@request_id}>
  <:brand><b>Acme</b></:brand>
  <:status href="https://status.acme.com">All systems operational</:status>
  <:actions><a class="lu-b c-primary v-solid s-lg" href="/">Back home</a></:actions>
  <.error_links title="Maybe you were looking for">
    <:link navigate="/orders" icon="receipt" description="Every order">Orders</:link>
  </.error_links>
  <:footer><a href="/help">Help center</a></:footer>
</.error_page>

<.error_state code={404} title="Order #2499 not found">
  It may have been deleted or belong to another branch.
</.error_state>

code is the HTTP status (or text, "OFF" for offline). It picks the colour of the big code (tone: neutral 404, error 5xx, warning 403/429/offline, accent 401/419/503) and the English defaults of label, title and description; pass them translated.

The copy button of the request id uses an inline onclick (navigator.clipboard), so it works on a plain ErrorHTML page with no LiveView or hook. back_label adds a history.back() button.

Summary

Functions

error_links(assigns)

Attributes

  • title (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • link (required) - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • icon (:string)
    • description (:string)

error_page(assigns)

Attributes

  • code (:any) (required)
  • tone (:string) - Defaults to nil.Must be one of nil, "", "neutral", "error", "warning", or "accent".
  • label (:string) - Defaults to nil.
  • title (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • request_id (:string) - Defaults to nil.
  • request_id_label (:string) - Defaults to "Request ID".
  • copy_label (:string) - Defaults to "Copy request ID".
  • copy (:boolean) - Defaults to true.
  • back_label (:string) - Defaults to nil.
  • timestamp (:string) - Defaults to nil.
  • id (:string) - Defaults to "error-page".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • actions
  • brand
  • card
  • footer
  • inner_block
  • status - Accepts attributes:
    • href (:string)
    • status (:string)

error_state(assigns)

Attributes

  • code (:any) (required)
  • tone (:string) - Defaults to nil.Must be one of nil, "", "neutral", "error", "warning", or "accent".
  • icon (:string) - Defaults to nil.
  • title (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • id (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • actions
  • inner_block - The description, instead of description.
  • more - Under the actions, full width.