Class: PhlexKit::AttachmentAction

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/attachment/attachment_action.rb

Overview

Small ghost icon button in an Attachment (remove/download). Give it an aria-label; block content is the icon (defaults to ×). See attachment.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ AttachmentAction

Returns a new instance of AttachmentAction.



5
6
7
# File 'app/components/phlex_kit/attachment/attachment_action.rb', line 5

def initialize(**attrs)
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/components/phlex_kit/attachment/attachment_action.rb', line 9

def view_template(&block)
  button(**mix({ type: :button, class: "pk-attachment-action" }, @attrs)) do
    if block
      yield
    else
      render Icon.new(:x, size: nil)
    end
  end
end