Files
nairobi/app/components/sdg/goals/show_component.rb
Javi Martín 1e7517d1f6 Extract components to edit and add cards
This way we'll be able to reuse it in the SDG Management section while
reusing the `title` method to set the page title.
2021-01-14 17:38:01 +01:00

26 lines
528 B
Ruby

class SDG::Goals::ShowComponent < ApplicationComponent
attr_reader :goal
def initialize(goal)
@goal = goal
end
def feeds
SDG::Widget::Feed.for_goal(goal)
end
private
def processes_feed
feeds.find { |feed| feed.kind == "processes" }
end
def heading
safe_join([tag.span(goal.code, class: "goal-code"), tag.span(split_title, class: "goal-title")], " ")
end
def split_title
safe_join(goal.title_in_two_lines.split("\n").map { |text| tag.span(text) }, " ")
end
end