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
- Do
- Render a Journey in a LiveView: write the host and access modules, embed
RiddlerLiveView.Journey, and see what the visitor is shown. - Scope a Path to who may see it: start a Journey under a scope, check it against the Path's kind, and say who belongs to it.
- Draw an element of your own kind: register a component for a kind the package does not draw, and see what a screen with an undrawn kind does.
- Offer an authored skip: author a button that leaves a screen unfinished, and let the host honour it.
- Render a Journey in a LiveView: write the host and access modules, embed
- Look up
RiddlerLiveView.Journey: every assign, what is drawn, who may see a Journey, and what a submit carries.RiddlerLiveView.Components: the frame, each element's component, the findings and thedata-riddler-*attributes.- The changelog: what changed in each version.
- Riddler: the package whose answers this one renders.
- Understand
- The decision record: why the package renders what riddler presents, owns no state and steps nothing.
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.