fa_rails 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 157fd0642d7e283f63085edd82d1e83941440c53b62f1c7e547a448faa07d43f
4
- data.tar.gz: 1fe81fae07ca36ee1451d435fb3355b4ad3c8fc9baa3b25f22f4823ce23f062d
3
+ metadata.gz: f664c27729b24055feaa406ad8847a1cd8e2c6bf176d513dff946c0cacfd088b
4
+ data.tar.gz: c2b3557385fe58d2c0cc87cc5f88b64b4a420cbf4ab521062e794253e2fc2672
5
5
  SHA512:
6
- metadata.gz: 1ed38c30ff8f9aca74e873dc2308506434a424d6955ea982207d292500bd906755395536e93569647688a05f2cd479421a2f26fdc8cefb36cc33c60219877261
7
- data.tar.gz: 1a630a476fb8b48a3c4800ac3907a2478e11bc99f6cdc656f50000e28581192375ad783648a3299252b040300c500cee14007d3d46e83418e88a21b9a7b4acf7
6
+ metadata.gz: 7f5b7a3d34e521837f5576c4a4da657c6e7d91fb30a131a32427f1750ffd183ab0281c1f11209c370ad96a11810f1e3a0b5381a947b6a126288aaa17e0652127
7
+ data.tar.gz: c6bfde33dce0ae1403553ca8ff1e36943e203ba6819010b9845b442e0ae46a242c16c63c424c121475af3fa6652f687dcec671150c4bff55613ac491cdeec7fc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fa_rails (0.1.20)
4
+ fa_rails (0.1.21)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -90,6 +90,7 @@ options #=> Hash
90
90
  size: Integer # Stepped scaling factor
91
91
 
92
92
  css: String # Arbitrary CSS classes, space-delimited
93
+ raw_css: Hash # Arbitrary raw CSS, as a hash of attributes and values
93
94
  fa: String # Arbitrary FA classes, space-delimited – each is automatically prefixed with `fa-`
94
95
  title: String #=> Tooltip text
95
96
  grow: Integer #=> Transform value – amount to grow by
@@ -114,6 +115,7 @@ options #=> Hash
114
115
  position: Symbol # Indicator of which corner to display on – one of [:tr, :tl, :br, :bl]
115
116
 
116
117
  css: String # Arbitrary CSS classes, space-delimited
118
+ raw_css: Hash # Arbitrary raw CSS, as a hash of attributes and values
117
119
  fa: String # Arbitrary FA classes, space-delimited – each is automatically prefixed with `fa-`
118
120
  title: String #=> Tooltip text
119
121
  grow: Integer #=> Transform value – amount to grow by
@@ -143,24 +145,28 @@ css #=> String – arbitrary CSS classes, space-delimited, applied to the layer
143
145
  ```ruby
144
146
  # Fixed-width lock icon
145
147
  FA::Icon.p('lock', fa: 'fw')
146
- #=> "<i class='fas fa-fw fa-lock fa-1x' data-fa-transform='' title=''></i>"
148
+ #=> "<i class='fas fa-fw fa-lock fa-1x' style='' data-fa-transform='' title=''></i>"
149
+
150
+ # Duotone fire-alt icon with specified opacities
151
+ FA::Icon.p('fire-alt', style: :duotone, raw_css: { '--fa-primary-opacity' => '0.6', '--fa-secondary-opacity' => '0.4' })
152
+ #=> "<i class='fad fa-fire-alt fa-1x' style='--fa-primary-opacity: 0.4; --fa-secondary-opacity: 0.6;' data-fa-transform='' title=''></i>"
147
153
 
148
154
  # Counter span, with value 5
149
155
  FA::Span.p('counter', 5)
150
- #=> "<span class='fa-layers-counter ' data-fa-transform=''>5</span>"
156
+ #=> "<span class='fa-layers-counter ' style='' data-fa-transform=''>5</span>"
151
157
 
152
158
  # Gray envelope icon with red exclamation mark overlayed, with tooltip 'Invalid email address'
153
159
  FA::Layer.p([{ name: 'envelope', options: { css: :gray } }, { name: 'exclamation', options: { css: :red } }], title: 'Invalid email address')
154
160
  #=> "<span class='icon fa-layers fa-stack fa-fw ' title='Invalid email address'>" \
155
- # "<i class='fas fa-stack-1x gray fa-envelope fa-1x' data-fa-transform='grow-0' title='Invalid email address'></i>" \
156
- # "<i class='fas fa-stack-1x red fa-exclamation fa-1x' data-fa-transform='grow-0' title='Invalid email address'></i>" \
161
+ # "<i class='fas fa-stack-1x gray fa-envelope fa-1x' style='' data-fa-transform='grow-0' title='Invalid email address'></i>" \
162
+ # "<i class='fas fa-stack-1x red fa-exclamation fa-1x' style='' data-fa-transform='grow-0' title='Invalid email address'></i>" \
157
163
  # "</span>"
158
164
 
159
165
  # Blue envelope with red counter on the top left corner, with value 7
160
166
  FA::Layer.p([{ name: 'envelope', options: { css: :blue } }, { name: 'counter', text: 7, options: { css: :red, position: :tl } }])
161
167
  #=> "<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
162
- # "<i class='fas fa-stack-1x blue fa-envelope fa-1x' data-fa-transform='grow-0' title=''></i>" \
163
- # "<span class='fa-stack-1x red fa-layers-counter fa-layers-top-left' data-fa-transform='grow-0'>7</span>" \
168
+ # "<i class='fas fa-stack-1x blue fa-envelope fa-1x' style='' data-fa-transform='grow-0' title=''></i>" \
169
+ # "<span class='fa-stack-1x red fa-layers-counter fa-layers-top-left' style='' data-fa-transform='grow-0'>7</span>" \
164
170
  # "</span>"
165
171
 
166
172
  # The same stack, but using the FA::Build DSL (with various syntaxes).
data/fa_rails.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'fa_rails'
3
- s.version = '0.1.20'
4
- s.date = '2019-07-31'
3
+ s.version = '0.1.21'
4
+ s.date = '2019-08-09'
5
5
  s.summary = 'FontAwesome helper for Rails'
6
6
  s.description = 'A helper module for using FontAwesome icons in Rails.'
7
7
  s.homepage = 'http://rubygems.org/gems/fa_rails'
data/lib/fa/base.rb CHANGED
@@ -43,7 +43,7 @@ module FA
43
43
  css = @classes.flatten.join(' ')
44
44
  transforms = @transforms.join(' ')
45
45
 
46
- "<i class='#{css}' data-fa-transform='#{transforms}' " \
46
+ "<i class='#{css}' style='#{@styles}' data-fa-transform='#{transforms}' " \
47
47
  "title='#{options[:title]}'></i>"
48
48
  end
49
49
 
@@ -59,11 +59,11 @@ module FA
59
59
  css = @classes.flatten.reject { |c| c.to_s.match?(/^fa.$/) }.join(' ')
60
60
  transforms = @transforms.join(' ')
61
61
 
62
- "<span class='#{css}' data-fa-transform='#{transforms}'>#{text}</span>"
62
+ "<span class='#{css}' style='#{@styles}' data-fa-transform='#{transforms}'>#{text}</span>"
63
63
  end
64
64
 
65
65
  def fa_options(options)
66
- default = { style: :solid, css: '', fa: '', size: 1 }
66
+ default = { style: :solid, css: '', raw_css: {}, fa: '', size: 1 }
67
67
 
68
68
  default.merge(options.to_h)
69
69
  end
@@ -93,6 +93,7 @@ module FA
93
93
 
94
94
  def parse_options(options)
95
95
  parse_classes(options)
96
+ parse_styles(options)
96
97
  parse_transforms(options)
97
98
  end
98
99
 
@@ -103,6 +104,10 @@ module FA
103
104
  @classes << options[:css].to_s.split(' ')
104
105
  end
105
106
 
107
+ def parse_styles(options)
108
+ @styles = options[:raw_css].map { |k, v| "#{k}: #{v};" }.join(' ')
109
+ end
110
+
106
111
  def parse_transforms(options)
107
112
  @transforms = []
108
113
  %i[grow shrink rotate up down left right].each do |transform|
data/spec/lib/fa_spec.rb CHANGED
@@ -30,18 +30,18 @@ RSpec.describe FA do
30
30
  describe 'icon' do
31
31
  it 'should generate the correct icon from a string or symbol name' do
32
32
  expect(FA::Icon.p('help')).to eql(
33
- "<i class='fas fa-help fa-1x' data-fa-transform='' title=''></i>"
33
+ "<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
34
34
  )
35
35
 
36
36
  expect(FA::Icon.p(:help)).to eql(
37
- "<i class='fas fa-help fa-1x' data-fa-transform='' title=''></i>"
37
+ "<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
38
38
  )
39
39
  end
40
40
 
41
41
  it 'should generate the correct icon from a configuration hash' do
42
42
  fa = { name: 'help', options: { style: :light, size: 2 } }
43
43
  expect(FA::Icon.p(fa)).to eql(
44
- "<i class='fal fa-help fa-2x' data-fa-transform='' title=''></i>"
44
+ "<i class='fal fa-help fa-2x' style='' data-fa-transform='' title=''></i>"
45
45
  )
46
46
  end
47
47
 
@@ -55,7 +55,7 @@ RSpec.describe FA do
55
55
 
56
56
  it 'should generate the correct brand icon' do
57
57
  expect(FA::Icon.p(:github, style: :brands)).to eql(
58
- "<i class='fab fa-github fa-1x' data-fa-transform='' title=''></i>"
58
+ "<i class='fab fa-github fa-1x' style='' data-fa-transform='' title=''></i>"
59
59
  )
60
60
  end
61
61
  end
@@ -70,9 +70,9 @@ RSpec.describe FA do
70
70
 
71
71
  expect(FA::Layer.p(icons, grow: 2)).to eql(
72
72
  "<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
73
- "<i class='fas fa-stack-1x fa-square fa-1x' data-fa-transform='grow-2' title=''></i>" \
74
- "<i class='fas fa-stack-1x fa-circle fa-1x' data-fa-transform='grow-3' title=''></i>" \
75
- "<i class='far fa-stack-1x fa-exclamation fa-1x' data-fa-transform='grow-2' title=''></i>" \
73
+ "<i class='fas fa-stack-1x fa-square fa-1x' style='' data-fa-transform='grow-2' title=''></i>" \
74
+ "<i class='fas fa-stack-1x fa-circle fa-1x' style='' data-fa-transform='grow-3' title=''></i>" \
75
+ "<i class='far fa-stack-1x fa-exclamation fa-1x' style='' data-fa-transform='grow-2' title=''></i>" \
76
76
  '</span>'
77
77
  )
78
78
  end
@@ -85,8 +85,8 @@ RSpec.describe FA do
85
85
 
86
86
  expect(FA::Layer.p(icons)).to eql(
87
87
  "<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
88
- "<i class='fas fa-stack-1x fa-square fa-1x' data-fa-transform='grow-0' title=''></i>" \
89
- "<span class='fa-stack-1x fa-layers-counter fa-layers-top-left' data-fa-transform='grow-0'>17</span>" \
88
+ "<i class='fas fa-stack-1x fa-square fa-1x' style='' data-fa-transform='grow-0' title=''></i>" \
89
+ "<span class='fa-stack-1x fa-layers-counter fa-layers-top-left' style='' data-fa-transform='grow-0'>17</span>" \
90
90
  '</span>'
91
91
  )
92
92
  end
@@ -99,8 +99,8 @@ RSpec.describe FA do
99
99
 
100
100
  expect(FA::Layer.p(icons, title: 'right')).to eql(
101
101
  "<span class='icon fa-layers fa-stack fa-fw ' title='right'>" \
102
- "<i class='fas fa-stack-1x fa-square fa-1x' data-fa-transform='grow-0' title='right'></i>" \
103
- "<i class='fas fa-stack-1x fa-exclamation fa-1x' data-fa-transform='grow-0' title='right'></i>" \
102
+ "<i class='fas fa-stack-1x fa-square fa-1x' style='' data-fa-transform='grow-0' title='right'></i>" \
103
+ "<i class='fas fa-stack-1x fa-exclamation fa-1x' style='' data-fa-transform='grow-0' title='right'></i>" \
104
104
  '</span>'
105
105
  )
106
106
  end
@@ -115,8 +115,8 @@ RSpec.describe FA do
115
115
 
116
116
  expect(layer).to eql(
117
117
  "<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
118
- "<i class='fas fa-stack-1x fa-circle fa-1x' data-fa-transform='grow-0' title=''></i>" \
119
- "<span class='fa-stack-1x fa-layers-counter ' data-fa-transform='grow-0'>7</span>" \
118
+ "<i class='fas fa-stack-1x fa-circle fa-1x' style='' data-fa-transform='grow-0' title=''></i>" \
119
+ "<span class='fa-stack-1x fa-layers-counter ' style='' data-fa-transform='grow-0'>7</span>" \
120
120
  '</span>'
121
121
  )
122
122
  end
@@ -125,7 +125,7 @@ RSpec.describe FA do
125
125
  describe 'span' do
126
126
  it 'should generate the correct span from a string or symbol type' do
127
127
  expect(FA::Span.p(:text, 'Hello')).to eql(
128
- "<span class='fa-layers-text ' data-fa-transform=''>Hello</span>"
128
+ "<span class='fa-layers-text ' style='' data-fa-transform=''>Hello</span>"
129
129
  )
130
130
  end
131
131
 
@@ -133,7 +133,7 @@ RSpec.describe FA do
133
133
  span = { type: :text, text: 'World', options: { position: :bl } }
134
134
  expect(FA::Span.p(span)).to eql(
135
135
  "<span class='fa-layers-text fa-layers-bottom-left' " \
136
- "data-fa-transform=''>World</span>"
136
+ "style='' data-fa-transform=''>World</span>"
137
137
  )
138
138
  end
139
139
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fa_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake