Class: Ariadne::ImageComponent
- Defined in:
- app/components/ariadne/image_component.rb
Overview
Use ‘Image` to render images.
Constant Summary
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag: :img, src:, alt:, lazy: false, classes: "", attributes: {}) ⇒ ImageComponent
constructor
A new instance of ImageComponent.
Methods included from LoggerHelper
#logger, #silence_deprecations?, #silence_warnings?
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean
Methods included from ClassNameHelper
Constructor Details
#initialize(tag: :img, src:, alt:, lazy: false, classes: "", attributes: {}) ⇒ ImageComponent
Returns a new instance of ImageComponent.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/ariadne/image_component.rb', line 31 def initialize(tag: :img, src:, alt:, lazy: false, classes: "", attributes: {}) @attributes = attributes @src = src @tag = check_incoming_tag(:img, 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
47 48 49 |
# File 'app/components/ariadne/image_component.rb', line 47 def call render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) end |