2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/helpers/tipjar_helper.rb', line 2
def tip_jar(options = {})
payment_link = options[:payment_link] || options[:link]
payment_links = options[:payment_links]
use_modal = options[:use_modal] || false
message = options[:message] || options[:button_text] || "Tip Jar"
icon = options[:icon] || :jar
position = options[:position] || :bottom_right
color = options[:color] || "#3b82f6"
text_color = options[:text_color] || "#ffffff"
pulse = options[:pulse] || false
z_index = options[:z_index] || 1000
custom_class = options[:class] || ""
modal_title = options[:modal_title] || "Support my work"
modal_description = options[:modal_description] || "Your support helps me continue creating and maintaining this project."
theme = options[:theme] || :light
custom_amounts = options[:custom_amounts] || [
{ amount: 5, label: "$5", default: false },
{ amount: 10, label: "$10", default: true },
{ amount: 25, label: "$25", default: false },
{ amount: 50, label: "$50", default: false }
]
color = "##{color}" unless color.start_with?('#')
text_color = "##{text_color}" unless text_color.start_with?('#')
if payment_links || use_modal
tipjar_modal_button(
payment_links: payment_links || { default: payment_link },
position: position,
icon: icon,
theme: theme,
button_text: message,
modal_title: modal_title,
modal_description: modal_description,
custom_amounts: custom_amounts,
button_class: custom_class,
z_index: z_index,
color: color,
text_color: text_color,
pulse: pulse
)
elsif payment_link
tipjar_simple_button(
payment_link: payment_link,
message: message,
icon: icon,
position: position,
color: color,
text_color: text_color,
pulse: pulse,
z_index: z_index,
custom_class: custom_class
)
else
raise ArgumentError, "You must provide either :payment_link or :payment_links option to tip_jar helper"
end
end
|