-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5163 from williamboman/4.3.0-wip
Add icon search
- Loading branch information
Showing
9 changed files
with
1,311 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div class="filter-parent"> | ||
<label for="filter-by" class="fa fa-search"></label> | ||
<input placeholder="Filter icons..." id="filter-by"> | ||
<a href="#" id="filter-clear" class="fa fa-times"></a> | ||
</div> | ||
<script> | ||
try { | ||
var filterSet = JSON.parse('{{ icons | flattenIconFilters | jsonify }}'); | ||
} catch (e) { | ||
console.error('Invalid JSON data!'); | ||
var filterSet = []; | ||
} | ||
</script> | ||
<{% if page.navbar_active == "icons" %}div{% else %}section{% endif %} id="filter"> | ||
<h2 class="page-header">Filter for <span class="text-muted" id="filter-val"></span></h2> | ||
{% if page.navbar_active != "icons" %} | ||
<div class="margin-botom-large"> | ||
You asked, Font Awesome delivers with {{ icons | version:site.fontawesome.minor_version | size }} shiny new icons in version {{ site.fontawesome.minor_version }}. | ||
Want to request new icons? <a href="{{ page.relative_path }}community/#requesting-new-icons">Here's how</a>. | ||
</div> | ||
{% endif %} | ||
|
||
<div class="row fontawesome-icon-list"> | ||
{% for icon in icons %} | ||
<div class="fa-hover col-md-3 col-sm-4 filter-icon" | ||
data-filter="{{ icon.class }}{% for alias in icon.aliases %}|{{ alias }}{% endfor %}{% for filter in icon.filter %}|{{ filter }}{% endfor %}"> | ||
<a href="{{ page.relative_path }}icon/{{ icon.id }}"><i class="fa fa-{{ icon.class }}"></i> fa-{{ icon.class }}{% if icon.alias_of %} <span class="text-muted">(alias)</span>{% endif %}</a> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
<div id="no-search-results"> | ||
<div class="alert alert-danger" role="alert"><i class="fa fa-ban"></i> No icons with the tag <strong>'<span></span>'</strong> were found.</div> | ||
<div class="alert alert-info" role="alert"><i class="fa fa-exclamation-circle"></i> Tags are added by the community. Do you think your search query should return an icon? Send a pull request on <a href="https://github.com/FortAwesome/Font-Awesome">GitHub</a>!</div> | ||
</div> | ||
|
||
</{% if page.navbar_active == "icons" %}div{% else %}section{% endif %}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## | ||
# Flattens the icons object to a one-dimensional array of possible search terms. | ||
|
||
require 'set' | ||
|
||
module Jekyll | ||
module FlattenArray | ||
def flattenIconFilters(icons) | ||
flattened = Set.new | ||
icons.each do |icon| | ||
toAdd = [] | ||
|
||
toAdd.push(icon["class"].downcase) # Add class as a filter value | ||
|
||
# Add any existing aliases as a filter value | ||
if not icon["aliases"].nil? | ||
icon["aliases"].each do |iconAlias| | ||
toAdd.push(iconAlias.downcase) | ||
end | ||
end | ||
|
||
# Add any existing filters as a filter value | ||
if not icon["filter"].nil? | ||
icon["filter"].each do |iconFilter| | ||
toAdd.push(iconFilter.downcase) | ||
end | ||
end | ||
flattened.merge(toAdd) | ||
|
||
print toAdd if toAdd.include? true | ||
print toAdd if toAdd.include? false | ||
end | ||
return flattened.to_a # .to_a because we can't jsonify a <Set> | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_filter(Jekyll::FlattenArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.