fa_rails 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/fa_rails.gemspec +1 -1
- data/lib/fa/base.rb +12 -0
- data/spec/lib/fa_spec.rb +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626bd595bc9a79f241571cc01ea6c2b17f926f4a98b37678f2ab0f78046de28d
|
4
|
+
data.tar.gz: 9b2374e43b36b5f304496de28e2a876014875e5d1615e20a1d853fe8fe271e8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a20e551e982f87d8e3c81df3a4dbd5d15e3933ecebcef9b62978a0174879a389379189f93ed4a985672de8ebbab15fbb124f4c074a914dcb1da9ac1cab30d1f
|
7
|
+
data.tar.gz: 685fb1c6945497270fd48526f8d481bad0b48cf1f408164fabe2a3f23b51827448fb68be0dca9c496a440bbe6cdbe8b108f45f40b4f1fa08cc53b39d9b9a2e16
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -151,6 +151,13 @@ FA::Icon.p('lock', fa: 'fw')
|
|
151
151
|
FA::Icon.p('fire-alt', style: :duotone, raw_css: { '--fa-primary-opacity' => '0.6', '--fa-secondary-opacity' => '0.4' })
|
152
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>"
|
153
153
|
|
154
|
+
# You can also use this simplified configuration option for adding styles
|
155
|
+
# This is reforatted and merged into :raw_css
|
156
|
+
# Accepts either snake_case symbols or spear-case strings as keys, and strings or symbols as values
|
157
|
+
# This is the easiest way to add primary/secondary styles for duotone icons
|
158
|
+
FA::Icon.p('fire-alt', style: :duotone, fa_styles: { primary_opacity: '0.6', secondary_opacity: '0.4', primary_color: :green, secondary_color: '#DD2200' })
|
159
|
+
#=> "<i class='fad fa-fire-alt fa-1x' style='--fa-primary-opacity: 0.6; --fa-secondary-opacity: 0.4; --fa-primary-color: green; --fa-secondary-color: #DD2200;' data-fa-transform='' title=''></i>"
|
160
|
+
|
154
161
|
# Counter span, with value 5
|
155
162
|
FA::Span.p('counter', 5)
|
156
163
|
#=> "<span class='fa-layers-counter ' style='' data-fa-transform=''>5</span>"
|
data/fa_rails.gemspec
CHANGED
data/lib/fa/base.rb
CHANGED
@@ -93,6 +93,7 @@ module FA
|
|
93
93
|
|
94
94
|
def parse_options(options)
|
95
95
|
parse_classes(options)
|
96
|
+
options = merge_fa_styles(options)
|
96
97
|
parse_styles(options)
|
97
98
|
parse_transforms(options)
|
98
99
|
end
|
@@ -104,6 +105,17 @@ module FA
|
|
104
105
|
@classes << options[:css].to_s.split(' ')
|
105
106
|
end
|
106
107
|
|
108
|
+
def merge_fa_styles(options)
|
109
|
+
fa_styles = options.delete(:fa_styles)
|
110
|
+
return options unless fa_styles
|
111
|
+
|
112
|
+
fa_styles = fa_styles.each_with_object({}) do |(k, v), hash|
|
113
|
+
hash["--fa-#{k.to_s.tr('_', '-')}"] = v.to_s
|
114
|
+
end
|
115
|
+
options[:raw_css] = options[:raw_css].merge(fa_styles)
|
116
|
+
options
|
117
|
+
end
|
118
|
+
|
107
119
|
def parse_styles(options)
|
108
120
|
@styles = options[:raw_css].map { |k, v| "#{k}: #{v};" }.join(' ')
|
109
121
|
end
|
data/spec/lib/fa_spec.rb
CHANGED
@@ -28,11 +28,13 @@ RSpec.describe FA do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'icon' do
|
31
|
-
it 'should generate the correct icon from a string
|
31
|
+
it 'should generate the correct icon from a string name' do
|
32
32
|
expect(FA::Icon.p('help')).to eql(
|
33
33
|
"<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
34
34
|
)
|
35
|
+
end
|
35
36
|
|
37
|
+
it 'should generate the correct icon from a symbol name' do
|
36
38
|
expect(FA::Icon.p(:help)).to eql(
|
37
39
|
"<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
38
40
|
)
|
@@ -58,6 +60,19 @@ RSpec.describe FA do
|
|
58
60
|
"<i class='fab fa-github fa-1x' style='' data-fa-transform='' title=''></i>"
|
59
61
|
)
|
60
62
|
end
|
63
|
+
|
64
|
+
it 'should generate the correct icon with styles' do
|
65
|
+
expect(
|
66
|
+
FA::Icon.p(
|
67
|
+
'fire-alt', style: :duotone, fa_styles: {
|
68
|
+
primary_opacity: '0.6', secondary_opacity: '0.4', primary_color: :green, secondary_color: '#DD2200'
|
69
|
+
}
|
70
|
+
)
|
71
|
+
).to eql(
|
72
|
+
"<i class='fad fa-fire-alt fa-1x' style='--fa-primary-opacity: 0.6; --fa-secondary-opacity: 0.4; " \
|
73
|
+
"--fa-primary-color: green; --fa-secondary-color: #DD2200;' data-fa-transform='' title=''></i>"
|
74
|
+
)
|
75
|
+
end
|
61
76
|
end
|
62
77
|
|
63
78
|
describe 'layer' do
|