fa_rails 0.1.13 → 0.1.14
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/Gemfile.lock +1 -1
- data/README.md +7 -4
- data/fa_rails.gemspec +1 -1
- data/lib/fa/base.rb +5 -0
- data/spec/lib/fa_spec.rb +11 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bedbb3b52f82b24d5ef7d78088141fcf16710258
|
4
|
+
data.tar.gz: aad0ad0db36223df9317c8fe54d0a61a879a5ba1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ac8ff919be13408c0c1093bfc260eb6eb86b532b90236c5e7cf4234eb1b35ab1764a903641f256ac0dbe2d228918d2bf155eb5c22d6e02f9d197342bb09e777
|
7
|
+
data.tar.gz: dff2c8aa2b9ea64e4924d241ff4fd0922bf52747fd63a37b223765b97e0917d3c14b9891a3590c3977a5537c6d11285f238ed202c2efa3af8a086b641b32e0a8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -67,6 +67,9 @@ All three classes respond to two output methods: `raw` and `safe`.
|
|
67
67
|
- `raw` outputs the formatted string directly
|
68
68
|
- `safe` attempts to call `.html_safe` on the formatted string, if available
|
69
69
|
|
70
|
+
For convenience, each class also has a `p` method, which will create a new
|
71
|
+
instance, and return its `safe` output.
|
72
|
+
|
70
73
|
### Icon
|
71
74
|
|
72
75
|
A single FontAwesome icon.
|
@@ -132,22 +135,22 @@ css # String – arbitrary CSS classes, space-delimited, applied to the layer st
|
|
132
135
|
|
133
136
|
```ruby
|
134
137
|
# Fixed-width lock icon
|
135
|
-
FA::Icon.
|
138
|
+
FA::Icon.p('lock', fa: 'fw')
|
136
139
|
#=> "<i class='fas fa-fw fa-lock' data-fa-transform='' title=''></i>"
|
137
140
|
|
138
141
|
# Counter span, with value 5
|
139
|
-
FA::Span.
|
142
|
+
FA::Span.p('counter', 5)
|
140
143
|
#=> "<span class='fa-layers-counter ' data-fa-transform=''>5</span>
|
141
144
|
|
142
145
|
# Gray envelope icon with red exclamation mark overlayed, with tooltip 'Invalid email address'
|
143
|
-
FA::Layer.
|
146
|
+
FA::Layer.p([{ name: 'envelope', options: { css: :gray } }, { name: 'exclamation', options: { css: :red } }], title: 'Invalid email address')
|
144
147
|
#=> "<span class='icon fa-layers fa-stack fa-fw ' title='Invalid email address'>" \
|
145
148
|
# "<i class='fas gray fa-envelope' data-fa-transform='grow-0' title=''></i>" \
|
146
149
|
# "<i class='fas red fa-exclamation' data-fa-transform='grow-0' title=''></i>" \
|
147
150
|
# "</span>"
|
148
151
|
|
149
152
|
# Blue envelope with red counter on the top left corner, with value 7
|
150
|
-
FA::Layer.
|
153
|
+
FA::Layer.p([{ name: 'envelope', options: { css: :blue } }, { name: 'counter', text: 7, options: { css: :red, position: :tl } }])
|
151
154
|
#=> "<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
|
152
155
|
# "<i class='fas gray fa-envelope' data-fa-transform='grow-0' title=''></i>" \
|
153
156
|
# "<span class='red fa-layers-counter ' data-fa-transform='grow-0'>7" \
|
data/fa_rails.gemspec
CHANGED
data/lib/fa/base.rb
CHANGED
data/spec/lib/fa_spec.rb
CHANGED
@@ -14,32 +14,32 @@ RSpec.describe FA do
|
|
14
14
|
|
15
15
|
describe 'icon' do
|
16
16
|
it 'should generate the correct icon from a string or symbol name' do
|
17
|
-
expect(FA::Icon.
|
17
|
+
expect(FA::Icon.p('help')).to eql(
|
18
18
|
"<i class='fas fa-help fa-1x' data-fa-transform='' title=''></i>"
|
19
19
|
)
|
20
20
|
|
21
|
-
expect(FA::Icon.
|
21
|
+
expect(FA::Icon.p(:help)).to eql(
|
22
22
|
"<i class='fas fa-help fa-1x' data-fa-transform='' title=''></i>"
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should generate the correct icon from a configuration hash' do
|
27
27
|
fa = { name: 'help', options: { style: :light, size: 2 } }
|
28
|
-
expect(FA::Icon.
|
28
|
+
expect(FA::Icon.p(fa)).to eql(
|
29
29
|
"<i class='fal fa-help fa-2x' data-fa-transform='' title=''></i>"
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should raise ArgumentError for other input types' do
|
34
34
|
[nil, [], 0].each do |fa|
|
35
|
-
expect { FA::Icon.
|
35
|
+
expect { FA::Icon.p(fa) }.to raise_error(
|
36
36
|
ArgumentError, 'Unexpected argument type.'
|
37
37
|
)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should generate the correct brand icon' do
|
42
|
-
expect(FA::Icon.
|
42
|
+
expect(FA::Icon.p(:github, style: :brands)).to eql(
|
43
43
|
"<i class='fab fa-github fa-1x' data-fa-transform='' title=''></i>"
|
44
44
|
)
|
45
45
|
end
|
@@ -53,7 +53,7 @@ RSpec.describe FA do
|
|
53
53
|
{ name: 'exclamation', options: { style: :regular } }
|
54
54
|
]
|
55
55
|
|
56
|
-
expect(FA::Layer.
|
56
|
+
expect(FA::Layer.p(icons, grow: 2)).to eql(
|
57
57
|
"<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
|
58
58
|
"<i class='fas fa-stack-1x fa-square fa-1x' data-fa-transform='grow-2' title=''></i>" \
|
59
59
|
"<i class='fas fa-stack-1x fa-circle fa-1x' data-fa-transform='grow-3' title=''></i>" \
|
@@ -68,7 +68,7 @@ RSpec.describe FA do
|
|
68
68
|
{ name: :counter, text: 17, options: { position: :tl } }
|
69
69
|
]
|
70
70
|
|
71
|
-
expect(FA::Layer.
|
71
|
+
expect(FA::Layer.p(icons)).to eql(
|
72
72
|
"<span class='icon fa-layers fa-stack fa-fw ' title=''>" \
|
73
73
|
"<i class='fas fa-stack-1x fa-square fa-1x' data-fa-transform='grow-0' title=''></i>" \
|
74
74
|
"<span class='fa-stack-1x fa-layers-counter fa-layers-top-left' data-fa-transform='grow-0'>17</span>" \
|
@@ -82,7 +82,7 @@ RSpec.describe FA do
|
|
82
82
|
{ name: :exclamation, title: 'wrong 2' }
|
83
83
|
]
|
84
84
|
|
85
|
-
expect(FA::Layer.
|
85
|
+
expect(FA::Layer.p(icons, title: 'right')).to eql(
|
86
86
|
"<span class='icon fa-layers fa-stack fa-fw ' title='right'>" \
|
87
87
|
"<i class='fas fa-stack-1x fa-square fa-1x' data-fa-transform='grow-0' title='right'></i>" \
|
88
88
|
"<i class='fas fa-stack-1x fa-exclamation fa-1x' data-fa-transform='grow-0' title='right'></i>" \
|
@@ -93,14 +93,14 @@ RSpec.describe FA do
|
|
93
93
|
|
94
94
|
describe 'span' do
|
95
95
|
it 'should generate the correct span from a string or symbol type' do
|
96
|
-
expect(FA::Span.
|
96
|
+
expect(FA::Span.p(:text, 'Hello')).to eql(
|
97
97
|
"<span class='fa-layers-text ' data-fa-transform=''>Hello</span>"
|
98
98
|
)
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should generate the correct span from a configuration hash' do
|
102
102
|
span = { type: :text, text: 'World', options: { position: :bl } }
|
103
|
-
expect(FA::Span.
|
103
|
+
expect(FA::Span.p(span)).to eql(
|
104
104
|
"<span class='fa-layers-text fa-layers-bottom-left' " \
|
105
105
|
"data-fa-transform=''>World</span>"
|
106
106
|
)
|
@@ -108,7 +108,7 @@ RSpec.describe FA do
|
|
108
108
|
|
109
109
|
it 'should raise ArgumentError for other input types' do
|
110
110
|
[nil, [], 0].each do |fa|
|
111
|
-
expect { FA::Span.
|
111
|
+
expect { FA::Span.p(fa) }.to raise_error(
|
112
112
|
ArgumentError, 'Unexpected argument type.'
|
113
113
|
)
|
114
114
|
end
|