2021-04-07 05:09:06 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
class MenuItem
|
2021-12-13 19:14:57 -05:00
|
|
|
include ::Sidebars::Concerns::LinkWithHtmlOptions
|
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
attr_reader :title, :link, :active_routes, :item_id, :container_html_options, :sprite_icon, :sprite_icon_html_options, :hint_html_options
|
2021-04-07 05:09:06 -04:00
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
def initialize(title:, link:, active_routes:, item_id: nil, container_html_options: {}, sprite_icon: nil, sprite_icon_html_options: {}, hint_html_options: {})
|
|
|
|
@title = title
|
|
|
|
@link = link
|
|
|
|
@active_routes = active_routes
|
|
|
|
@item_id = item_id
|
2021-04-26 08:09:44 -04:00
|
|
|
@container_html_options = { aria: { label: title } }.merge(container_html_options)
|
2021-04-23 08:09:52 -04:00
|
|
|
@sprite_icon = sprite_icon
|
|
|
|
@sprite_icon_html_options = sprite_icon_html_options
|
|
|
|
@hint_html_options = hint_html_options
|
|
|
|
end
|
2021-04-07 05:09:06 -04:00
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
def show_hint?
|
|
|
|
hint_html_options.present?
|
2021-04-07 05:09:06 -04:00
|
|
|
end
|
2021-05-10 14:10:41 -04:00
|
|
|
|
|
|
|
def render?
|
|
|
|
true
|
|
|
|
end
|
2021-06-04 11:10:25 -04:00
|
|
|
|
|
|
|
def nav_link_html_options
|
|
|
|
{
|
|
|
|
data: {
|
|
|
|
track_label: item_id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2021-04-07 05:09:06 -04:00
|
|
|
end
|
|
|
|
end
|