Improve styling for search filters

This commit is contained in:
syeopite 2021-04-13 00:23:17 -07:00
parent bc273c75c3
commit 82d51429c1
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
3 changed files with 116 additions and 93 deletions

View file

@ -1,12 +1,7 @@
#filters { #filters {
display: inline;
margin-top: 15px; margin-top: 15px;
} }
#filters > div {
display: inline-block;
}
#filters > summary { #filters > summary {
display: block; display: block;
margin-bottom: 15px; margin-bottom: 15px;
@ -22,6 +17,20 @@
font-size: 1.5em; font-size: 1.5em;
} }
#filters .pure-menu-item {
margin-top: 10px;
}
#filters hr {
width: 80%;
margin: 10px 0 15px 0 !important
}
.filter-catagory {
display: inline-block;
margin-bottom: 20px;
}
.remove-filter { .remove-filter {
margin-left: 6px; margin-left: 6px;
vertical-align: middle; vertical-align: middle;
@ -30,3 +39,9 @@
.dark-theme .remove-filter { .dark-theme .remove-filter {
color: #CAC5BE color: #CAC5BE
} }
@media (prefers-color-scheme: dark) {
.no-theme .remove-filter {
color: #CAC5BE
}
}

View file

@ -119,7 +119,7 @@
<div class="pure-u-1-3"> <!-- Sort by --> <div class="pure-u-1-3"> <!-- Sort by -->
<div class="pure-menu pure-menu-horizontal" style=""> <div class="pure-menu pure-menu-horizontal" style="">
<ul class="pure-menu-list", style="float: right"> <ul class="pure-menu-list" style="float: right">
<% sort_options.each do |sort| %> <% sort_options.each do |sort| %>
<% if sort_by == sort %> <% if sort_by == sort %>
<li class="pure-menu-item pure-menu-selected"> <li class="pure-menu-item pure-menu-selected">

View file

@ -19,98 +19,106 @@
<% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&|$)/, "") %> <% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&|$)/, "") %>
<% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %> <% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %>
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-date"> <div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-date">
<b><%= translate(locale, "date") %></b> <b><%= translate(locale, "date") %></b>
<hr/> <hr/>
<% ["hour", "today", "week", "month", "year"].each do |date| %> <ul class="pure-menu-list">
<div class="pure-u-1 pure-md-1-5"> <% ["hour", "today", "week", "month", "year"].each do |date| %>
<% if operator_hash.fetch("date", "all") == date %> <li class="pure-menu-item">
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}"%>"> <% if operator_hash.fetch("date", "all") == date %>
<b><%= translate(locale, date) %></b> <a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}"%>">
<i class="remove-filter icon ion-md-close"></i> <b><%= translate(locale, date) %></b>
</a> <i class="remove-filter icon ion-md-close"></i>
<% else %> </a>
<a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>"> <% else %>
<%= translate(locale, date) %> <a href="<%= base_url + "#{filter_params.gsub(/&date=[a-z]+/, "")}&date=#{date}"%>">
</a> <%= translate(locale, date) %>
<% end %> </a>
</div> <% end %>
<% end %> </li>
</div> <% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-content_type"> <div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-content_type">
<b><%= translate(locale, "content_type") %></b> <b><%= translate(locale, "content_type") %></b>
<hr/> <hr/>
<% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %> <ul class="pure-menu-list">
<div class="pure-u-1 pure-md-1-5"> <% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %>
<% if operator_hash.fetch("content_type", "all") == content_type %> <li class="pure-menu-item">
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}"%>"> <% if operator_hash.fetch("content_type", "all") == content_type %>
<b><%= translate(locale, content_type) %></b> <a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}"%>">
<i class="remove-filter icon ion-md-close"></i> <b><%= translate(locale, content_type) %></b>
</a> <i class="remove-filter icon ion-md-close"></i>
<% else %> </a>
<a href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>"> <% else %>
<%= translate(locale, content_type) %> <a href="<%= base_url + "#{filter_params.gsub(/&content_type=[a-z]+/, "")}&content_type=#{content_type}"%>">
</a> <%= translate(locale, content_type) %>
<% end %> </a>
</div> <% end %>
<% end %> </li>
</div> <% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-duration"> <div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-duration">
<b><%= translate(locale, "duration") %></b> <b><%= translate(locale, "duration") %></b>
<hr/> <hr/>
<% ["short", "long"].each do |duration| %> <ul class="pure-menu-list">
<div class="pure-u-1 pure-md-1-5"> <% ["short", "long"].each do |duration| %>
<% if operator_hash.fetch("duration", "all") == duration %> <li class="pure-menu-item">
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}"%>"> <% if operator_hash.fetch("duration", "all") == duration %>
<b><%= translate(locale, duration) %></b> <a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}"%>">
<i class="remove-filter icon ion-md-close"></i> <b><%= translate(locale, duration) %></b>
</a> <i class="remove-filter icon ion-md-close"></i>
<% else %> </a>
<a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>"> <% else %>
<%= translate(locale, duration) %> <a href="<%= base_url + "#{filter_params.gsub(/&duration=[a-z]+/, "")}&duration=#{duration}"%>">
</a> <%= translate(locale, duration) %>
<% end %> </a>
</div> <% end %>
<% end %> </li>
</div> <% end %>
</ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-features"> <div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-features">
<b><%= translate(locale, "features") %></b> <b><%= translate(locale, "features") %></b>
<hr/> <hr/>
<% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %> <ul class="pure-menu-list">
<div class="pure-u-1 pure-md-1-5"> <% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %>
<% if operator_hash.fetch("features", "all").includes?(feature) %> <li class="pure-menu-item">
<% if operator_hash["features"].split(",").size == 1 %> <% if operator_hash.fetch("features", "all").includes?(feature) %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&features=[a-z]+/, "")}"%>"> <% if operator_hash["features"].split(",").size == 1 %>
<b><%= translate(locale, feature) %></b> <a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&features=[a-z]+/, "")}"%>">
<i class="remove-filter icon ion-md-close"></i> <b><%= translate(locale, feature) %></b>
</a> <i class="remove-filter icon ion-md-close"></i>
<% else %> </a>
<% data = filter_params.match(/.*features=.*(#{feature}(%2C|&|$)).*/).not_nil! %> <% else %>
<% start = data.begin(1) %> <% data = filter_params.match(/.*features=.*(#{feature}(%2C|&|$)).*/).not_nil! %>
<% last = data.end(1) %> <% start = data.begin(1) %>
<% last = data.end(1) %>
<a style="color: inherit;" href="<%= base_url + "#{filter_params[0...start] + filter_params[last..-1]}"%>"> <a style="color: inherit;" href="<%= base_url + "#{filter_params[0...start] + filter_params[last..-1]}"%>">
<b><%= translate(locale, feature) %></b> <b><%= translate(locale, feature) %></b>
<i class="remove-filter icon ion-md-close"></i> <i class="remove-filter icon ion-md-close"></i>
</a> </a>
<% end %> <% end %>
<% elsif operator_hash.has_key?("features") %> <% elsif operator_hash.has_key?("features") %>
<a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>"> <a href="<%= base_url + filter_params.gsub(/features=/, "features=#{feature},")%>">
<%= translate(locale, feature) %> <%= translate(locale, feature) %>
</a> </a>
<% else %> <% else %>
<a href="<%= "#{base_url}#{filter_params}&features=#{feature}"%>"> <a href="<%= "#{base_url}#{filter_params}&features=#{feature}"%>">
<%= translate(locale, feature) %> <%= translate(locale, feature) %>
</a> </a>
<% end %> <% end %>
</div> </li>
<% end %> <% end %>
</div> </ul>
</div>
<div class="pure-u-1-3 pure-u-md-1-5" id="filter-sort"> <div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-sort">
<b><%= translate(locale, "sort") %></b> <b><%= translate(locale, "sort") %></b>
<hr/> <hr/>
<% ["relevance", "rating", "date", "views"].each do |sort| %> <% ["relevance", "rating", "date", "views"].each do |sort| %>