rails_tipjar 0.1.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a942f0f33f3ae7a78eda233a1dff1ce1a883a144ac1cad2a31e9849f212b708
4
- data.tar.gz: f00214075a3e9008ddc7aa9b85d46caca6a6792ebbc185407c5dae07ccc114f8
3
+ metadata.gz: eb45f6dbcb30df4e79a71f533760d0fa1c5d2a904c0065ae774c675998d19585
4
+ data.tar.gz: c0f1ea549ffb2fb0fbd3f48b36e81621697de38af2e622aa57eaec01d0c61cca
5
5
  SHA512:
6
- metadata.gz: 7a437aedf1dd798d8bb7e76d364236f19c80b1ee3295c72df64477cbaa1ed1f4e51f494a32e5a53da8fa86fd42a7376dc7c53110e916fcd24020f9d6c6739819
7
- data.tar.gz: 38d10e40392878cf99f43ed646a41401630f97340b97145b02b49ce9a48d8b49a716d5c4c2cb4bf1d59d873614cf5f404e4740d894cbb32045ac402d05f7de86
6
+ metadata.gz: 6bd013f51e770763b1b6305ee094e42e90359d17306b03a78497996efe34cec2cc5c1c2cf3c12ad4b7f4ab5992cd7fad73f88c9e2f428ad82baf6f8d0434c278
7
+ data.tar.gz: b60050b28b9686dd14e0dba7323cec9eed49b709288a59d6a6f3ffb5b3f6a9827d4a8f818db65958711cf7c2bd11cfdb291af85652854c8304a741a68473c03f
@@ -2,8 +2,9 @@
2
2
  .tipjar-button {
3
3
  display: flex;
4
4
  align-items: center;
5
+ justify-content: center;
5
6
  gap: 0.5rem;
6
- padding: 0.75rem 1rem;
7
+ padding: 0.75rem;
7
8
  background-color: #3b82f6;
8
9
  color: white;
9
10
  border-radius: 9999px;
@@ -14,12 +15,15 @@
14
15
  font-size: 0.875rem;
15
16
  font-weight: 500;
16
17
  animation: tipjar-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
18
+ min-width: 3rem;
19
+ min-height: 3rem;
17
20
  }
18
21
 
19
22
  .tipjar-button:hover {
20
23
  background-color: #2563eb;
21
24
  transform: scale(1.05);
22
25
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
26
+ padding: 0.75rem 1rem;
23
27
  }
24
28
 
25
29
  .tipjar-button:focus {
@@ -172,8 +176,14 @@
172
176
  /* Responsive Design */
173
177
  @media (max-width: 640px) {
174
178
  .tipjar-button {
175
- padding: 0.625rem 0.875rem;
179
+ padding: 0.625rem;
176
180
  font-size: 0.75rem;
181
+ min-width: 2.5rem;
182
+ min-height: 2.5rem;
183
+ }
184
+
185
+ .tipjar-button:hover {
186
+ padding: 0.625rem 0.875rem;
177
187
  }
178
188
 
179
189
  .tipjar-button-icon {
@@ -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 #{config_position_classes(position)} #{custom_class}",
15
- style: "z-index: #{z_index};" do
16
- content_tag(:span, class: "tipjar-button-icon") do
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTipjar
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
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.1.0
4
+ version: 0.2.1
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: []