Class: PhlexKit::AttachmentAction
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::AttachmentAction
- Defined in:
- app/components/phlex_kit/attachment/attachment_action.rb
Overview
Small ghost icon button in an Attachment (remove/download). Block content
is the icon (defaults to ×). label: renders a pk-sr-only span so the
icon-only button always has an accessible name (default "Remove") —
override it per action, or pass label: nil when supplying your own
aria-label. See attachment.rb.
Instance Method Summary collapse
-
#initialize(label: "Remove", **attrs) ⇒ AttachmentAction
constructor
A new instance of AttachmentAction.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(label: "Remove", **attrs) ⇒ AttachmentAction
Returns a new instance of AttachmentAction.
8 9 10 11 |
# File 'app/components/phlex_kit/attachment/attachment_action.rb', line 8 def initialize(label: "Remove", **attrs) @label = label @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/phlex_kit/attachment/attachment_action.rb', line 13 def view_template(&block) (**mix({ type: :button, class: "pk-attachment-action" }, @attrs)) do if block yield else render Icon.new(:x, size: nil) end span(class: "pk-sr-only") { @label } if @label end end |