LedgerUI.Components.StepGroup (LedgerUI v0.2.0)

Copy Markdown View Source

A framed card for processes in steps (a build, a deploy, issuing an invoice, an import).

<.step_group id="deploy" title="Deploy logs" status={:running} duration="1m 04s">
  <:step title="Preparing environment" status={:ok} result="12s" />
  <:step title="Updating the stack" status={:running} result="Running…" open>
    <.step_group_line n={1} at="09:41:02" tone="dim">Connecting</.step_group_line>
    <.step_group_line n={2} at="09:41:04" tone="err">Rejected</.step_group_line>
  </:step>
  <:step title="Routing traffic" status={:waiting} result="Waiting" />
</.step_group>

status is one of :ok, :running, :waiting, :failed, :skipped and :canceled.

The content of a :step is its log (step_group_line/1 lines). A step with a log is a <button> that opens and closes the log; a step without one is a plain row. Without a title the card is just the list of steps (no header, nothing to collapse).

Collapsing the card and opening a log happen in the browser (Phoenix.LiveView.JS), with no round trip; collapsed and open set where the state starts.

Summary

Functions

step_group(assigns)

Attributes

  • id (:string) - Required with a title (the collapse button needs it). Defaults to nil.
  • title (:string) - Defaults to nil.
  • status (:atom) - Defaults to :waiting. Must be one of :ok, :running, :waiting, :failed, :skipped, or :canceled.
  • duration (:string) - Defaults to nil.
  • collapsed (:boolean) - Defaults to false.
  • steps (:list) - The steps as data, instead of <:step> slots: maps with :title and optionally :status, :result, :id. (No log: use the slots for that.). Defaults to [].
  • current (:integer) - With steps: the position (from 1) of the step in progress; the ones before it are :ok, the ones after :waiting (unless a step has its own :status). Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • step - One step; its content is its log. Accepts attributes:
    • title (:string)
    • status (:atom)
    • result (:string)
    • open (:boolean)
    • id (:string)
    • class (:any)
    • style (:string)

step_group_line(assigns)

Attributes

  • n (:integer) (required) - The line number.
  • at (:string) - The time of the line. Defaults to nil.
  • tone (:string) - Defaults to nil.Must be one of nil, "dim", "err", or "ok".

Slots

  • inner_block (required)