Files
nairobi/app/components/shared/in_favor_against_component.rb
taitus 10cfa0e59f Refactor scss for in favor against component
In order to reduce the code used to add styles to the buttons,
we removed the classes that had been added and handled it with
the new aria-pressed attribute
2023-10-06 18:13:45 +02:00

30 lines
593 B
Ruby

class Shared::InFavorAgainstComponent < ApplicationComponent
attr_reader :votable
delegate :current_user, :votes_percentage, to: :helpers
def initialize(votable)
@votable = votable
end
private
def agree_aria_label
t("votes.agree_label", title: votable.title)
end
def disagree_aria_label
t("votes.disagree_label", title: votable.title)
end
def pressed?(value)
case current_user&.voted_as_when_voted_for(votable)
when true
value == "yes"
when false
value == "no"
else
false
end
end
end