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
18
19
20
21
22
# 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
      svg(xmlns: "http://www.w3.org/2000/svg", viewbox: "0 0 24 24", fill: "none",
          stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round",
          "stroke-linejoin": "round", "aria-hidden": "true") do |s|
        s.path(d: "M18 6 6 18")
        s.path(d: "m6 6 12 12")
      end
    end
  end
end