PhoenixKit.Modules.Comments.Web.CommentsComponent (phoenix_kit v1.7.71)

Copy Markdown View Source

Reusable LiveComponent for displaying and managing comments on any resource.

Usage

<.live_component
  module={PhoenixKit.Modules.Comments.Web.CommentsComponent}
  id={"comments-#{@post.uuid}"}
  resource_type="post"
  resource_uuid={@post.uuid}
  current_user={@current_user}
/>

Required Attrs

  • resource_type - String identifying the resource type (e.g., "post")
  • resource_uuid - UUID of the resource
  • current_user - Current authenticated user struct
  • id - Unique component ID

Optional Attrs

  • enabled - Whether comments are enabled (default: true)
  • show_likes - Show like/dislike buttons (default: false)
  • title - Section title (default: "Comments")

Parent Notifications

After create/delete, sends to the parent LiveView:

{:comments_updated, %{resource_type: "post", resource_uuid: uuid, action: :created | :deleted}}

Summary

Functions

render(assigns)

Callback implementation for Phoenix.LiveComponent.render/1.

render_comment(assigns)

Attributes

  • comment (:map) (required)
  • current_user (:map) (required)
  • myself (:any) (required)