Class: Keystone::Ui::NavDropdownComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::NavDropdownComponent
- Defined in:
- app/components/keystone/ui/nav_dropdown_component.rb
Constant Summary collapse
- WRAPPER_CLASSES =
"nav-dropdown"- MENU_CLASSES =
"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
-
#area ⇒ Object
readonly
Returns the value of attribute area.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title:, area:, active: false) ⇒ NavDropdownComponent
constructor
A new instance of NavDropdownComponent.
- #trigger_classes ⇒ Object
- #wrapper_data ⇒ Object
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
#area ⇒ Object (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 |
#title ⇒ Object (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_classes ⇒ Object
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_data ⇒ Object
28 29 30 |
# File 'app/components/keystone/ui/nav_dropdown_component.rb', line 28 def wrapper_data { controller: "dropdown" } end |