File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ class Icon
77 # @param [String, Symbol] icon_name
88 # @param [Hash] options
99 # @param [String] classes additional classes separated by a string
10- def initialize ( icon_name , classes : '' )
10+ def initialize ( icon_name , classes : '' , aria_hidden : false )
1111 @icon_name = icon_name
1212 @classes = classes
13+ @aria_hidden = aria_hidden
1314 end
1415
1516 ##
@@ -23,7 +24,8 @@ def svg
2324 # @return [Hash]
2425 def options
2526 {
26- class : classes
27+ class : classes ,
28+ "aria-hidden" : ( true if @aria_hidden )
2729 }
2830 end
2931
Original file line number Diff line number Diff line change 2020 < span class ="input-group-append ">
2121 < button type ="submit " class ="btn btn-primary search-btn " id ="search ">
2222 < span class ="submit-search-text "> <%= t ( 'blacklight.search.form.submit' ) %> </ span >
23- <%= blacklight_icon :search %>
23+ <%= blacklight_icon :search , aria_hidden : true %>
2424 </ button >
2525 </ span >
2626 </ div >
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33RSpec . describe Blacklight ::Icon do
4- subject { described_class . new ( :search , classes : 'awesome' ) }
4+ subject { described_class . new ( :search , classes : 'awesome' , aria_hidden : true ) }
55
66 describe '#svg' do
77 it 'returns a string' do
1717 it 'applies options classes and default class' do
1818 expect ( subject . options [ :class ] ) . to eq 'blacklight-icons awesome'
1919 end
20+ it 'applies options aria-hidden=true' do
21+ expect ( subject . options [ :'aria-hidden' ] ) . to be true
22+ end
23+ context 'no options provided' do
24+ subject { described_class . new ( :view ) }
25+
26+ it 'applies default class with no options' do
27+ expect ( subject . options [ :class ] ) . to eq 'blacklight-icons'
28+ end
29+
30+ it 'has no aria-hidden attribute with no options' do
31+ expect ( subject . options [ :'aria-hidden' ] ) . to be nil
32+ end
33+ end
2034 end
2135
2236 describe '#path' do
You can’t perform that action at this time.
0 commit comments