Class: Ariadne::ImageComponent
- Defined in:
- app/components/ariadne/image_component.rb
Overview
Use Image to render images.
Constant Summary collapse
- DEFAULT_TAG =
:img
Constants inherited from Component
Component::BASE_BODY_CLASSES, Component::BASE_HTML_CLASSES, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS
Constants included from ActionViewExtensions::FormHelper
ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag: DEFAULT_TAG, src:, alt:, lazy: false, classes: "", attributes: {}) ⇒ ImageComponent
constructor
A new instance of ImageComponent.
Methods included from ActionViewExtensions::FormHelper
Methods included from ClassNameHelper
Methods included from LoggerHelper
#logger, #silence_deprecations?, #silence_warnings?
Methods included from FetchOrFallbackHelper
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer
Constructor Details
#initialize(tag: DEFAULT_TAG, src:, alt:, lazy: false, classes: "", attributes: {}) ⇒ ImageComponent
Returns a new instance of ImageComponent.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/components/ariadne/image_component.rb', line 33 def initialize(tag: DEFAULT_TAG, src:, alt:, lazy: false, classes: "", attributes: {}) @attributes = attributes @src = src @tag = check_incoming_tag(DEFAULT_TAG, tag) @classes = classes @attributes[:alt] = alt @attributes[:src] = image_path(@src) return unless lazy @attributes[:loading] = :lazy @attributes[:decoding] = :async end |
Instance Method Details
#call ⇒ Object
49 50 51 |
# File 'app/components/ariadne/image_component.rb', line 49 def call render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) end |