Class: Keystone::Ui::NavDropdownComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/keystone/ui/nav_dropdown_component.rb

Constant Summary collapse

WRAPPER_CLASSES =
"nav-dropdown"
"nav-dropdown-menu hidden"
TRIGGER_BASE =
"nav-dropdown-trigger"
ACTIVE_CLASS =
"active"
CARET_ICON =
<<~SVG.freeze
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="nav-dropdown-caret">
    <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
  </svg>
SVG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, area:, active: false) ⇒ NavDropdownComponent

Returns a new instance of NavDropdownComponent.



18
19
20
21
22
# File 'app/components/keystone/ui/nav_dropdown_component.rb', line 18

def initialize(title:, area:, active: false)
  @title = title
  @area = area
  @active = active
end

Instance Attribute Details

#areaObject (readonly)

Returns the value of attribute area.



16
17
18
# File 'app/components/keystone/ui/nav_dropdown_component.rb', line 16

def area
  @area
end

#titleObject (readonly)

Returns the value of attribute title.



16
17
18
# File 'app/components/keystone/ui/nav_dropdown_component.rb', line 16

def title
  @title
end

Instance Method Details

#trigger_classesObject



24
25
26
# File 'app/components/keystone/ui/nav_dropdown_component.rb', line 24

def trigger_classes
  [ TRIGGER_BASE, (ACTIVE_CLASS if @active) ].compact.join(" ")
end

#wrapper_dataObject



28
29
30
# File 'app/components/keystone/ui/nav_dropdown_component.rb', line 28

def wrapper_data
  { controller: "dropdown" }
end