Files
nairobi/app/components/comments/votes_component.rb
taitus 5009bf6c37 Add aria-pressed to in comments votes component
In order to the users using screen readers know whether the button is pressed
or not.
2023-10-06 18:13:45 +02:00

20 lines
367 B
Ruby

class Comments::VotesComponent < ApplicationComponent
attr_reader :comment
delegate :can?, :current_user, to: :helpers
def initialize(comment)
@comment = comment
end
def pressed?(value)
case current_user&.voted_as_when_voted_for(comment)
when true
value == "yes"
when false
value == "no"
else
false
end
end
end