Skip to content

About

Phoenix LiveView components that render a riddler Journey: unstyled semantic HTML, one component per node kind, and a Journey component that asks the host's access module before every step

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

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, button, group and row - 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.3.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. A host that passes the optional re_present function has the screen drawn again as the visitor types, so a button a same-screen condition reveals can be pressed.

The markup is plain semantic HTML with a class and stable data-riddler-* attributes on every component, and no styling. One opt-in stylesheet, priv/static/riddler_live_view.css, sets a row's elements side by side and nothing else; the markup is the same without it.

Documentation

Compatibility

RiddlerLiveView needs Elixir 1.18 or later (elixir: "~> 1.18"). It has two runtime dependencies: riddler ~> 0.10, 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.

About

Phoenix LiveView components that render a riddler Journey: unstyled semantic HTML, one component per node kind, and a Journey component that asks the host's access module before every step

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages