Class: Bs5::DropdownComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ComponentsHelper, ViewComponent::SlotableV2
Defined in:
app/components/bs5/dropdown_component.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

CLASS_PREFIX =
'dropdown'
CLASS_NAMES =
{
  visually_hidden: 'visually-hidden',
  toggle_split: "#{CLASS_PREFIX}-toggle-split",
  toggle: "#{CLASS_PREFIX}-toggle",
  menu: "#{CLASS_PREFIX}-menu",
  menu_dark: "#{CLASS_PREFIX}-menu-dark",
  menu_end: "#{CLASS_PREFIX}-menu-end"
}.freeze
DIRECTIONS =
{
  up: :dropup,
  end: :dropend,
  start: :dropstart
}.with_indifferent_access.freeze
%i[offset flip boundary reference display].freeze

Constants included from ComponentsHelper

ComponentsHelper::COMPONENTS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComponentsHelper

#bs5_collapse, #bs5_popover, #bs5_tooltip

Constructor Details

#initialize(content_or_options = nil, options = {}) ⇒ DropdownComponent

Returns a new instance of DropdownComponent.



28
29
30
31
32
33
34
35
36
37
# File 'app/components/bs5/dropdown_component.rb', line 28

def initialize(content_or_options = nil, options = {})
  if content_or_options.is_a? Hash
    @options = content_or_options.symbolize_keys
  else
    @title = content_or_options
    @options = options.symbolize_keys
  end

  extract_options
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



26
27
28
# File 'app/components/bs5/dropdown_component.rb', line 26

def title
  @title
end