Class: HakumiComponents::Button::Component

Inherits:
HakumiComponents::BaseComponent show all
Extended by:
T::Sig
Defined in:
app/components/hakumi_components/button/component.rb

Constant Summary collapse

IconValue =
T.type_alias { T.nilable(T.any(String, Symbol, ActiveSupport::SafeBuffer, ViewComponent::Base)) }
TYPES =
T.let([ :primary, :default, :dashed, :text, :link ].freeze, T::Array[Symbol])
SHAPES =
T.let([ :default, :circle, :round ].freeze, T::Array[Symbol])
HTML_TYPES =
T.let([ :button, :submit, :reset ].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

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(type: :default, size: :default, html_type: :button, href: nil, disabled: false, loading: false, danger: false, block: false, icon: nil, shape: :default, **html_options) ⇒ Component

Returns a new instance of Component.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/components/hakumi_components/button/component.rb', line 30

def initialize(
  type: :default,
  size: :default,
  html_type: :button,
  href: nil,
  disabled: false,
  loading: false,
  danger: false,
  block: false,
  icon: nil,
  shape: :default,
  **html_options
)
  @type = type
  @size = size
  @html_type = html_type
  @href = href
  @disabled = T.let(disabled, T::Boolean)
  @loading = T.let(loading, T::Boolean)
  @danger = T.let(danger, T::Boolean)
  @block = T.let(block, T::Boolean)
  @icon = T.let(icon, IconValue)
  @shape = shape
  @html_options = T.let(html_options, Types::HtmlAttributes)

  validate_props!
end

Instance Method Details

#callObject



59
60
61
# File 'app/components/hakumi_components/button/component.rb', line 59

def call
  (tag_name, content_wrapper, wrapper_attributes)
end