Class: HakumiComponents::Image::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Image::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/image/component.rb
Constant Summary collapse
- SizeInput =
T.type_alias { BaseComponent::DimensionInput }
Constants inherited from BaseComponent
BaseComponent::ControllerOptions, BaseComponent::DateInput, BaseComponent::DateLikeValue, BaseComponent::DimensionInput, BaseComponent::HtmlPayloadInput, BaseComponent::I18nOptionValue, BaseComponent::PresenceArray, BaseComponent::PresenceScalar, BaseComponent::PresenceValue, BaseComponent::RawHtmlInput, BaseComponent::SIZES, BaseComponent::SizeValue, BaseComponent::SymbolInput
Instance Attribute Summary collapse
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
-
#preview_src ⇒ Object
readonly
Returns the value of attribute preview_src.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
-
#initialize(src:, alt: nil, width: nil, height: nil, fallback: nil, placeholder: false, preview: true, preview_src: nil, mask_closable: false, **html_options) ⇒ Component
constructor
A new instance of Component.
- #placeholder? ⇒ Boolean
- #preview_enabled? ⇒ Boolean
- #preview_image_src ⇒ Object
Methods inherited from BaseComponent
#append_data_token, boolean_html_param, #build_inline_style, cast_boolean, #cast_boolean, #class_names, #component_classes, #data_attributes_from, #dimension_to_css, #ensure_dom_id!, float_html_param, #generate_id, #html_classes, html_param, html_primitive_param, #html_style, #i18n_scope, integer_html_param, #merge_attributes, #render_value, #size_to_pixels, #stimulus_attrs, string_html_param, string_or_symbol_array_html_param, symbol_html_param, #t_default, #translate_with_default, #validate_inclusion!, #validate_required!, #value_present?
Constructor Details
#initialize(src:, alt: nil, width: nil, height: nil, fallback: nil, placeholder: false, preview: true, preview_src: nil, mask_closable: false, **html_options) ⇒ Component
Returns a new instance of Component.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/components/hakumi_components/image/component.rb', line 25 def initialize( src:, alt: nil, width: nil, height: nil, fallback: nil, placeholder: false, preview: true, preview_src: nil, mask_closable: false, ** ) @src = T.let(src, String) @alt = T.let(alt, T.nilable(String)) @width = T.let(width, SizeInput) @height = T.let(height, SizeInput) @fallback = T.let(fallback, T.nilable(String)) @placeholder = T.let(placeholder, T::Boolean) @preview = T.let(preview, T::Boolean) @preview_src = T.let(preview_src, T.nilable(String)) @mask_closable = T.let(mask_closable, T::Boolean) @html_options = T.let(, Types::HtmlAttributes) end |
Instance Attribute Details
#alt ⇒ Object (readonly)
Returns the value of attribute alt.
53 54 55 |
# File 'app/components/hakumi_components/image/component.rb', line 53 def alt @alt end |
#fallback ⇒ Object (readonly)
Returns the value of attribute fallback.
53 54 55 |
# File 'app/components/hakumi_components/image/component.rb', line 53 def fallback @fallback end |
#preview_src ⇒ Object (readonly)
Returns the value of attribute preview_src.
53 54 55 |
# File 'app/components/hakumi_components/image/component.rb', line 53 def preview_src @preview_src end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
50 51 52 |
# File 'app/components/hakumi_components/image/component.rb', line 50 def src @src end |
Instance Method Details
#placeholder? ⇒ Boolean
66 67 68 |
# File 'app/components/hakumi_components/image/component.rb', line 66 def placeholder? @placeholder end |
#preview_enabled? ⇒ Boolean
56 57 58 |
# File 'app/components/hakumi_components/image/component.rb', line 56 def preview_enabled? @preview end |
#preview_image_src ⇒ Object
61 62 63 |
# File 'app/components/hakumi_components/image/component.rb', line 61 def preview_image_src @preview_src || @src end |