Improve styling for search filters

(cherry picked from commit c28e96bc7b)
This commit is contained in:
syeopite 2021-04-13 00:23:17 -07:00
parent e89a2c9b69
commit 3e09dcaada
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82
3 changed files with 261 additions and 92 deletions

View file

@ -1,12 +1,7 @@
#filters {
display: inline;
margin-top: 15px;
}
#filters > div {
display: inline-block;
}
#filters > summary {
display: block;
margin-bottom: 15px;
@ -22,6 +17,20 @@
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 {
margin-left: 6px;
vertical-align: middle;
@ -47,3 +56,9 @@
.no-theme .remove-filter {
color: #030303
}
@media (prefers-color-scheme: dark) {
.no-theme .remove-filter {
color: #CAC5BE
}
}

View file

@ -0,0 +1,146 @@
<% content_for "header" do %>
<title><%= channel.author %> - Invidious</title>
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= channel.ucid %>" />
<% end %>
<% if channel.banner %>
<div class="h-box">
<img style="width:100%" src="/ggpht<%= URI.parse(channel.banner.not_nil!.gsub("=w1060-", "=w1280-")).request_target %>">
</div>
<div class="h-box">
<hr>
</div>
<% end %>
<div class="pure-g h-box">
<div class="pure-u-2-3">
<div class="channel-profile">
<img src="/ggpht<%= URI.parse(channel.author_thumbnail).request_target %>">
<span><%= channel.author %></span>
</div>
</div>
<div class="pure-u-1-3" style="text-align:right">
<h3>
<a href="/feed/channel/<%= channel.ucid %>"><i class="icon ion-logo-rss"></i></a>
</h3>
</div>
</div>
<div class="h-box">
<p><span style="white-space:pre-wrap"><%= channel.description_html %></span></p>
</div>
<div class="h-box">
<% ucid = channel.ucid %>
<% author = channel.author %>
<% sub_count_text = number_to_short_text(channel.sub_count) %>
<%= rendered "components/subscribe_widget" %>
</div>
<div class="pure-g h-box" id="content-navigation">
<div class="pure-u-1-3">
<!-- TODO Add these!
<a href="https://www.youtube.com/channel/<%= channel.ucid %>"><%= translate(locale, "View channel on YouTube") %></a> -->
<!-- <a href="/redirect?referer=<%= env.get?("current_page") %>"><%= translate(locale, "Switch Invidious Instance") %></a> -->
<!-- TODO Refactor this! -->
<div class="pure-menu pure-menu-horizontal">
<ui class="pure-menu-list">
<% if !channel.auto_generated %>
<% if content_type == 0 %>
<li class="pure-menu-item pure-menu-selected">
<a href="/channel/<%= channel.ucid %>" class="pure-menu-link">
<b><%= translate(locale, "Videos") %></b>
</a>
</li>
<% else %>
<li class="pure-menu-item pure-menu">
<a href="/channel/<%= channel.ucid %>" class="pure-menu-link">
<%= translate(locale, "Videos") %>
</a>
</li>
<% end %>
<% end %>
<% if content_type == 1 || channel.auto_generated %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/playlists">
<b> <%= translate(locale, "Playlists") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/playlists">
<%= translate(locale, "Playlists") %>
</a>
</li>
<% end %>
<% if channel.tabs.includes? "community" %>
<% if content_type == 2 %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">
<b> <%= translate(locale, "Community") %> </b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>/community">
<%= translate(locale, "Community") %>
</a>
</li>
<% end %>
<% end %>
<% if !channel.auto_generated %>
<li class="pure-menu-item navbar" style="margin: 0 0 0 0.5em">
<div class="searchbar">
<form class="pure-form" action="/search" method="get">
<fieldset>
<button class="search-button"><i class="icon ion-md-search"></i></button>
<input type="search" name="q" placeholder="<%= translate(locale, "search") %>" value="<%= env.get?("search").try {|x| HTML.escape(x.as(String)) } %>">
<input type="hidden" name="channel" value="<%= channel.ucid %>">
</fieldset>
</form>
</div>
</li>
<% end %>
</ui>
</div>
</div>
<div class="pure-u-1-3"></div>
<% if content_type == 0 || content_type == 1 %>
<% route = content_type == 1 ? "/playlists" : "" %>
<% url = "/channel/#{channel.ucid + route}" %>
<% if env.params.query %>
<% url += "?#{env.params.query}"%>
<% end %>
<div class="pure-u-1-3"> <!-- Sort by -->
<div class="pure-menu pure-menu-horizontal" style="">
<ul class="pure-menu-list" style="float: right">
<% sort_options.each do |sort| %>
<% if sort_by == sort %>
<li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="<%= url %>?sort_by=<%= sort %>">
<b><%= translate(locale, sort) %></b>
</a>
</li>
<% else %>
<li class="pure-menu-item">
<a class="pure-menu-link" href="<%= url %>?sort_by=<%= sort %>">
<%= translate(locale, sort) %>
</a>
</li>
<% end %>
<% end %>
</ul>
</div>
</div>
<% end %>
</div>
<div class="h-box">
<hr>
</div>

View file

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