Class: Components::DropdownItem
- Inherits:
-
Base
- Object
- Base
- Components::DropdownItem
- Includes:
- Phlex::Rails::Helpers::LinkTo
- Defined in:
- app/components/dropdown_item.rb
Instance Method Summary collapse
-
#initialize(label:, path:, icon: nil, method: nil, aria_label: nil, confirm: nil, active: false) ⇒ DropdownItem
constructor
A new instance of DropdownItem.
- #view_template ⇒ Object
Constructor Details
#initialize(label:, path:, icon: nil, method: nil, aria_label: nil, confirm: nil, active: false) ⇒ DropdownItem
Returns a new instance of DropdownItem.
6 7 8 9 10 11 12 13 14 |
# File 'app/components/dropdown_item.rb', line 6 def initialize(label:, path:, icon: nil, method: nil, aria_label: nil, confirm: nil, active: false) @icon = icon @label = label @path = path @method = method @aria_label = aria_label @confirm = confirm @active = active end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/components/dropdown_item.rb', line 16 def view_template li role: "presentation" do link_to @path, method: @method, class: "dropdown-item #{"active" if @active}", role: "menuitem", aria: {label: @aria_label, current: @active.to_s}, data: {confirm: @confirm}, rel: "nofollow" do if @icon Icon(icon: @icon, label: @label) whitespace end span { @label } end end end |