Class: HakumiComponents::Card::Meta::Component

Inherits:
BaseComponent
  • Object
show all
Extended by:
T::Sig
Defined in:
app/components/hakumi_components/card/meta/component.rb

Constant Summary

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 Method Summary collapse

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(title: nil, description: nil, avatar: nil, **html_options) ⇒ Component

Returns a new instance of Component.



18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/hakumi_components/card/meta/component.rb', line 18

def initialize(
  title: nil,
  description: nil,
  avatar: nil,
  **html_options
)
  @title = T.let(title, Types::Renderable)
  @description = T.let(description, Types::Renderable)
  @avatar = T.let(avatar, Types::Renderable)
  @html_options = T.let(html_options, Types::HtmlAttributes)
end

Instance Method Details

#avatar_contentObject



36
37
38
# File 'app/components/hakumi_components/card/meta/component.rb', line 36

def avatar_content
  render_value(@avatar)
end

#description_contentObject



46
47
48
# File 'app/components/hakumi_components/card/meta/component.rb', line 46

def description_content
  render_value(@description)
end

#detail_content?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/components/hakumi_components/card/meta/component.rb', line 51

def detail_content?
  title_content.present? || description_content.present?
end

#title_contentObject



41
42
43
# File 'app/components/hakumi_components/card/meta/component.rb', line 41

def title_content
  render_value(@title)
end

#wrapper_attributesObject



31
32
33
# File 'app/components/hakumi_components/card/meta/component.rb', line 31

def wrapper_attributes
  merge_attributes({ class: classes }, @html_options.except(:class))
end