mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
34 lines
822 B
Ruby
34 lines
822 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Components::DropdownItem < Components::Base
|
|
include Phlex::Rails::Helpers::LinkTo
|
|
|
|
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
|
|
|
|
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
|
|
end
|