Class: ImageComponent

Inherits:
Component show all
Defined in:
app/components/image_component.rb

Overview

Image — image element. Merges the holy spec primitive with Fomantic-UI image.

Usage:

Image(src: "photo.jpg")
Image(src: "avatar.png", avatar: true, size: :mini)
Image(src: "logo.svg", circular: true, centered: true)

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/components/image_component.rb', line 28

def to_s
  classes = class_names(
    "ui",
    size,
    spaced && "#{spaced} spaced",
    { "rounded" => rounded, "circular" => circular, "bordered" => bordered,
      "fluid" => fluid, "avatar" => avatar, "centered" => centered,
      "hidden" => hidden, "disabled" => disabled, "inline" => inline },
    "image"
  )

  opts = { class: classes, src: src, alt: alt }
  opts[:width] = width if width
  opts[:height] = height if height
  opts[:style] = "flex-shrink:0" unless shrink

  tag.img(**opts)
end