Class: HakumiComponents::FloatButton::Component

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

Constant Summary collapse

IconValue =
T.type_alias { T.nilable(T.any(String, Symbol, ViewComponent::Base, ViewComponent::Slot, ActiveSupport::SafeBuffer)) }
BadgeCount =
T.type_alias { T.nilable(T.any(Integer, Float, String)) }
TYPES =
T.let([ :default, :primary ].freeze, T::Array[Symbol])
SHAPES =
T.let([ :circle, :square ].freeze, T::Array[Symbol])

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(icon: :plus, description: nil, tooltip: nil, href: nil, target: nil, shape: :circle, type: :default, danger: false, badge: nil, floating: true, placement: :bottom_right, offset: nil, button_options: {}, **html_options) ⇒ Component

Returns a new instance of Component.



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
57
58
59
60
61
62
# File 'app/components/hakumi_components/float_button/component.rb', line 32

def initialize(
  icon: :plus,
  description: nil,
  tooltip: nil,
  href: nil,
  target: nil,
  shape: :circle,
  type: :default,
  danger: false,
  badge: nil,
  floating: true,
  placement: :bottom_right,
  offset: nil,
  button_options: {},
  **html_options
)
  @icon = T.let(icon, IconValue)
  @description = T.let(description, T.nilable(String))
  @tooltip = T.let(tooltip, T.nilable(String))
  @href = T.let(href, T.nilable(String))
  @target = T.let(target, T.nilable(String))
  @shape = T.let(shape, Symbol)
  @type = T.let(type, Symbol)
  @danger = T.let(danger, T::Boolean)
  @badge = T.let(badge, T.nilable(Types::HtmlAttributes))
  @position = T.let(HakumiComponents::FloatButton::PositionConfig.new(floating: floating, placement: placement, offset: offset), HakumiComponents::FloatButton::PositionConfig)
  @button_options = T.let(button_options, Types::HtmlAttributes)
  @html_options = T.let(html_options, Types::HtmlAttributes)

  validate_props!
end

Instance Method Details

#callObject



65
66
67
# File 'app/components/hakumi_components/float_button/component.rb', line 65

def call
  wrap_with_badge(float_button_markup)
end