From d7901a99f8a364fc4c92bd978dd3708d75bd2b9e Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 10 Apr 2021 01:16:40 -0700 Subject: [PATCH] Add ability to remove search filters from UI --- assets/css/search.css | 26 +++++ src/invidious/views/search.ecr | 171 +++++++++++++++++++-------------- 2 files changed, 124 insertions(+), 73 deletions(-) diff --git a/assets/css/search.css b/assets/css/search.css index 7601fa8ae..7f95c88a3 100644 --- a/assets/css/search.css +++ b/assets/css/search.css @@ -21,3 +21,29 @@ content: "[ - ]"; font-size: 1.5em; } + +.remove-filter { + margin-left: 6px; + vertical-align: middle; +} + +/* No theme */ + +.no-theme .remove-filter { + color: #ffffff +} + + +/* Light theme */ +@media (prefers-color-scheme: light) { + .light-theme .remove-filter { + color: #ffffff + } +} + + +/* Dark theme */ + +.no-theme .remove-filter { + color: #030303 +} diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr index 0ed47edeb..2b9615be5 100644 --- a/src/invidious/views/search.ecr +++ b/src/invidious/views/search.ecr @@ -16,92 +16,117 @@ - <% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&)/, "") %> - <% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %> + <% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&|$)/, "") %> + <% base_url = "/search?q=#{HTML.escape(query.not_nil!)}" %> -
- <%= translate(locale, "date") %> -
- <% ["hour", "today", "week", "month", "year"].each do |date| %> -
- <% if operator_hash.fetch("date", "all") == date %> +
+ <%= translate(locale, "date") %> +
+ <% ["hour", "today", "week", "month", "year"].each do |date| %> +
+ <% if operator_hash.fetch("date", "all") == date %> + "> <%= translate(locale, date) %> - <% else %> - "> - <%= translate(locale, date) %> - - <% end %> -
- <% end %> -
+ + + <% else %> + "> + <%= translate(locale, date) %> + + <% end %> +
+ <% end %> +
-
- <%= translate(locale, "content_type") %> -
- <% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %> -
- <% if operator_hash.fetch("content_type", "all") == content_type %> +
+ <%= translate(locale, "content_type") %> +
+ <% ["video", "channel", "playlist", "movie", "show"].each do |content_type| %> +
+ <% if operator_hash.fetch("content_type", "all") == content_type %> + "> <%= translate(locale, content_type) %> - <% else %> - "> - <%= translate(locale, content_type) %> - - <% end %> -
- <% end %> -
+ + + <% else %> + "> + <%= translate(locale, content_type) %> + + <% end %> +
+ <% end %> +
-
- <%= translate(locale, "duration") %> -
- <% ["short", "long"].each do |duration| %> -
- <% if operator_hash.fetch("duration", "all") == duration %> +
+ <%= translate(locale, "duration") %> +
+ <% ["short", "long"].each do |duration| %> +
+ <% if operator_hash.fetch("duration", "all") == duration %> + "> <%= translate(locale, duration) %> - <% else %> - "> - <%= translate(locale, duration) %> - - <% end %> -
- <% end %> -
+ + + <% else %> + "> + <%= translate(locale, duration) %> + + <% end %> +
+ <% end %> +
-
- <%= translate(locale, "features") %> -
- <% ["hd", "subtitles", "creative_commons", "3d", "live", "purchased", "4k", "360", "location", "hdr"].each do |feature| %> - + <% end %> +
-
- <%= translate(locale, "sort") %> -
- <% ["relevance", "rating", "date", "views"].each do |sort| %> -
- <% if operator_hash.fetch("sort", "relevance") == sort %> +
+ <%= translate(locale, "sort") %> +
+ <% ["relevance", "rating", "date", "views"].each do |sort| %> +
+ <% if operator_hash.fetch("sort", "relevance") == sort %> + "> <%= translate(locale, sort) %> - <% else %> - "> - <%= translate(locale, sort) %> - - <% end %> -
- <% end %> -
+ + + <% else %> + "> + <%= translate(locale, sort) %> + + <% end %> +
+ <% end %>
<% end %>