Class: VoteFu::LikeButtonComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/vote_fu/like_button_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(voteable:, voter: nil, scope: nil, liked_label: "♥", unliked_label: "♡", show_count: true, variant: :default) ⇒ LikeButtonComponent

Simple like button (upvote only, social media style)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/vote_fu/like_button_component.rb', line 14

def initialize(
  voteable:,
  voter: nil,
  scope: nil,
  liked_label: "♥",
  unliked_label: "♡",
  show_count: true,
  variant: :default
)
  @voteable = voteable
  @voter = voter
  @scope = scope
  @liked_label = liked_label
  @unliked_label = unliked_label
  @show_count = show_count
  @variant = variant
end

Instance Method Details

#callObject



32
33
34
35
36
37
38
39
# File 'app/components/vote_fu/like_button_component.rb', line 32

def call
  tag.div(**wrapper_attributes) do
    safe_join([
      like_button,
      (count_display if @show_count)
    ].compact)
  end
end