Class: HakumiComponents::Carousel::Component

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

Constant Summary collapse

EFFECTS =
T.let(%i[scrollx fade].freeze, T::Array[Symbol])
DOT_PLACEMENTS =
T.let(%i[top bottom start end].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(autoplay: false, autoplay_speed: 3000, dot_placement: :bottom, dots: true, dots_class: nil, arrows: false, adaptive_height: false, draggable: false, infinite: true, fade: nil, effect: :scrollx, speed: 500, easing: "linear", wait_for_animate: false, **html_options) ⇒ Component

Returns a new instance of Component.



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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/components/hakumi_components/carousel/component.rb', line 33

def initialize(
  autoplay: false,
  autoplay_speed: 3000,
  dot_placement: :bottom,
  dots: true,
  dots_class: nil,
  arrows: false,
  adaptive_height: false,
  draggable: false,
  infinite: true,
  fade: nil,
  effect: :scrollx,
  speed: 500,
  easing: "linear",
  wait_for_animate: false,
  **html_options
)
  @autoplay_config = T.let(
    HakumiComponents::Carousel::AutoplayConfig.coerce(autoplay),
    HakumiComponents::Carousel::AutoplayConfig
  )
  @autoplay_speed = T.let(autoplay_speed, Integer)

  resolved_fade = if fade.nil?
    effect == :fade
  else
    effect = fade ? :fade : :scrollx
    fade
  end

  @dots_config = T.let(
    HakumiComponents::Carousel::DotsConfig.coerce(dots, override_class_name: dots_class),
    HakumiComponents::Carousel::DotsConfig
  )

  @dot_placement = T.let(dot_placement, Symbol)
  @arrows = T.let(arrows, T::Boolean)
  @adaptive_height = T.let(adaptive_height, T::Boolean)
  @draggable = T.let(draggable, T::Boolean)
  @infinite = T.let(infinite, T::Boolean)
  @fade = T.let(resolved_fade, T::Boolean)
  @effect = T.let(effect, Symbol)
  @speed = T.let(speed, Integer)
  @easing = T.let(easing, String)
  @wait_for_animate = T.let(wait_for_animate, T::Boolean)
  @html_options = T.let(html_options, Types::HtmlAttributes)

  validate_props!
end