Class: HakumiComponents::Badge::Component
- Inherits:
-
HakumiComponents::BaseComponent
- Object
- ViewComponent::Base
- HakumiComponents::BaseComponent
- HakumiComponents::Badge::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/badge/component.rb
Constant Summary collapse
- Status =
T.type_alias { T.nilable(T.any(Symbol, String)) }
- Count =
T.type_alias { T.nilable(T.any(Integer, Float, String)) }
- IconName =
T.type_alias { T.nilable(T.any(Symbol, String)) }
- STATUSES =
T.let(%i[success processing default error warning].freeze, T::Array[Symbol])
Constants inherited from HakumiComponents::BaseComponent
HakumiComponents::BaseComponent::ControllerOptions, HakumiComponents::BaseComponent::DateInput, HakumiComponents::BaseComponent::DateLikeValue, HakumiComponents::BaseComponent::DimensionInput, HakumiComponents::BaseComponent::HtmlPayloadInput, HakumiComponents::BaseComponent::I18nOptionValue, HakumiComponents::BaseComponent::PresenceArray, HakumiComponents::BaseComponent::PresenceScalar, HakumiComponents::BaseComponent::PresenceValue, HakumiComponents::BaseComponent::RawHtmlInput, HakumiComponents::BaseComponent::SIZES, HakumiComponents::BaseComponent::SizeValue, HakumiComponents::BaseComponent::SymbolInput
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(count: nil, dot: false, overflow_count: 99, status: nil, text: nil, color: nil, show_zero: false, icon: nil, **html_options) ⇒ Component
constructor
A new instance of Component.
- #wrapper_attributes ⇒ Object
Methods inherited from HakumiComponents::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(count: nil, dot: false, overflow_count: 99, status: nil, text: nil, color: nil, show_zero: false, icon: nil, **html_options) ⇒ Component
Returns a new instance of Component.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/hakumi_components/badge/component.rb', line 28 def initialize(count: nil, dot: false, overflow_count: 99, status: nil, text: nil, color: nil, show_zero: false, icon: nil, **) @count = T.let(count, Count) @dot = T.let(cast_boolean(dot) ? true : false, T::Boolean) @overflow_count = T.let(overflow_count, Integer) @status = T.let(status&.to_sym, T.nilable(Symbol)) @text = T.let(text, T.nilable(String)) @color = T.let(color, T.nilable(String)) @show_zero = T.let(cast_boolean(show_zero) ? true : false, T::Boolean) @icon = T.let(icon, IconName) @html_options = T.let(, Types::HtmlAttributes) validate_props! end |
Instance Method Details
#call ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'app/components/hakumi_components/badge/component.rb', line 43 def call content_tag(:span, wrapper_attributes) do safe_join([ content, badge_element, status_text_element ].compact) end end |
#wrapper_attributes ⇒ Object
54 55 56 |
# File 'app/components/hakumi_components/badge/component.rb', line 54 def wrapper_attributes merge_attributes({ class: wrapper_classes }, @html_options.except(:class)) end |