RiddlerLiveView

RiddlerLiveView renders what Riddler presents as Phoenix LiveView. Riddler answers what one visitor sees at one step of a Journey; this package turns that answer into plain semantic HTML: a function component for each element kind and one LiveComponent a host embeds.

Why RiddlerLiveView

A host that presents a Journey in LiveView would otherwise write the same markup for every question, button and message, and keep it in step with Riddler's vocabulary by hand. Putting that markup in one package keeps a patron-registration screen looking the same wherever it is embedded, and keeps the host to what is its own: who may see a Journey, where it runs and what happens when a visitor submits.

The package carries the screen's frame, a component for each element kind riddler presents - heading, text, image, divider, link, text question, secret question, choice question, boolean question and button - the Back control, findings drawn beside the questions they name, and RiddlerLiveView.Journey, the LiveComponent that shows a Journey.

Installation

Add riddler_live_view to your list of dependencies in mix.exs:

def deps do
  [
    {:riddler_live_view, "~> 0.1.0"}
  ]
end

Pre-1.0. The public API is still moving, and a minor version may break it. Pinning to an exact minor - ~> X.Y.0 - is the recommended way to consume it until 1.0.

Basic usage

Embed a patron's registration Journey in a LiveView, naming the Journey and the host's modules implementing Riddler.Journey.Host and Riddler.Journey.Access:

<.live_component
  module={RiddlerLiveView.Journey}
  id="registration"
  journey={@journey}
  host={Library.RegistrationHost}
  access={Library.PatronAccess}
  actor={@patron_id}
/>

The component asks the host where the Journey is, draws the screen, and hands the host each submit and back request; the host's engine steps the Journey.

The markup is plain semantic HTML with a class and stable data-riddler-* attributes on every component; the package ships no stylesheet.

Documentation

Compatibility

RiddlerLiveView needs Elixir 1.18 or later (elixir: "~> 1.18"). It has two runtime dependencies: riddler ~> 0.9, which presents each step of a Journey, and phoenix_live_view ~> 1.2, which renders it. Nothing in the statifier family is a dependency: a host wires its execution engine to this package, never the reverse.

License

MIT. See LICENSE.