Class: PhlexKit::AttachmentTrigger

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

Overview

Full-card overlay that activates the attachment (a preview link or dialog trigger). Sits BEHIND AttachmentActions in the stacking order, so actions stay independently clickable. Give it an aria-label; pass as: :a + href: for a link. See attachment.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(as: :button, href: nil, **attrs) ⇒ AttachmentTrigger

Returns a new instance of AttachmentTrigger.



7
8
9
10
11
# File 'app/components/phlex_kit/attachment/attachment_trigger.rb', line 7

def initialize(as: :button, href: nil, **attrs)
  @as = as.to_sym
  @href = href
  @attrs = attrs
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
# File 'app/components/phlex_kit/attachment/attachment_trigger.rb', line 13

def view_template
  base = { class: "pk-attachment-trigger" }
  if @as == :a
    a(**mix(base.merge(href: @href), @attrs))
  else
    button(**mix(base.merge(type: :button), @attrs))
  end
end