Class: HakumiComponents::FloatButton::BackTop::Component

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

Constant Summary collapse

DEFAULT_VISIBILITY =
400

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: :vertical_align_top, tooltip: "Back to top", visibility_height: DEFAULT_VISIBILITY, target_selector: nil, floating: true, placement: :bottom_right, offset: nil, button_options: {}, **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
# File 'app/components/hakumi_components/float_button/back_top/component.rb', line 25

def initialize(
  icon: :vertical_align_top,
  tooltip: "Back to top",
  visibility_height: DEFAULT_VISIBILITY,
  target_selector: nil,
  floating: true,
  placement: :bottom_right,
  offset: nil,
  button_options: {},
  **html_options
)
  @icon = T.let(icon, HakumiComponents::FloatButton::Component::IconValue)
  @tooltip = T.let(tooltip, String)
  @visibility_height = T.let(visibility_height, Integer)
  @target_selector = T.let(target_selector, T.nilable(String))
  @floating = T.let(floating, T::Boolean)
  @placement = T.let(placement, Symbol)
  @offset = T.let(offset, T.nilable(HakumiComponents::FloatButton::PositionConfig::OffsetMap))
  @button_options = T.let(button_options, Types::HtmlAttributes)
  @html_options = T.let(html_options, Types::HtmlAttributes)
end

Instance Method Details

#callObject



48
49
50
51
52
53
54
55
56
57
58
# File 'app/components/hakumi_components/float_button/back_top/component.rb', line 48

def call
  render HakumiComponents::FloatButton::Component.new(
    icon: @icon,
    tooltip: @tooltip,
    floating: @floating,
    placement: @placement,
    offset: @offset,
    button_options: back_top_button_options,
    **back_top_html_options
  )
end