PhoenixKitWeb.Components.MediaViewer (phoenix_kit v1.7.114)

Copy Markdown View Source

Standalone media lightbox ("slide box") LiveComponent.

Renders a <dialog> modal showing one file from an ordered set, with prev/next navigation (chevrons + ←/→ keys) and Escape/backdrop close. Per-file content (the pan/zoom canvas with annotations + comments thread for images, video/PDF/icon fallback otherwise) is delegated to the shared PhoenixKitWeb.Components.MediaCanvasViewer child LiveComponent — the same one MediaBrowser uses, so admins get the full annotation experience here too.

Reusable on its own or embedded by MediaGallery.

Attrs

  • id — required
  • files — ordered list of file UUIDs (the navigable set)
  • current — initial UUID to show (must be in files). Treated as a seed: once mounted, internal navigation state takes precedence over subsequent current attr changes. This is intentional when the component is mount-gated (:if={...}) so it remounts fresh on each open. A standalone consumer that keeps the component mounted and wants to jump to a different image programmatically must unmount and remount it.
  • current_user — required for the composer / comments thread to render. nil-tolerant (lightbox falls back to view-only).
  • notify — optional {module, id}; see Close below

Close

On close, if notify: {module, id} is set: send_update(module, id: id, media_viewer_closed: true). Otherwise: send(self(), {__MODULE__, id, :closed}).

Summary

Functions

render(assigns)

Callback implementation for Phoenix.LiveComponent.render/1.