Files
grecia/app/components/shared/link_list_component.rb
Javi Martín 790170a27c Use keyword arguments in tag methods
The interface of this method has changed and uses keyword arguments
instead of a hash of options. This change will be particularly
significant when upgrading to Ruby 3.
2022-08-24 15:10:36 +02:00

31 lines
574 B
Ruby

class Shared::LinkListComponent < ApplicationComponent
attr_reader :links, :options
def initialize(*links, **options)
@links = links
@options = options
end
def render?
present_links.any?
end
private
def present_links
links.select(&:present?)
end
def list_items
present_links.map do |text, url, current = false, **link_options|
tag.li("aria-current": (true if current)) do
if url
link_to text, url, link_options
else
text
end
end
end
end
end