20 lines
570 B
Ruby
20 lines
570 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DropdownLinkComponent < ViewComponent::Base
|
|
def initialize(href:, open_in_new_tab: false, separator: false, add_class: nil)
|
|
@href = href
|
|
@target = open_in_new_tab ? "_blank" : nil
|
|
@class = class_str(separator, add_class)
|
|
end
|
|
|
|
private
|
|
|
|
def class_str(separator, add_class)
|
|
str = "no-underline block px-5 py-3 text-sm text-gray-900 bg-white
|
|
hover:bg-gray-100 focus:bg-gray-100 whitespace-no-wrap"
|
|
str = "#{str} border-t" if separator
|
|
str = "#{str} #{add_class}" if add_class
|
|
str
|
|
end
|
|
end
|