Class: PhlexKit::AttachmentMedia

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

Overview

Media slot of an Attachment: variant: :icon (default, a muted tile) or :image (render an inside; fills the slot, full-width when the attachment is vertical). See attachment.rb.

Constant Summary collapse

VARIANTS =
{ icon: nil, image: "image" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(variant: :icon, **attrs) ⇒ AttachmentMedia

Returns a new instance of AttachmentMedia.



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

def initialize(variant: :icon, **attrs)
  @variant = variant.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



13
14
15
# File 'app/components/phlex_kit/attachment/attachment_media.rb', line 13

def view_template(&)
  div(**mix({ class: [ "pk-attachment-media", fetch_option(VARIANTS, @variant, :variant) ].compact.join(" ") }, @attrs), &)
end