Files
grecia/app/components/sdg_management/subnavigation_component.rb
Senén Rodero Rodríguez e9d52b5e11 Add subnavigation component to targets and goals
Add a new SDG component to make easier to create subnavigation menus.

Co-Authored-By: Javi Martín <35156+javierm@users.noreply.github.com>
2020-12-04 15:15:32 +01:00

31 lines
627 B
Ruby

class SDGManagement::SubnavigationComponent < ApplicationComponent
attr_reader :current
def initialize(current:)
@current = current
end
private
def sections
%i[goals targets]
end
def link_to_section(section)
link_to "SDG::#{section.to_s.classify}".constantize.model_name.human(count: 2).titleize,
path_for(section),
class: active_style(section)
end
def path_for(section)
{
controller: "sdg_management/#{section}",
action: :index
}
end
def active_style(section)
"is-active" if section == current
end
end