rails_tipjar 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/helpers/tipjar_helper.rb +69 -7
- data/lib/rails_tipjar/version.rb +1 -1
- data/rails_tipjar-0.1.0.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b20cb8427d06b557ced9867853f9acd14b7ba74cac80de9207316dd8f6cdb2ee
|
4
|
+
data.tar.gz: a89f5d9936f3efa1f714df6a56b542988709b8a6e99e96478b1f2f70d4713bfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77a0e7430424741d748ea350bf629c1a92ccbf743649d6f45709e0e9767980a113206f171313a14548813948b992372d22ca57d2081ea92c2b2d4b63d5ff1e1b
|
7
|
+
data.tar.gz: cad8649848b878a8d26796a4fa29760d51e71ff1576d1bc09128d0de77bc784d65230ecf3830b6315bd864b5e53204e008d6a9335c8e7b2c0f3d78a9181e4aab
|
@@ -6,20 +6,32 @@ module TipjarHelper
|
|
6
6
|
custom_class = options[:class] || config.button_class
|
7
7
|
z_index = options[:z_index] || config.z_index
|
8
8
|
|
9
|
+
# Inject CSS styles into the page once
|
10
|
+
tipjar_styles + tipjar_button_html(config, position, custom_class, z_index)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def tipjar_button_html(config, position, custom_class, z_index)
|
9
16
|
# Simple direct link mode when payment_link is set
|
10
17
|
if config.payment_link && !config.use_modal
|
18
|
+
position_style = position_inline_styles(position)
|
19
|
+
button_style = "#{position_style} z-index: #{z_index}; display: flex; align-items: center; padding: 0.75rem 1rem; background-color: #3b82f6; color: white; border-radius: 9999px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; cursor: pointer; border: none; font-size: 0.875rem; font-weight: 500; text-decoration: none; animation: tipjar-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;"
|
20
|
+
|
11
21
|
link_to config.payment_link,
|
12
22
|
target: "_blank",
|
13
23
|
rel: "noopener",
|
14
|
-
class: "tipjar-button #{
|
15
|
-
style:
|
16
|
-
|
24
|
+
class: "tipjar-button #{custom_class}",
|
25
|
+
style: button_style,
|
26
|
+
onmouseover: "this.style.backgroundColor='#2563eb'; this.style.transform='scale(1.05)'; this.querySelector('.tipjar-button-text').style.maxWidth='200px'; this.querySelector('.tipjar-button-text').style.marginLeft='0.5rem';",
|
27
|
+
onmouseout: "this.style.backgroundColor='#3b82f6'; this.style.transform='scale(1)'; this.querySelector('.tipjar-button-text').style.maxWidth='0'; this.querySelector('.tipjar-button-text').style.marginLeft='0';" do
|
28
|
+
content_tag(:span, style: "display: flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem;") do
|
17
29
|
raw config.icon_svg
|
18
30
|
end +
|
19
|
-
content_tag(:span, config.button_text, class: "tipjar-button-text")
|
31
|
+
content_tag(:span, config.button_text, class: "tipjar-button-text", style: "white-space: nowrap; max-width: 0; overflow: hidden; transition: all 0.3s ease; margin-left: 0;")
|
20
32
|
end
|
21
33
|
else
|
22
|
-
# Original modal mode
|
34
|
+
# Original modal mode - would need more work to be fully inline
|
23
35
|
content_tag :div,
|
24
36
|
class: "tipjar-container",
|
25
37
|
data: {
|
@@ -41,6 +53,58 @@ module TipjarHelper
|
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
56
|
+
def tipjar_styles
|
57
|
+
return "" if @tipjar_styles_injected
|
58
|
+
@tipjar_styles_injected = true
|
59
|
+
|
60
|
+
content_tag :style do
|
61
|
+
<<~CSS.html_safe
|
62
|
+
@keyframes tipjar-pulse {
|
63
|
+
0%, 100% { opacity: 1; }
|
64
|
+
50% { opacity: 0.8; }
|
65
|
+
}
|
66
|
+
|
67
|
+
@keyframes tipjar-coin-drop {
|
68
|
+
0% {
|
69
|
+
transform: translateY(0) rotate(0deg);
|
70
|
+
opacity: 0;
|
71
|
+
}
|
72
|
+
20% {
|
73
|
+
opacity: 1;
|
74
|
+
}
|
75
|
+
80% {
|
76
|
+
transform: translateY(7px) rotate(180deg);
|
77
|
+
opacity: 1;
|
78
|
+
}
|
79
|
+
100% {
|
80
|
+
transform: translateY(9px) rotate(180deg);
|
81
|
+
opacity: 0;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
.tipjar-coin-animation {
|
86
|
+
animation: tipjar-coin-drop 2s ease-in-out infinite;
|
87
|
+
transform-origin: center;
|
88
|
+
}
|
89
|
+
CSS
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def position_inline_styles(position)
|
94
|
+
case position
|
95
|
+
when :bottom_right
|
96
|
+
"position: fixed; bottom: 1rem; right: 1rem;"
|
97
|
+
when :bottom_left
|
98
|
+
"position: fixed; bottom: 1rem; left: 1rem;"
|
99
|
+
when :top_right
|
100
|
+
"position: fixed; top: 1rem; right: 1rem;"
|
101
|
+
when :top_left
|
102
|
+
"position: fixed; top: 1rem; left: 1rem;"
|
103
|
+
else
|
104
|
+
"position: fixed; bottom: 1rem; right: 1rem;"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
44
108
|
def tipjar_link(text = nil, options = {})
|
45
109
|
config = RailsTipjar.config
|
46
110
|
text ||= config.button_text
|
@@ -74,8 +138,6 @@ module TipjarHelper
|
|
74
138
|
}
|
75
139
|
end
|
76
140
|
|
77
|
-
private
|
78
|
-
|
79
141
|
def config_position_classes(position)
|
80
142
|
case position
|
81
143
|
when :bottom_right
|
data/lib/rails_tipjar/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_tipjar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Paulson
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/rails_tipjar/configuration.rb
|
61
61
|
- lib/rails_tipjar/engine.rb
|
62
62
|
- lib/rails_tipjar/version.rb
|
63
|
+
- rails_tipjar-0.1.0.gem
|
63
64
|
- sig/rails_tipjar.rbs
|
64
65
|
homepage: https://github.com/justinpaulson/rails_tipjar
|
65
66
|
licenses: []
|