fx_awesome_mails 0.5.1 → 0.5.5

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: 16fcfef004cf5598649b4b8b69390a5aa6d9945e0a5b0010a8fe8b46fc26f69f
4
- data.tar.gz: bae92a1e1137f5ea6479239d99d63702636d45bee9d30e644b179539c6b14771
3
+ metadata.gz: bd2b4740a0862d162ca275c62ebaa8796a72570f6f7efa4c990ffdc0c70eb4d2
4
+ data.tar.gz: 3cbd818cad4ef2c7f46467e50e6eec5578cf333d001215c9caa78f9cbf09ab97
5
5
  SHA512:
6
- metadata.gz: 1be5ea3bd16866f478d985d4379bcbea38d62d1ee7958ecbf5d30a157ae33c0620a94ece01fcbfa4b8070d9f635983b73a3b39623a2a53768b17ad2791a8bcb5
7
- data.tar.gz: 443800a73d2fdf1705458f7b4d9465bcbed53c4ea2c33ec38fe203e11f3a60fd14e9db09549d2c2a5fb047b8078ba78172931a335cbd2f4f9a25c593d31181e0
6
+ metadata.gz: b164d6adbd4f1a04bc8ce92f1f35a400cf8063d4fb324b2c354c46a1ee93593200611e2bdc4107f1af6ba34daeef973e9820b5aa54109203a83b3f1668837fc5
7
+ data.tar.gz: 65885c7bccebce3a048bb05a311ed929f03082bbb5c9ffec1ca14e459a702dfc992969e11c568be86fc38cf4c20d06005230ee4b5a51daebce8ebb4e59ccc5ff
@@ -0,0 +1,35 @@
1
+ module FXAwesomeMails
2
+ module Refinements
3
+ refine String do
4
+ def to_css_hash
5
+ Hash[split(';').map { _1.split(':').map(&:strip) }]
6
+ end
7
+
8
+ def merge_css_options(second, key)
9
+ return self&.strip if second.blank?
10
+ return second&.strip if self.blank?
11
+
12
+ case key
13
+ when :style
14
+ return self.strip.to_css_hash.deep_merge_v2(second.strip.to_css_hash).map {|k,v| [k,v].join(':') }.join(';')
15
+ when :class
16
+ self.strip.split(' ').union(second.strip.split(' ')).join(' ')
17
+ else
18
+ return ""
19
+ end
20
+ end
21
+ end
22
+
23
+ refine Hash do
24
+ def deep_merge_v2(second)
25
+ merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
26
+ merge(second.to_h, &merger)
27
+ end
28
+
29
+ def merge_email_options(second)
30
+ merger = proc { |k, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : [:style, :class].include?(k) ? v1.merge_css_options(v2, k) : v2}
31
+ merge(second.to_h, &merger)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module FXAwesomeMails
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -1,14 +1,18 @@
1
+ require 'fx_awesome_mails/refinements'
1
2
  module FXAwesomeMails
2
3
  module EmailHelpers
4
+
5
+ using FXAwesomeMails::Refinements
6
+
3
7
  def preheader(text)
4
8
  "<div style='display: none; max-height: 0px; overflow: hidden;'>
5
- #{text}
6
- </div>
7
- <div class='preheader' style='display: none; width: 0px; height: 0px; max-height: 0px; overflow: hidden;'>
8
- &#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;
9
- </div>".html_safe
9
+ #{text}
10
+ </div>
11
+ <div class='preheader' style='display: none; width: 0px; height: 0px; max-height: 0px; overflow: hidden;'>
12
+ &#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;
13
+ </div>".html_safe
10
14
  end
11
-
15
+
12
16
  def titlebar_link(link)
13
17
  "<div class='tac pt10 pb10 pl5 pr5'>
14
18
  <!--[if gte mso 12]><br><![endif]-->
@@ -16,12 +20,11 @@ module FXAwesomeMails
16
20
  <!--[if gte mso 12]><br><![endif]-->
17
21
  </div>".html_safe
18
22
  end
19
-
23
+
20
24
  def divider(options = {})
21
25
  "<p class='MsoNormal'><o:p>&nbsp;</o:p></p>".html_safe # TODO: options/smaller
22
26
  end
23
-
24
-
27
+
25
28
  # experimental mail helpers
26
29
  def content_tag_if(condition, name, content_or_options_with_block = {}, options = {}, escape = true, &block)
27
30
  options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) if block_given?
@@ -35,14 +38,14 @@ module FXAwesomeMails
35
38
  content_or_options_with_block, options = options, nil if block_given?
36
39
  content_tag(name, content_or_options_with_block, options, escape, &block)
37
40
  end
38
-
41
+
39
42
  def rounded_box(&block)
40
43
  html = "<div class='rounded_box'><div class='rounded_box_content'><div class='rounded_box_top'></div>"
41
44
  html << capture(:foo, :bar, &block)
42
45
  html << "<div class='rounded_box_bottom'><div></div></div></div>"
43
46
  raw html
44
47
  end
45
-
48
+
46
49
  # https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to_if + link_to( ...&block)
47
50
  def link_to_if_true(condition, name, options = {}, html_options = {}, &block)
48
51
  if condition
@@ -55,14 +58,14 @@ module FXAwesomeMails
55
58
  end
56
59
  end
57
60
  end
58
-
61
+
59
62
  class Button
60
63
  attr_accessor :parent
61
64
  def initialize(parent)
62
65
  self.parent = parent
63
66
  end
64
67
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
65
-
68
+
66
69
  # simple, graphical
67
70
  def simple_button(text = nil, type: :simple, **options, &block)
68
71
  html = "<th valign='bottom' style='text-align:left' class='buttoncellclass mobile-display-block button-container' bgcolor='#000000'>
@@ -73,7 +76,7 @@ module FXAwesomeMails
73
76
  <table cellpadding='0' cellspacing='0' border='0' width='auto' style='margin:0 auto' role='presentation' align='center'>
74
77
  <tbody>
75
78
  <tr>"
76
-
79
+
77
80
  # style = mso-line-height-rule: exactly; -webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background:#FFFF00;text-align:right
78
81
  # link_style = -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; padding: 10px 20px; display: inline-block; text-decoration: none; text-align: right; color: #00FF00; border: 12; font-family: Arial, sans-serif; font-size: 13px; line-height: 14px; font-weight: 500;
79
82
  html << content_tag('th', valign: options[:valign].to_s, align: options[:align].to_s) do
@@ -90,24 +93,24 @@ module FXAwesomeMails
90
93
  </tbody>
91
94
  </table>
92
95
  </th>"
93
-
96
+
94
97
  html.html_safe
95
98
  end
96
-
99
+
97
100
  def graphical_button(text, type: :simple, **options, &block)
98
101
  "<th valign='bottom' style='text-align:left' class='buttoncellclass mobile-display-block button-container' bgcolor='#000000'>
99
102
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='width:100% !important' role='presentation'>
100
103
  <tbody>
101
104
  <tr>
102
-
105
+
103
106
 
104
-
107
+
105
108
  </tr>
106
109
  </tbody>
107
110
  </table>
108
111
  </th>"
109
112
  end
110
-
113
+
111
114
  def button(text = nil, type: :simple, **options)
112
115
  case type
113
116
  when :simple
@@ -116,7 +119,7 @@ module FXAwesomeMails
116
119
  graphical_button(text, **options)
117
120
  end
118
121
  end
119
-
122
+
120
123
  end
121
124
  class Gutter
122
125
  attr_accessor :parent
@@ -124,43 +127,43 @@ module FXAwesomeMails
124
127
  self.parent = parent
125
128
  end
126
129
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
127
-
130
+
128
131
  def horizontal(height = '20', **options)
129
- options = {valign: 'top', class: '',style: { "background-color" => '' }}.deep_merge_v2(options)
130
- content_tag('th', '&nbsp;'.html_safe, height: height, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} horizontal-gutter", bgcolor: "#{options.dig(:style, "background-color")}")
132
+ options = {valign: 'top', class: '',style: ""}.merge_email_options(options)
133
+ content_tag('th', '&nbsp;'.html_safe, height: height, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} horizontal-gutter", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}")
131
134
  end
132
-
135
+
133
136
  def vertical(width = '20', **options)
134
- options = {valign: 'top', class: '',style: { "background-color" => '' }}.deep_merge_v2(options)
135
- content_tag('th', '&nbsp;'.html_safe, width: width, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} vertical-gutter", bgcolor: "#{options.dig(:style, "background-color")}")
137
+ options = {valign: 'top', class: '',style: ""}.merge_email_options(options)
138
+ content_tag('th', '&nbsp;'.html_safe, width: width, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} vertical-gutter", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}")
136
139
  end
137
140
  end
138
-
141
+
139
142
  class Text
140
143
  attr_accessor :parent
141
144
  def initialize(parent)
142
145
  self.parent = parent
143
146
  end
144
147
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
145
-
148
+
146
149
  def text(text = nil, **options, &block)
147
- options = {"mso-line-height-rule" => "exactly", "text-align" => "center", "font-family" => "Helvetica", "font-size" => "20px", "line-height" => "30px", "font-weight" => "400", color: "#000000", "background-color" => "#FF00FF"}.deep_merge_v2(options)
148
- content_tag('th', valign: "#{options[:valign]}", style: options[:style], class: "#{options[:class]} text-container", bgcolor: "#{options.dig(:style, "background-color")}") do
150
+ options = {style: "mso-line-height-rule:exactly;text-align:left;font-weight:400"}.merge_email_options(options)
151
+ content_tag('th', valign: "#{options[:valign]}", style: options[:style], class: "#{options[:class]} text-container", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}") do
149
152
  "#{block_given? ? capture(&block) : text}".html_safe
150
153
  end
151
154
  end
152
155
  end
153
-
156
+
154
157
  class Image
155
158
  attr_accessor :parent
156
159
  def initialize(parent)
157
160
  self.parent = parent
158
161
  end
159
162
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
160
-
163
+
161
164
  def email_image_tag(source: nil, **options, &block)
162
- options = {alt: '', link_url: nil, width: 130, height: 50, valign: 'top', align: 'left', class: '', style: {"background-color" => "#FFFFFF", outline: "none", "text-decoration" => "none", "-ms-interpolation-mode" => "bicubic", display: "block", border: "none"} }.deep_merge_v2(options)
163
- html = "<th valign='#{options[:avlign]}' style='text-align:left' class='#{options[:class]} mobile-display-table-footer-group image-container' bgcolor='#{options.dig(:style, "background-color")}' align='#{options[:align]}'>"
165
+ options = {alt: '', link_url: nil, width: 130, height: 50, valign: 'top', align: 'left', class: '', style: "background-color: #FFFFFF;outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; display: block; border: none" }.merge_email_options(options)
166
+ html = "<th valign='#{options[:avlign]}' style='text-align:left' class='#{options[:class]} mobile-display-table-footer-group image-container' bgcolor='#{options[:style].to_s.to_css_hash["background-color"]}' align='#{options[:align]}'>"
164
167
  html << link_to_if_true(options[:link_url].present?, options[:link_url], target: '_blank') do
165
168
  image_tag(source, style: options[:style], width: "#{options[:width]}", height: "#{options[:height]}", alt: "#{options[:alt]}")
166
169
  end
@@ -169,60 +172,61 @@ module FXAwesomeMails
169
172
  html.html_safe
170
173
  end
171
174
  end
172
-
173
-
175
+
176
+
174
177
  class VerticalGrid
175
178
  attr_accessor :parent
176
179
  def initialize(parent)
177
180
  self.parent = parent
178
181
  end
179
182
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
180
-
183
+
181
184
  def self.vertical_grid(_capture_helper, **options, &block)
182
- "<th valign='top' style='text-align:left' class='vertical-grid'>
183
- <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
185
+ options = { valign: 'top', style: "text-align: left" }.merge_email_options(options)
186
+ _capture_helper.content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "text-container #{options[:class]}") do
187
+ "<table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
184
188
  <tbody>
185
189
  #{_capture_helper.capture(VerticalGrid.new(_capture_helper), &block)}
186
190
  </tbody>
187
- </table>
188
- </th>".html_safe
191
+ </table>".html_safe
192
+ end
189
193
  end
190
-
194
+
191
195
  def gutter(...)
192
196
  "<tr>#{Gutter.new(parent).horizontal(...)}</tr>".html_safe
193
197
  end
194
-
198
+
195
199
  def text(text = nil, **options, &block)
196
200
  "<tr>#{Text.new(parent).text(text, **options, &block)}</tr>".html_safe
197
201
  end
198
-
202
+
199
203
  def image(...)
200
204
  "<tr>#{Image.new(parent).email_image_tag(...)}</tr>".html_safe
201
205
  end
202
-
206
+
203
207
  def button(...)
204
208
  "<tr>
205
209
  #{Button.new(parent).button(...)}
206
210
  </tr>".html_safe
207
211
  end
208
-
212
+
209
213
  def horizontal_grid(**options, &block)
210
214
  "<tr>#{HorizontalGrid.horizontal_grid(parent, **options, &block)}</tr>".html_safe
211
215
  end
212
-
216
+
213
217
  def vertical_grid(**options, &block)
214
218
  "<tr>#{VerticalGrid.vertical_grid(parent, **options, &block)}</tr>".html_safe
215
219
  end
216
220
  end
217
-
218
-
221
+
222
+
219
223
  class HorizontalGrid
220
224
  attr_accessor :parent
221
225
  def initialize(parent)
222
226
  self.parent = parent
223
227
  end
224
228
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
225
-
229
+
226
230
  def self.horizontal_grid(_capture_helper, **options, &block)
227
231
  "<th valign='top' style='text-align:left' class='horizontal-grid'>
228
232
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -234,22 +238,22 @@ module FXAwesomeMails
234
238
  </table>
235
239
  </th>".html_safe
236
240
  end
237
-
241
+
238
242
  def gutter(...)
239
243
  "#{Gutter.new(parent).vertical(...)}".html_safe
240
244
  end
241
-
245
+
242
246
  def text(text = nil, **options, &block)
243
- options = { valign: 'top', style: { "mso-line-height-rule" => "exactly", "text-align" => "left", "font-family" => "Arial, sans-serif", "font-size" => "15px", "line-height" => "18px", "font-weight" => "normal", color: "#999999" }}.deep_merge_v2(options)
244
- content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} text-container") do
247
+ options = { valign: 'top', style: "mso-line-height-rule: exactly; text-align: left; font-family: Arial, sans-serif; font-size: 15px; line-height: 18px; font-weight: normal; color: #999999" }.merge_email_options(options)
248
+ content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "text-container #{options[:class]}") do
245
249
  block_given? ? capture(&block) : text
246
250
  end
247
251
  end
248
-
252
+
249
253
  def image(...)
250
254
  "#{Image.new(parent).email_image_tag(...)}".html_safe
251
255
  end
252
-
256
+
253
257
  def button
254
258
  "<th valign='top' style='text-align:left' class='button-container'>
255
259
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='width:100% !important' role='presentation'>
@@ -269,28 +273,28 @@ module FXAwesomeMails
269
273
  </table>
270
274
  </th>".hmtl_safe
271
275
  end
272
-
276
+
273
277
  def horizontal_grid(**options, &block)
274
278
  "#{HorizontalGrid.horizontal_grid(parent, **options, &block)}".html_safe
275
279
  end
276
-
280
+
277
281
  def vertical_grid(**options, &block)
278
282
  "#{VerticalGrid.vertical_grid(parent, **options, &block)}".html_safe
279
283
  end
280
-
284
+
281
285
  end
282
-
286
+
283
287
  class ContentTable
284
-
288
+
285
289
  attr_accessor :parent
286
290
  def initialize(parent)
287
291
  self.parent = parent
288
292
  end
289
293
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
290
-
294
+
291
295
  def self.content_table(_capture_helper, **options, &block)
292
- options = {alt: '', link_url: nil, width: 600, height: 50, valign: 'top', align: 'left', class: '', background: '', style: {"background-color" => "#FFFFFF" } }.deep_merge_v2(options)
293
- "<table cellpadding='0' cellspacing='0' border='0' width='#{options[:width]}' style='margin: 0; padding: 0; text-align: left; width: 100%; min-width: 600px; line-height: 100%;' role='presentation' background='#{options[:background]}' class='background-table has-width-#{options[:width]}' bgcolor='#{options.dig(:style, "background-color")}' valign='top'>
296
+ options = {alt: '', link_url: nil, width: 600, height: 50, valign: 'top', align: 'left', class: '', background: '', style: "background-color: #FFFFFF" }.merge_email_options(options)
297
+ "<table cellpadding='0' cellspacing='0' border='0' width='#{options[:width]}' style='margin: 0; padding: 0; text-align: left; width: 100%; min-width: 600px; line-height: 100%;' role='presentation' background='#{options[:background]}' class='background-table has-width-#{options[:width]}' bgcolor='#{options[:style].to_s.to_css_hash["background-color"]}' valign='top'>
294
298
  <tbody>
295
299
  <tr>
296
300
  <th valign='top'>
@@ -310,7 +314,7 @@ module FXAwesomeMails
310
314
  </tbody>
311
315
  </table>".html_safe
312
316
  end
313
-
317
+
314
318
  def text(...)
315
319
  "<div>
316
320
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -334,13 +338,13 @@ module FXAwesomeMails
334
338
  </table>
335
339
  </div>".html_safe
336
340
  end
337
-
341
+
338
342
  def button
339
343
  "<div>
340
344
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
341
345
  <tbody>
342
346
  <tr>
343
-
347
+
344
348
  <th valign='top' style='text-align:left' class='button-container'>
345
349
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='width:100% !important' role='presentation'>
346
350
  <tbody>
@@ -358,13 +362,13 @@ module FXAwesomeMails
358
362
  </tbody>
359
363
  </table>
360
364
  </th>
361
-
365
+
362
366
  </tr>
363
367
  </tbody>
364
368
  </table>
365
369
  </div>".html_safe
366
370
  end
367
-
371
+
368
372
  def gutter(...)
369
373
  # only horizontal
370
374
  "<div>
@@ -377,7 +381,7 @@ module FXAwesomeMails
377
381
  </table>
378
382
  </div>".html_safe
379
383
  end
380
-
384
+
381
385
  def horizontal_grid(**options, &block)
382
386
  "<div>
383
387
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -389,7 +393,7 @@ module FXAwesomeMails
389
393
  </table>
390
394
  </div>".html_safe
391
395
  end
392
-
396
+
393
397
  def vertical_grid(**options, &block)
394
398
  "<div>
395
399
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -401,7 +405,7 @@ module FXAwesomeMails
401
405
  </table>
402
406
  </div>".html_safe
403
407
  end
404
-
408
+
405
409
  # def content(**options, &block)
406
410
  # "<div>
407
411
  # <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -413,7 +417,7 @@ module FXAwesomeMails
413
417
  # </table>
414
418
  # </div>".html_safe
415
419
  # end
416
-
420
+
417
421
  end
418
422
 
419
423
  def content_table(**options, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fx_awesome_mails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Gebhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-24 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -41,6 +41,7 @@ files:
41
41
  - Rakefile
42
42
  - lib/fx_awesome_mails.rb
43
43
  - lib/fx_awesome_mails/railtie.rb
44
+ - lib/fx_awesome_mails/refinements.rb
44
45
  - lib/fx_awesome_mails/version.rb
45
46
  - lib/fx_awesome_mails/view_helpers.rb
46
47
  - lib/tasks/fx_awesome_mails_tasks.rake