Skip to content

Commit

Permalink
fixes our facet icon alignment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Jul 28, 2016
1 parent 89deba6 commit 952c039
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/geoblacklight/_geoblacklight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@import 'font-awesome';
@import 'geoblacklight/styles';
@import 'modules/coderay';
@import 'modules/facets';
@import 'modules/mixins';
@import 'modules/icon-customization';
@import 'modules/home';
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/geoblacklight/modules/facets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.facet-label .geoblacklight-icon {
display: inline;
padding-left: 10px;
padding-right: 15px;
}
12 changes: 12 additions & 0 deletions app/helpers/geoblacklight_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,16 @@ def render_web_services(reference)
def leaflet_options
Settings.LEAFLET
end

##
# Renders a facet item with an icon placed as the first child of
# `.facet-label`. This works with `render_facet_value` and
# `render_selected_facet_value`
# @return String
def render_facet_item_with_icon(field_name, item)
doc = Nokogiri::HTML.fragment(render_facet_item(field_name, item))
doc.at_css('.facet-label').children.first
.add_previous_sibling(geoblacklight_icon(item.value))
doc.to_html.html_safe
end
end
7 changes: 1 addition & 6 deletions app/views/catalog/_icon_facet.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
<% paginator = facet_paginator(facet_field, display_facet) %>
<% paginator.items.each do |item| -%>
<li>
<%= geoblacklight_icon item.value %>
<% if facet_in_params?( solr_field, item.value ) %>
<%= render_selected_facet_value(solr_field, item) %>
<% else %>
<%= render_facet_value(solr_field, item) %>
<% end -%>
<%= render_facet_item_with_icon(field_name, item) %>
</li>
<% end %>
</ul>

0 comments on commit 952c039

Please sign in to comment.