inlay/component

A single universal Lustre component for every inlay provider.

Register one custom element, <inlay-embed url="…">, that auto-detects the provider from its url attribute and renders the matching embed. Configure it imperatively with configure (or register for the default configuration) from a browser main, then use the tag in your markup or the embed_element helper in a Lustre view.

Registration only takes effect in the browser; on other targets register returns lustre.NotABrowser and embed_element still serialises to the plain custom-element tag.

Types

The decoded attributes of an <inlay-embed> element together with the state of any in-flight Bluesky handle resolution. The base Config is captured in the component closure, not stored here.

pub type Model {
  Model(
    url: option.Option(String),
    no_cookie: option.Option(Bool),
    parent: option.Option(String),
    aspect_ratio: option.Option(String),
    state: Resolution,
  )
}

Constructors

A change to one of an <inlay-embed> element’s attributes, or the result of a Bluesky handle resolution.

pub type Msg {
  UrlChanged(url: String)
  NoCookieChanged(no_cookie: Bool)
  ParentChanged(parent: String)
  AspectRatioChanged(aspect_ratio: String)
  GotDid(result: Result(String, rsvp.Error(String)))
}

Constructors

  • UrlChanged(url: String)
  • NoCookieChanged(no_cookie: Bool)
  • ParentChanged(parent: String)
  • AspectRatioChanged(aspect_ratio: String)
  • GotDid(result: Result(String, rsvp.Error(String)))

State of the handle-to-DID resolution for a Bluesky embed.

pub type Resolution {
  Static
  Resolving
  Resolved(did: String)
  Failed
}

Constructors

  • Static
  • Resolving
  • Resolved(did: String)
  • Failed

Values

pub fn configure(
  config: embed.Config,
) -> Result(Nil, lustre.Error)

Register <inlay-embed> with the given base configuration. Call this once from a browser main before rendering any <inlay-embed> tags.

Registration is browser-only; on other targets it returns lustre.NotABrowser. Calling it more than once yields lustre.ComponentAlreadyRegistered.

pub fn embed_component(
  config: embed.Config,
) -> lustre.App(Nil, Model, Msg)

The <inlay-embed> component configured with the given base config.

The config is captured in the component’s update/view closures. Pass it to lustre.register (see configure) or run it as a server component.

pub fn embed_element(
  attributes: List(attribute.Attribute(msg)),
) -> element.Element(msg)

Render the <inlay-embed> custom-element tag with the given attributes.

pub fn init(args: Nil) -> #(Model, effect.Effect(Msg))

Initialise the component model before any attribute has been received.

pub const name: String

The custom element tag for the universal embed component.

pub fn register() -> Result(Nil, lustre.Error)

Register <inlay-embed> with the default configuration.

pub fn update(
  config: embed.Config,
  model: Model,
  msg: Msg,
) -> #(Model, effect.Effect(Msg))

Advance the component model in response to a message, using config as the base configuration before per-embed overrides are applied.

pub fn view(
  config: embed.Config,
  model: Model,
) -> element.Element(msg)

Render the current component model to HTML, using config as the base configuration before per-embed overrides are applied.

Search Document