Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new Dutotone style type #43

Merged
merged 2 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fa_icon(:camera_retro, text: 'Camera', right: true)
# => <i class="fas fa-camera-retro"></i>
```

### Solid, Regular, Light, Brand icon types
### Solid, Regular, Light, Brand, Duotone icon types
In Font Awesome 5 there are several different types of icons. In font_awesome5_rails gem default icon type is ```solid```.
If you want to use different icon style you can do this through ```type``` attribute.

Expand All @@ -91,6 +91,7 @@ If you want to use different icon style you can do this through ```type``` attri
| Regular | :far |:regular|
| Light | :fal |:light |
| Brand | :fab |:brand |
| Duotone | :fad |:duotone|


```ruby
Expand All @@ -106,6 +107,9 @@ fa_icon('camera-retro', type: :light)
fa_icon('camera-retro', type: :brand)
# => <i class="fab fa-camera-retro"></i>

fa_icon('camera-retro', type: :duotone)
# => <i class="fad fa-camera-retro"></i>

fa_icon('camera-retro', type: :fab)
# => <i class="fab fa-camera-retro"></i>

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/font_awesome5/rails/icon_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def fa_layered_icon(options = {}, &block)
end
end

%w(fas far fal fab).each do |type|
%w(fas far fal fab fad).each do |type|
define_method :"#{type}_icon" do |icon, options = {}|
options[:type] = type.to_sym unless options.key? :type
fa_icon(icon, options)
Expand All @@ -49,4 +49,4 @@ def fa_layered_icon(options = {}, &block)

end
end
end
end
4 changes: 3 additions & 1 deletion lib/font_awesome5_rails/parsers/parse_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def icon_type(type)
"fal"
when "fab", "brand"
"fab"
when "fad", "duotone"
"fad"
else
"fas"
end
Expand All @@ -35,4 +37,4 @@ def handle_input(input)
input.to_s
end
end
end
end
11 changes: 7 additions & 4 deletions spec/font_awesome5_rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
expect(send method, 'camera-retro', type: :far).to eq '<i class="far fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :fal).to eq '<i class="fal fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :fab).to eq '<i class="fab fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :fad).to eq '<i class="fad fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :solid).to eq '<i class="fas fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :regular).to eq '<i class="far fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :light).to eq '<i class="fal fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :brand).to eq '<i class="fab fa-camera-retro"></i>'
expect(send method, 'camera-retro', type: :duotone).to eq '<i class="fad fa-camera-retro"></i>'
end

it 'should return correct class tags' do
Expand Down Expand Up @@ -83,6 +85,7 @@

it 'should return correct tags with symbols' do
expect(send method, :facebook, type: :brand).to eq '<i class="fab fa-facebook"></i>'
expect(send method, :camera_retor, type: :duotone).to eq '<i class="fad fa-camera-retro"></i>'
expect(send method, :camera_retro).to eq '<i class="fas fa-camera-retro"></i>'
expect(send method, [:camera_retro, :circle]).to eq '<i class="fas fa-camera-retro fa-circle"></i>'
end
Expand Down Expand Up @@ -173,8 +176,8 @@
end
end

describe '[fas, far, fal, fab]_icon helper method' do
%w(fas far fal fab).each do |type|
describe '[fas, far, fal, fab, fad, far_stacked_icon]_icon helper method' do
%w(fas far fal fab fad).each do |type|
it "#{type}_icon should be defined and use the right icon type" do
method = :"#{type}_icon"

Expand All @@ -186,7 +189,7 @@
end
end

describe '[fas, far, fal, fab]_stacked_icon helper method' do
describe '[fas, far, fal, fab, fad]_stacked_icon helper method' do
%w(fas far fal fab).each do |type|
it "#{type}_stacked_icon should be defined and use the right icon type" do
method = :"#{type}_stacked_icon"
Expand All @@ -205,4 +208,4 @@
end
end

end
end